@Test(expectedExceptions = ConnectException.class) public void ioException() throws IOException { when(client.isConnected()).thenReturn(false); doThrow(IOException.class).when(client).reconnect(); connection.reconnect(); } }
@Test public void alreadyConnected() throws ConnectException { when(client.isConnected()).thenReturn(true); connection.reconnect(); verify(client).isConnected(); verifyNoMoreInteractions(client); }
@Test public void reconnect() throws IOException { when(client.isConnected()).thenReturn(false); connection.reconnect(); verify(client).reconnect(); verify(client, atLeast(1)).isConnected(); verifyNoMoreInteractions(client); }