I am trying to make fun of the following call:
s.socket().bind(new InetSocketAddress(serverIPAddress_, serverPort_), 0);
so I can check what the rest of the code does when it fails in a predictable way. 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'm doing wrong?
source
share