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

        // construct a single base namespace message to verify sent to socket
        TerraHarvestMessage message = TerraHarvestMessageHelper.createBaseMessage();
        
        // replay
        boolean sent = m_SUT.trySendMessage(message);
        assertThat(sent, is(true));

        //check that status is connected
        assertThat(m_SUT.getStatus(), is(ChannelStatus.Active));

        // verify mock socket's output stream was asked to send message in binary form with delimiter at beginning
        byte[] binaryMessage = message.toByteArray();
        // first byte sent will be the varint (https://developers.google.com/protocol-buffers/docs/encoding#varints)
        // representing the length of the message following
        byte[] fullBinaryMessage = new byte[binaryMessage.length + 1]; // leave room for delimiter
        fullBinaryMessage[0] = (byte)binaryMessage.length;
        System.arraycopy(binaryMessage, 0, fullBinaryMessage, 1, binaryMessage.length);
        
        // should pass complete message as byte buffer
        verify(m_TransportLayer, never()).connect(m_Address);
        verify(m_TransportLayer).send(ByteBuffer.wrap(fullBinaryMessage));
        verify(m_TransportLayer, never()).send(ByteBuffer.wrap(fullBinaryMessage), m_Address);
        
        // verify logging is enabled
        verify(m_Logging, times(1)).debug(anyString(), anyVararg());
    }
/**
     * Verify the message is sent using the given transport layer to the address in binary form when the transport
     * layer (connection oriented) is already connected.
     */
Verify the message is sent using the given transport layer to the address in binary form when the transport
layer (connection oriented) is already connected.
Verify the message is sent using the given transport layer to the address in binary form when the transport layer ( connection oriented ) is already connected .
@Test
    public void testTrySendMessageConnected() throws IOException, CCommException
    {
        activateChannel(true, true, null);
        TerraHarvestMessage message = TerraHarvestMessageHelper.createBaseMessage();
        boolean sent = m_SUT.trySendMessage(message);
        assertThat(sent, is(true));
        assertThat(m_SUT.getStatus(), is(ChannelStatus.Active));
        byte[] binaryMessage = message.toByteArray();
        byte[] fullBinaryMessage = new byte[binaryMessage.length + 1]; 
        fullBinaryMessage[0] = (byte)binaryMessage.length;
        System.arraycopy(binaryMessage, 0, fullBinaryMessage, 1, binaryMessage.length);
        verify(m_TransportLayer, never()).connect(m_Address);
        verify(m_TransportLayer).send(ByteBuffer.wrap(fullBinaryMessage));
        verify(m_TransportLayer, never()).send(ByteBuffer.wrap(fullBinaryMessage), m_Address);
        verify(m_Logging, times(1)).debug(anyString(), anyVararg());
    }
@ Test public void testTrySendMessageConnected ( ) throws IOException , CCommException { activateChannel ( true , true , null ) ; TerraHarvestMessage message = TerraHarvestMessageHelper . createBaseMessage ( ) ; boolean sent = m_SUT . trySendMessage ( message ) ; assertThat ( sent , is ( true ) ) ; assertThat ( m_SUT . getStatus ( ) , is ( ChannelStatus . Active ) ) ; byte [ ] binaryMessage = message . toByteArray ( ) ; byte [ ] fullBinaryMessage = new byte [ binaryMessage . length + 1 ] ; fullBinaryMessage [ 0 ] = ( byte ) binaryMessage . length ; System . arraycopy ( binaryMessage , 0 , fullBinaryMessage , 1 , binaryMessage . length ) ; verify ( m_TransportLayer , never ( ) ) . connect ( m_Address ) ; verify ( m_TransportLayer ) . send ( ByteBuffer . wrap ( fullBinaryMessage ) ) ; verify ( m_TransportLayer , never ( ) ) . send ( ByteBuffer . wrap ( fullBinaryMessage ) , m_Address ) ; verify ( m_Logging , times ( 1 ) ) . debug ( anyString ( ) , anyVararg ( ) ) ; }
Verify the message is sent using the given transport layer to the address in binary form when the transport
 layer (connection oriented) is already connected.
Verify the message is sent using the given transport layer to the address in binary form when the transport layer ( connection oriented ) is already connected .
// Connection-oriented channel that is connected // construct a single base namespace message to verify sent to socket // replay //check that status is connected // verify mock socket's output stream was asked to send message in binary form with delimiter at beginning // first byte sent will be the varint (https://developers.google.com/protocol-buffers/docs/encoding#varints) // representing the length of the message following // leave room for delimiter // should pass complete message as byte buffer // verify logging is enabled