mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/channel/TestChannelMgrImpl.java
@Test
    public void testRemoveChannelMultiple() throws IllegalArgumentException
    {
        // mock lookup
        SocketChannel socketChannel = createMockSocketChannel("host", 1000, ChannelStatus.Unknown);
        TransportChannel transportChannel = createMockTransportChannel("tl1", "local", 
                "remote", ChannelStatus.Unavailable);
        
        when(m_RemoteChannelLookup.getSocketChannel("host", 1000)).thenReturn(socketChannel);
        when(m_RemoteChannelLookup.getTransportChannel("tl1", "local", "remote")).thenReturn(transportChannel);
        
        //create channel models that will be removed
        TransportChannelModel transportChannelModel = new TransportChannelModel(1, transportChannel);
        SocketChannelModel socketChannelModel = new SocketChannelModel(1, socketChannel);
        
        //mock the list of channels from the remote channel look up, this list does not include the transport channel
        //because it is being removed
        List<RemoteChannel> channels = new ArrayList<RemoteChannel>();
        channels.add(socketChannel);
        when(m_RemoteChannelLookup.getChannels(1)).thenReturn(channels);
        //remove the transport channel
        m_SUT.removeChannel(transportChannelModel); 

        // verify lookup told to remove the correct channel
        verify(m_RemoteChannelLookup).removeChannel(transportChannel);

        //mock that there are no channels for the id after removal of the socket channel
        when(m_RemoteChannelLookup.getChannels(1)).thenReturn(new ArrayList<RemoteChannel>());
        // now remove the socket channel
        m_SUT.removeChannel(socketChannelModel); 

        // verify lookup told to remove the correct channel
        verify(m_RemoteChannelLookup).removeChannel(socketChannel);
    }
/**
     * Verify that removing a channel removes it from the lookup.
     * 
     * Verify that the controller for the channel is NOT removed after one channel is removed.
     */
Verify that removing a channel removes it from the lookup.

Verify that the controller for the channel is NOT removed after one channel is removed.
Verify that removing a channel removes it from the lookup . Verify that the controller for the channel is NOT removed after one channel is removed .
@Test
    public void testRemoveChannelMultiple() throws IllegalArgumentException
    {
        SocketChannel socketChannel = createMockSocketChannel("host", 1000, ChannelStatus.Unknown);
        TransportChannel transportChannel = createMockTransportChannel("tl1", "local", 
                "remote", ChannelStatus.Unavailable);
        when(m_RemoteChannelLookup.getSocketChannel("host", 1000)).thenReturn(socketChannel);
        when(m_RemoteChannelLookup.getTransportChannel("tl1", "local", "remote")).thenReturn(transportChannel);
        TransportChannelModel transportChannelModel = new TransportChannelModel(1, transportChannel);
        SocketChannelModel socketChannelModel = new SocketChannelModel(1, socketChannel);
        List<RemoteChannel> channels = new ArrayList<RemoteChannel>();
        channels.add(socketChannel);
        when(m_RemoteChannelLookup.getChannels(1)).thenReturn(channels);
        m_SUT.removeChannel(transportChannelModel); 
        verify(m_RemoteChannelLookup).removeChannel(transportChannel);
        when(m_RemoteChannelLookup.getChannels(1)).thenReturn(new ArrayList<RemoteChannel>());
        m_SUT.removeChannel(socketChannelModel); 
        verify(m_RemoteChannelLookup).removeChannel(socketChannel);
    }
@ Test public void testRemoveChannelMultiple ( ) throws IllegalArgumentException { SocketChannel socketChannel = createMockSocketChannel ( "host" , 1000 , ChannelStatus . Unknown ) ; TransportChannel transportChannel = createMockTransportChannel ( "tl1" , "local" , "remote" , ChannelStatus . Unavailable ) ; when ( m_RemoteChannelLookup . getSocketChannel ( "host" , 1000 ) ) . thenReturn ( socketChannel ) ; when ( m_RemoteChannelLookup . getTransportChannel ( "tl1" , "local" , "remote" ) ) . thenReturn ( transportChannel ) ; TransportChannelModel transportChannelModel = new TransportChannelModel ( 1 , transportChannel ) ; SocketChannelModel socketChannelModel = new SocketChannelModel ( 1 , socketChannel ) ; List < RemoteChannel > channels = new ArrayList < RemoteChannel > ( ) ; channels . add ( socketChannel ) ; when ( m_RemoteChannelLookup . getChannels ( 1 ) ) . thenReturn ( channels ) ; m_SUT . removeChannel ( transportChannelModel ) ; verify ( m_RemoteChannelLookup ) . removeChannel ( transportChannel ) ; when ( m_RemoteChannelLookup . getChannels ( 1 ) ) . thenReturn ( new ArrayList < RemoteChannel > ( ) ) ; m_SUT . removeChannel ( socketChannelModel ) ; verify ( m_RemoteChannelLookup ) . removeChannel ( socketChannel ) ; }
Verify that removing a channel removes it from the lookup.
Verify that removing a channel removes it from the lookup .
// mock lookup //create channel models that will be removed //mock the list of channels from the remote channel look up, this list does not include the transport channel //because it is being removed //remove the transport channel // verify lookup told to remove the correct channel //mock that there are no channels for the id after removal of the socket channel // now remove the socket channel // verify lookup told to remove the correct channel