mil.dod.th.remote.client/test/mil/dod/th/remote/client/impl/TestCommands.java
@Test
    public void testConnectException() throws IOException
    {
        try (ServerSocket server = new ServerSocket(0))
        {
            m_SUT.connect(m_CmdSession, LOCALHOST, server.getLocalPort());

            // mock
            doThrow(new IllegalStateException()).when(m_MessageListenerService)
                .addRemoteChannel(anyInt(), Mockito.any(InputStream.class), any(ChannelStateCallback.class));

            // replay
            try
            {
                m_SUT.connect(m_CmdSession, LOCALHOST, server.getLocalPort());
                fail("connect should exception");
            }
            catch (Exception ex)
            {
                // Expected
            }
        }
    }
/**
     * Verify that an exception is thrown when trying to make a connection twice without disconnecting first.
     */
Verify that an exception is thrown when trying to make a connection twice without disconnecting first.
Verify that an exception is thrown when trying to make a connection twice without disconnecting first .
@Test
    public void testConnectException() throws IOException
    {
        try (ServerSocket server = new ServerSocket(0))
        {
            m_SUT.connect(m_CmdSession, LOCALHOST, server.getLocalPort());
            doThrow(new IllegalStateException()).when(m_MessageListenerService)
                .addRemoteChannel(anyInt(), Mockito.any(InputStream.class), any(ChannelStateCallback.class));
            try
            {
                m_SUT.connect(m_CmdSession, LOCALHOST, server.getLocalPort());
                fail("connect should exception");
            }
            catch (Exception ex)
            {
            }
        }
    }
@ Test public void testConnectException ( ) throws IOException { try ( ServerSocket server = new ServerSocket ( 0 ) ) { m_SUT . connect ( m_CmdSession , LOCALHOST , server . getLocalPort ( ) ) ; doThrow ( new IllegalStateException ( ) ) . when ( m_MessageListenerService ) . addRemoteChannel ( anyInt ( ) , Mockito . any ( InputStream . class ) , any ( ChannelStateCallback . class ) ) ; try { m_SUT . connect ( m_CmdSession , LOCALHOST , server . getLocalPort ( ) ) ; fail ( "connect should exception" ) ; } catch ( Exception ex ) { } } }
Verify that an exception is thrown when trying to make a connection twice without disconnecting first.
Verify that an exception is thrown when trying to make a connection twice without disconnecting first .
// mock // replay // Expected