How can I mock a method in easymock that shall return one of its parameters?

Well, the easiest way would be to just use the Capture in the IAnswer implementation… when doing this inline you have to declare it final of course. MyService mock = createMock(MyService.class); final Capture<ParamAndReturnType> myCapture = new Capture<ParamAndReturnType>(); expect(mock.someMethod(capture(myCapture))).andAnswer( new IAnswer<ParamAndReturnType>() { @Override public ParamAndReturnType answer() throws Throwable { return myCapture.getValue(); } } ); replay(mock) This … Read more

How do I capture the output from the ls or find command to store all file names in an array?

To answer your exact question, use the following: arr=( $(find /path/to/toplevel/dir -type f) ) Example $ find . -type f ./test1.txt ./test2.txt ./test3.txt $ arr=( $(find . -type f) ) $ echo ${#arr[@]} 3 $ echo ${arr[@]} ./test1.txt ./test2.txt ./test3.txt $ echo ${arr[0]} ./test1.txt However, if you just want to process files one at a … Read more

How can I capture the stdout from a process that is ALREADY running

True solution for OSX Write the following function to your ~/.bashrc or ~/.zshrc. capture() { sudo dtrace -p “$1” -qn ‘ syscall::write*:entry /pid == $target && arg0 == 1/ { printf(“%s”, copyinstr(arg1, arg2)); } ‘ } Usage: example@localhost:~$ perl -e ‘STDOUT->autoflush; while (1) { print “Hello\n”; sleep 1; }’ >/dev/null & [1] 97755 example@localhost:~$ capture … Read more

Android > 4.0 : Ideas how to record/capture internal audio (e.g. STREAM_MUSIC)?

You must pass audio traffic through your local socket server: Create local socket server Modify audio http stream address to path is thru your local socket server, for example for address http://example.com/stream.mp3 -> http://127.0.0.1:8888/http://example.com/stream.mp3 where 8888 is your socket port. Play http://127.0.0.1:8888/http://example.com/stream.mp3 with default media player Read all incoming requests to port 8888 in your … Read more

Capture incoming traffic in tcpdump

In Bash shell try this: tcpdump -i eth0 tcp and dst host $MyIpAddress and not src net $MyNetworkAddress/$myNetworkBytes or this equivalent formulation: tcpdump -i eth0 ip proto \\tcp and dst host $MyIpAddress and not src net $MyNetworkAddress/$myNetworkBytes On my system this resolves to something like: tcpdump -i eth0 tcp and dst host 10.0.0.35 and not … Read more

How to tell a lambda function to capture a copy instead of a reference in C#?

What the compiler is doing is pulling your lambda and any variables captured by the lambda into a compiler generated nested class. After compilation your example looks a lot like this: class Program { delegate void Action(); static void Main(string[] args) { List<Action> actions = new List<Action>(); DisplayClass1 displayClass1 = new DisplayClass1(); for (displayClass1.i = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)