mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/transport/TestTransportChannelImpl.java
@Test
    public void testTrySendMessageConnectException() throws IOException, CCommException
    {
        // Connection-oriented channel that is not available
        activateChannel(true, false, null);

        // construct a single base namespace message to verify sent to socket
        TerraHarvestMessage message = TerraHarvestMessageHelper.createBaseMessage();

        doThrow(new CCommException(FormatProblem.TIMEOUT)).when(m_TransportLayer).connect(Mockito.any(Address.class));

        // replay
        boolean sent = m_SUT.trySendMessage(message);
        assertThat("message is not sent because unable to connect", sent, is(false));

        //check that status is unavailable
        assertThat(m_SUT.getStatus(), is(ChannelStatus.Unavailable));

        doThrow(new IllegalStateException()).when(m_TransportLayer).connect(Mockito.any(Address.class));

        // replay
        sent = m_SUT.trySendMessage(message);
        assertThat(sent, is(true));

        //check that status is still active
        assertThat(m_SUT.getStatus(), is(ChannelStatus.Active));
    }
/**
     * Verify the message is not sent if the endpoint is not available according to transport layer.
     */
Verify the message is not sent if the endpoint is not available according to transport layer.
Verify the message is not sent if the endpoint is not available according to transport layer .
@Test
    public void testTrySendMessageConnectException() throws IOException, CCommException
    {
        activateChannel(true, false, null);
        TerraHarvestMessage message = TerraHarvestMessageHelper.createBaseMessage();
        doThrow(new CCommException(FormatProblem.TIMEOUT)).when(m_TransportLayer).connect(Mockito.any(Address.class));
        boolean sent = m_SUT.trySendMessage(message);
        assertThat("message is not sent because unable to connect", sent, is(false));
        assertThat(m_SUT.getStatus(), is(ChannelStatus.Unavailable));
        doThrow(new IllegalStateException()).when(m_TransportLayer).connect(Mockito.any(Address.class));
        sent = m_SUT.trySendMessage(message);
        assertThat(sent, is(true));
        assertThat(m_SUT.getStatus(), is(ChannelStatus.Active));
    }
@ Test public void testTrySendMessageConnectException ( ) throws IOException , CCommException { activateChannel ( true , false , null ) ; TerraHarvestMessage message = TerraHarvestMessageHelper . createBaseMessage ( ) ; doThrow ( new CCommException ( FormatProblem . TIMEOUT ) ) . when ( m_TransportLayer ) . connect ( Mockito . any ( Address . class ) ) ; boolean sent = m_SUT . trySendMessage ( message ) ; assertThat ( "message is not sent because unable to connect" , sent , is ( false ) ) ; assertThat ( m_SUT . getStatus ( ) , is ( ChannelStatus . Unavailable ) ) ; doThrow ( new IllegalStateException ( ) ) . when ( m_TransportLayer ) . connect ( Mockito . any ( Address . class ) ) ; sent = m_SUT . trySendMessage ( message ) ; assertThat ( sent , is ( true ) ) ; assertThat ( m_SUT . getStatus ( ) , is ( ChannelStatus . Active ) ) ; }
Verify the message is not sent if the endpoint is not available according to transport layer.
Verify the message is not sent if the endpoint is not available according to transport layer .
// Connection-oriented channel that is not available // construct a single base namespace message to verify sent to socket // replay //check that status is unavailable // replay //check that status is still active