mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestServerSocketChannel.java
@Test
    public void testGetBytesTransmitted() throws IOException
    {
        // mock the socket that will be used to send the message
        Socket socket = mock(Socket.class);
        SocketAddress socketAddress = mock(SocketAddress.class);
        when(socketAddress.toString()).thenReturn(REMOTE_SOCKET_ADDR);
        when(socket.getRemoteSocketAddress()).thenReturn(socketAddress);
        
        // activate method expects a connected socket to be passed in
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(ServerSocketChannel.SOCKET_PROP_KEY, socket);
        m_SUT.activate(props);
        
        // verify bytes transmitted starts off at zero
        assertThat(m_SUT.getBytesTransmitted(), is(0L));
        
        TerraHarvestMessage message = TerraHarvestMessageHelper.createBaseMessage();
        m_SUT.trySendMessage(message);
        
        // verify bytes transmitted now equals data transmitted
        assertThat(m_SUT.getBytesTransmitted(), is(new Integer(message.getSerializedSize()).longValue()));
        
        m_SUT.trySendMessage(message);
        
        // verify bytes transmitted is updated again
        assertThat(m_SUT.getBytesTransmitted(), is(new Integer(message.getSerializedSize() * 2).longValue()));
    }
/**
     * Verify bytes transmitted is correct.
     */
Verify bytes transmitted is correct.
Verify bytes transmitted is correct .
@Test
    public void testGetBytesTransmitted() throws IOException
    {
        Socket socket = mock(Socket.class);
        SocketAddress socketAddress = mock(SocketAddress.class);
        when(socketAddress.toString()).thenReturn(REMOTE_SOCKET_ADDR);
        when(socket.getRemoteSocketAddress()).thenReturn(socketAddress);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(ServerSocketChannel.SOCKET_PROP_KEY, socket);
        m_SUT.activate(props);
        assertThat(m_SUT.getBytesTransmitted(), is(0L));
        TerraHarvestMessage message = TerraHarvestMessageHelper.createBaseMessage();
        m_SUT.trySendMessage(message);
        assertThat(m_SUT.getBytesTransmitted(), is(new Integer(message.getSerializedSize()).longValue()));
        m_SUT.trySendMessage(message);
        assertThat(m_SUT.getBytesTransmitted(), is(new Integer(message.getSerializedSize() * 2).longValue()));
    }
@ Test public void testGetBytesTransmitted ( ) throws IOException { Socket socket = mock ( Socket . class ) ; SocketAddress socketAddress = mock ( SocketAddress . class ) ; when ( socketAddress . toString ( ) ) . thenReturn ( REMOTE_SOCKET_ADDR ) ; when ( socket . getRemoteSocketAddress ( ) ) . thenReturn ( socketAddress ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( ServerSocketChannel . SOCKET_PROP_KEY , socket ) ; m_SUT . activate ( props ) ; assertThat ( m_SUT . getBytesTransmitted ( ) , is ( 0L ) ) ; TerraHarvestMessage message = TerraHarvestMessageHelper . createBaseMessage ( ) ; m_SUT . trySendMessage ( message ) ; assertThat ( m_SUT . getBytesTransmitted ( ) , is ( new Integer ( message . getSerializedSize ( ) ) . longValue ( ) ) ) ; m_SUT . trySendMessage ( message ) ; assertThat ( m_SUT . getBytesTransmitted ( ) , is ( new Integer ( message . getSerializedSize ( ) * 2 ) . longValue ( ) ) ) ; }
Verify bytes transmitted is correct.
Verify bytes transmitted is correct .
// mock the socket that will be used to send the message // activate method expects a connected socket to be passed in // verify bytes transmitted starts off at zero // verify bytes transmitted now equals data transmitted // verify bytes transmitted is updated again