mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestRemoteChannelLookupImpl.java
@Test
    public void testGetSocketChannel()
    {
        // mock the sockets
        Socket socket1 = mock(Socket.class);
        
        stubSocketChannel(m_ClientSocketChannel, "host", 100, false);
        stubTransportChannel(m_TransportChannel, "test", "local", "remote");
        
        // replay
        m_SUT.newServerSocketChannel(socket1);
        m_SUT.syncClientSocketChannel("host", 100, 1);
        // sync transport channel just to make sure those are ignored later
        m_SUT.syncTransportChannel("test", "local", "remote", 2);
        
        // mock channels to be completely different
        stubSocketChannel(m_ServerSocketChannel, "test-host1", 1000, false);
        stubSocketChannel(m_ClientSocketChannel, "test-host2", 2000, false);
        
        // verify channel is returned for the given socket
        assertThat(m_SUT.getSocketChannel("test-host1", 1000), is(m_ServerSocketChannel));
        assertThat(m_SUT.getSocketChannel("test-host2", 2000), is(m_ClientSocketChannel));
        
        // mock channels so port is the same
        stubSocketChannel(m_ServerSocketChannel, "test-host1", 1000, false);
        stubSocketChannel(m_ClientSocketChannel, "test-host2", 1000, false);
        
        // verify channel is returned for the given socket
        assertThat(m_SUT.getSocketChannel("test-host1", 1000), is(m_ServerSocketChannel));
        assertThat(m_SUT.getSocketChannel("test-host2", 1000), is(m_ClientSocketChannel));
        
        // mock channels so hosts are the same
        stubSocketChannel(m_ServerSocketChannel, "test-host1", 1000, false);
        stubSocketChannel(m_ClientSocketChannel, "test-host1", 2000, false);
        
        // verify channel is returned for the given socket
        assertThat(m_SUT.getSocketChannel("test-host1", 1000), is(m_ServerSocketChannel));
        assertThat(m_SUT.getSocketChannel("test-host1", 2000), is(m_ClientSocketChannel));
        
        // verify null returned if not found
        assertThat(m_SUT.getSocketChannel("test-host-blah", 5000), is(nullValue()));
    }
/**
     * Verify getSocketChannel returns a channel if added only (not synced).

     * Verify null is returned for a socket channel not in the lookup.
     */
Verify getSocketChannel returns a channel if added only (not synced).
Verify null is returned for a socket channel not in the lookup.
Verify getSocketChannel returns a channel if added only ( not synced ) . Verify null is returned for a socket channel not in the lookup .
@Test
    public void testGetSocketChannel()
    {
        Socket socket1 = mock(Socket.class);
        stubSocketChannel(m_ClientSocketChannel, "host", 100, false);
        stubTransportChannel(m_TransportChannel, "test", "local", "remote");
        m_SUT.newServerSocketChannel(socket1);
        m_SUT.syncClientSocketChannel("host", 100, 1);
        m_SUT.syncTransportChannel("test", "local", "remote", 2);
        stubSocketChannel(m_ServerSocketChannel, "test-host1", 1000, false);
        stubSocketChannel(m_ClientSocketChannel, "test-host2", 2000, false);
        assertThat(m_SUT.getSocketChannel("test-host1", 1000), is(m_ServerSocketChannel));
        assertThat(m_SUT.getSocketChannel("test-host2", 2000), is(m_ClientSocketChannel));
        stubSocketChannel(m_ServerSocketChannel, "test-host1", 1000, false);
        stubSocketChannel(m_ClientSocketChannel, "test-host2", 1000, false);
        assertThat(m_SUT.getSocketChannel("test-host1", 1000), is(m_ServerSocketChannel));
        assertThat(m_SUT.getSocketChannel("test-host2", 1000), is(m_ClientSocketChannel));
        stubSocketChannel(m_ServerSocketChannel, "test-host1", 1000, false);
        stubSocketChannel(m_ClientSocketChannel, "test-host1", 2000, false);
        assertThat(m_SUT.getSocketChannel("test-host1", 1000), is(m_ServerSocketChannel));
        assertThat(m_SUT.getSocketChannel("test-host1", 2000), is(m_ClientSocketChannel));
        assertThat(m_SUT.getSocketChannel("test-host-blah", 5000), is(nullValue()));
    }
@ Test public void testGetSocketChannel ( ) { Socket socket1 = mock ( Socket . class ) ; stubSocketChannel ( m_ClientSocketChannel , "host" , 100 , false ) ; stubTransportChannel ( m_TransportChannel , "test" , "local" , "remote" ) ; m_SUT . newServerSocketChannel ( socket1 ) ; m_SUT . syncClientSocketChannel ( "host" , 100 , 1 ) ; m_SUT . syncTransportChannel ( "test" , "local" , "remote" , 2 ) ; stubSocketChannel ( m_ServerSocketChannel , "test-host1" , 1000 , false ) ; stubSocketChannel ( m_ClientSocketChannel , "test-host2" , 2000 , false ) ; assertThat ( m_SUT . getSocketChannel ( "test-host1" , 1000 ) , is ( m_ServerSocketChannel ) ) ; assertThat ( m_SUT . getSocketChannel ( "test-host2" , 2000 ) , is ( m_ClientSocketChannel ) ) ; stubSocketChannel ( m_ServerSocketChannel , "test-host1" , 1000 , false ) ; stubSocketChannel ( m_ClientSocketChannel , "test-host2" , 1000 , false ) ; assertThat ( m_SUT . getSocketChannel ( "test-host1" , 1000 ) , is ( m_ServerSocketChannel ) ) ; assertThat ( m_SUT . getSocketChannel ( "test-host2" , 1000 ) , is ( m_ClientSocketChannel ) ) ; stubSocketChannel ( m_ServerSocketChannel , "test-host1" , 1000 , false ) ; stubSocketChannel ( m_ClientSocketChannel , "test-host1" , 2000 , false ) ; assertThat ( m_SUT . getSocketChannel ( "test-host1" , 1000 ) , is ( m_ServerSocketChannel ) ) ; assertThat ( m_SUT . getSocketChannel ( "test-host1" , 2000 ) , is ( m_ClientSocketChannel ) ) ; assertThat ( m_SUT . getSocketChannel ( "test-host-blah" , 5000 ) , is ( nullValue ( ) ) ) ; }
Verify getSocketChannel returns a channel if added only (not synced).
Verify getSocketChannel returns a channel if added only ( not synced ) .
// mock the sockets // replay // sync transport channel just to make sure those are ignored later // mock channels to be completely different // verify channel is returned for the given socket // mock channels so port is the same // verify channel is returned for the given socket // mock channels so hosts are the same // verify channel is returned for the given socket // verify null returned if not found