mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/transport/TestTransportChannelImpl.java
@SuppressWarnings({ "rawtypes", "unchecked" })
    // this timeout is less then time the thread below blocks to prove it is blocking on a separate thread
    @Test(timeout = 2000)
    public void testActivate() throws InterruptedException, CCommException
    {
        // mock the message listener and its run method to block, need to block to verify run method is called on 
        // separate thread
        TransportMessageListener transportMessageListener = mock(TransportMessageListener.class);
        when(m_Instance.getInstance()).thenReturn(transportMessageListener);
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable
            {
                Thread.sleep(200000); // simulate a blocking call
                return null;
            }
        }).when(transportMessageListener).run();

        // Connection-less channel that is available
        activateChannel(false, true, null);

        ArgumentCaptor<Dictionary> dictionaryCaptor = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_ListenerFactory).newInstance(dictionaryCaptor.capture());
        assertThat((TransportChannelImpl)dictionaryCaptor.getValue().get(TransportMessageListener.CHANNEL_PROP_KEY), 
                is(m_SUT));
        
        Thread.sleep(500); // allow thread to run
        
        // verify listener was told to run and on a separate thread, know on a separate thread because this test
        // didn't timeout waiting on the run method to exit
        verify(transportMessageListener).run();
    }
/**
     * Verify that the channel status and props are initialized.
     * 
     * Verify message listener is created and started on a thread.
     */
Verify that the channel status and props are initialized.

Verify message listener is created and started on a thread.
Verify that the channel status and props are initialized . Verify message listener is created and started on a thread .
@SuppressWarnings({ "rawtypes", "unchecked" })
    @Test(timeout = 2000)
    public void testActivate() throws InterruptedException, CCommException
    {
        TransportMessageListener transportMessageListener = mock(TransportMessageListener.class);
        when(m_Instance.getInstance()).thenReturn(transportMessageListener);
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable
            {
                Thread.sleep(200000); 
                return null;
            }
        }).when(transportMessageListener).run();
        activateChannel(false, true, null);
        ArgumentCaptor<Dictionary> dictionaryCaptor = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_ListenerFactory).newInstance(dictionaryCaptor.capture());
        assertThat((TransportChannelImpl)dictionaryCaptor.getValue().get(TransportMessageListener.CHANNEL_PROP_KEY), 
                is(m_SUT));
        Thread.sleep(500); 
        verify(transportMessageListener).run();
    }
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ Test ( timeout = 2000 ) public void testActivate ( ) throws InterruptedException , CCommException { TransportMessageListener transportMessageListener = mock ( TransportMessageListener . class ) ; when ( m_Instance . getInstance ( ) ) . thenReturn ( transportMessageListener ) ; doAnswer ( new Answer < Object > ( ) { @ Override public Object answer ( InvocationOnMock invocation ) throws Throwable { Thread . sleep ( 200000 ) ; return null ; } } ) . when ( transportMessageListener ) . run ( ) ; activateChannel ( false , true , null ) ; ArgumentCaptor < Dictionary > dictionaryCaptor = ArgumentCaptor . forClass ( Dictionary . class ) ; verify ( m_ListenerFactory ) . newInstance ( dictionaryCaptor . capture ( ) ) ; assertThat ( ( TransportChannelImpl ) dictionaryCaptor . getValue ( ) . get ( TransportMessageListener . CHANNEL_PROP_KEY ) , is ( m_SUT ) ) ; Thread . sleep ( 500 ) ; verify ( transportMessageListener ) . run ( ) ; }
Verify that the channel status and props are initialized.
Verify that the channel status and props are initialized .
// this timeout is less then time the thread below blocks to prove it is blocking on a separate thread // mock the message listener and its run method to block, need to block to verify run method is called on  // separate thread // simulate a blocking call // Connection-less channel that is available // allow thread to run // verify listener was told to run and on a separate thread, know on a separate thread because this test // didn't timeout waiting on the run method to exit