mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/channel/TestChannelMgrImpl.java
@Test
    public void testGetSocketChannels()
    {
        //mocking
        SocketChannel socChannel = createMockSocketChannel("localhost", 3001, ChannelStatus.Unknown);
        
        Set<RemoteChannel> setChans = new HashSet<RemoteChannel>();
        setChans.add(socChannel);
        
        Map<Integer, Set<RemoteChannel>> channels = new HashMap<Integer, Set<RemoteChannel>>();
        channels.put(1957, setChans);
        when(m_RemoteChannelLookup.getAllChannels()).thenReturn(channels);
        
        //check that the mock channel is returned, this would be the same behavior as if the channel was created
        //in the remote channel look up and merely retrieved by the channel manager
        assertThat(m_SUT.getSocketChannel("localhost", 3001), is(notNullValue()));
        SocketChannelModel socketModel = m_SUT.getSocketChannel("localhost", 3001);
        
        //check the model is what was expected
        assertThat(socketModel.getHost(), is("localhost"));
        assertThat(socketModel.getPort(), is(3001));
        assertThat(socketModel.getControllerId(), is(1957));
        assertThat(socketModel.getBytesTransmitted(), is(991L));
        assertThat(socketModel.getBytesReceived(), is(402L));
        assertThat(socketModel.getQueuedMessageCount(), is(1));
    }
/**
     * Test that a socket channel model contains all info from the actual RemoteChannel.
     */
Test that a socket channel model contains all info from the actual RemoteChannel.
Test that a socket channel model contains all info from the actual RemoteChannel .
@Test
    public void testGetSocketChannels()
    {
        SocketChannel socChannel = createMockSocketChannel("localhost", 3001, ChannelStatus.Unknown);
        Set<RemoteChannel> setChans = new HashSet<RemoteChannel>();
        setChans.add(socChannel);
        Map<Integer, Set<RemoteChannel>> channels = new HashMap<Integer, Set<RemoteChannel>>();
        channels.put(1957, setChans);
        when(m_RemoteChannelLookup.getAllChannels()).thenReturn(channels);
        assertThat(m_SUT.getSocketChannel("localhost", 3001), is(notNullValue()));
        SocketChannelModel socketModel = m_SUT.getSocketChannel("localhost", 3001);
        assertThat(socketModel.getHost(), is("localhost"));
        assertThat(socketModel.getPort(), is(3001));
        assertThat(socketModel.getControllerId(), is(1957));
        assertThat(socketModel.getBytesTransmitted(), is(991L));
        assertThat(socketModel.getBytesReceived(), is(402L));
        assertThat(socketModel.getQueuedMessageCount(), is(1));
    }
@ Test public void testGetSocketChannels ( ) { SocketChannel socChannel = createMockSocketChannel ( "localhost" , 3001 , ChannelStatus . Unknown ) ; Set < RemoteChannel > setChans = new HashSet < RemoteChannel > ( ) ; setChans . add ( socChannel ) ; Map < Integer , Set < RemoteChannel > > channels = new HashMap < Integer , Set < RemoteChannel > > ( ) ; channels . put ( 1957 , setChans ) ; when ( m_RemoteChannelLookup . getAllChannels ( ) ) . thenReturn ( channels ) ; assertThat ( m_SUT . getSocketChannel ( "localhost" , 3001 ) , is ( notNullValue ( ) ) ) ; SocketChannelModel socketModel = m_SUT . getSocketChannel ( "localhost" , 3001 ) ; assertThat ( socketModel . getHost ( ) , is ( "localhost" ) ) ; assertThat ( socketModel . getPort ( ) , is ( 3001 ) ) ; assertThat ( socketModel . getControllerId ( ) , is ( 1957 ) ) ; assertThat ( socketModel . getBytesTransmitted ( ) , is ( 991L ) ) ; assertThat ( socketModel . getBytesReceived ( ) , is ( 402L ) ) ; assertThat ( socketModel . getQueuedMessageCount ( ) , is ( 1 ) ) ; }
Test that a socket channel model contains all info from the actual RemoteChannel.
Test that a socket channel model contains all info from the actual RemoteChannel .
//mocking //check that the mock channel is returned, this would be the same behavior as if the channel was created //in the remote channel look up and merely retrieved by the channel manager //check the model is what was expected