mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestRemoteChannelLookupImpl.java
@Test
    public void testRemoveServerSocketChannel()
    {
        // mock the sockets for input
        Socket socket1 = mock(Socket.class);
        
        int systemId = 100;
        
        stubSocketChannel(m_ClientSocketChannel, "host", 100, false);
        
        // create channels
        SocketChannel serverChannel = m_SUT.newServerSocketChannel(socket1);
        SocketChannel clientChannel = m_SUT.syncClientSocketChannel("host", 100, systemId);
        
        // remove 1 channel, verify channel is disposed, then verify channel is still available
        // should be false since channel was never synced
        assertThat(m_SUT.removeChannel(serverChannel), is(false));
        verify(m_ServerSocketChannelInstance).dispose();
        assertThat((SocketChannel)m_SUT.getChannel(systemId), is(clientChannel));
        
        // remove other channel
        assertThat(m_SUT.removeChannel(clientChannel), is(true)); // should be true since it was synced to system id
        // instance should be disposed for each removed channel
        verify(m_ClientSocketChannelInstance).dispose();
        
        // should be no channels available now
        assertThat(m_SUT.getChannels(systemId).size(), is(0));
        
        // try removing a channel that is no longer managed at all
        assertThat(m_SUT.removeChannel(serverChannel), is(false));
    }
/**
     * Verify removing a channel will remove channel from list and dispose of instance.
     */
Verify removing a channel will remove channel from list and dispose of instance.
Verify removing a channel will remove channel from list and dispose of instance .
@Test
    public void testRemoveServerSocketChannel()
    {
        Socket socket1 = mock(Socket.class);
        int systemId = 100;
        stubSocketChannel(m_ClientSocketChannel, "host", 100, false);
        SocketChannel serverChannel = m_SUT.newServerSocketChannel(socket1);
        SocketChannel clientChannel = m_SUT.syncClientSocketChannel("host", 100, systemId);
        assertThat(m_SUT.removeChannel(serverChannel), is(false));
        verify(m_ServerSocketChannelInstance).dispose();
        assertThat((SocketChannel)m_SUT.getChannel(systemId), is(clientChannel));
        assertThat(m_SUT.removeChannel(clientChannel), is(true)); 
        verify(m_ClientSocketChannelInstance).dispose();
        assertThat(m_SUT.getChannels(systemId).size(), is(0));
        assertThat(m_SUT.removeChannel(serverChannel), is(false));
    }
@ Test public void testRemoveServerSocketChannel ( ) { Socket socket1 = mock ( Socket . class ) ; int systemId = 100 ; stubSocketChannel ( m_ClientSocketChannel , "host" , 100 , false ) ; SocketChannel serverChannel = m_SUT . newServerSocketChannel ( socket1 ) ; SocketChannel clientChannel = m_SUT . syncClientSocketChannel ( "host" , 100 , systemId ) ; assertThat ( m_SUT . removeChannel ( serverChannel ) , is ( false ) ) ; verify ( m_ServerSocketChannelInstance ) . dispose ( ) ; assertThat ( ( SocketChannel ) m_SUT . getChannel ( systemId ) , is ( clientChannel ) ) ; assertThat ( m_SUT . removeChannel ( clientChannel ) , is ( true ) ) ; verify ( m_ClientSocketChannelInstance ) . dispose ( ) ; assertThat ( m_SUT . getChannels ( systemId ) . size ( ) , is ( 0 ) ) ; assertThat ( m_SUT . removeChannel ( serverChannel ) , is ( false ) ) ; }
Verify removing a channel will remove channel from list and dispose of instance.
Verify removing a channel will remove channel from list and dispose of instance .
// mock the sockets for input // create channels // remove 1 channel, verify channel is disposed, then verify channel is still available // should be false since channel was never synced // remove other channel // should be true since it was synced to system id // instance should be disposed for each removed channel // should be no channels available now // try removing a channel that is no longer managed at all