I am trying to mock the following call:
s.socket().bind(new InetSocketAddress(serverIPAddress_, serverPort_), 0);
so I can test what the rest of the code does when this fails in predictable ways. I use this in my test case:
ServerSocketChannel ssc = mock(ServerSocketChannel.class);
when(ServerSocketChannel.open()).thenReturn(ssc);
doNothing().when(ssc.socket().bind(any(), anyInt()));
However, the above does not compile with:
[javac] /home/yann/projects/flexnbd/src/uk/co/bytemark/flexnbd/FlexNBDTest.java:147: cannot find symbol
[javac] symbol : method bind(java.lang.Object,int)
[javac] location: class java.net.ServerSocket
[javac] doNothing().when(ssc.socket().bind(any(), anyInt()));
[javac] ^
[javac] 1 error
Any idea what I am doing wrong?