mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/remoteconfiguration/TestRemoteChannelLookupService.java
@Test
    public void testSyncTransportChannelResponseMessage() throws IOException
    {
        // construct a single message containing data within a namespace message
        SyncTransportChannelResponseData transportRequestData = SyncTransportChannelResponseData.newBuilder()
                .setRemoteSystemAddress("system")
                .setTransportLayerName("transport")
                .setRemoteSystemId(7)
                .setSourceSystemAddress("local")
                .build();
        
        RemoteChannelLookupNamespace remoteNamespaceMessage = RemoteChannelLookupNamespace.newBuilder()
                .setType(RemoteChannelLookupMessageType.SyncTransportChannelResponse)
                .setData(transportRequestData.toByteString()).build();

        TerraHarvestMessage message = createRemoteChannelMessage(remoteNamespaceMessage);
        TerraHarvestPayload payload = createPayload(remoteNamespaceMessage);
                
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, payload, channel);

        // verify event is posted
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();
        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(remoteNamespaceMessage.getType().toString()));
        assertThat((RemoteChannelLookupNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(remoteNamespaceMessage));
        assertThat((SyncTransportChannelResponseData)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(transportRequestData));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
    }
/**
     * Verify handling of the response to syncing a transport layer channel.
     */
Verify handling of the response to syncing a transport layer channel.
Verify handling of the response to syncing a transport layer channel .
@Test
    public void testSyncTransportChannelResponseMessage() throws IOException
    {
        SyncTransportChannelResponseData transportRequestData = SyncTransportChannelResponseData.newBuilder()
                .setRemoteSystemAddress("system")
                .setTransportLayerName("transport")
                .setRemoteSystemId(7)
                .setSourceSystemAddress("local")
                .build();
        RemoteChannelLookupNamespace remoteNamespaceMessage = RemoteChannelLookupNamespace.newBuilder()
                .setType(RemoteChannelLookupMessageType.SyncTransportChannelResponse)
                .setData(transportRequestData.toByteString()).build();
        TerraHarvestMessage message = createRemoteChannelMessage(remoteNamespaceMessage);
        TerraHarvestPayload payload = createPayload(remoteNamespaceMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();
        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(remoteNamespaceMessage.getType().toString()));
        assertThat((RemoteChannelLookupNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(remoteNamespaceMessage));
        assertThat((SyncTransportChannelResponseData)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(transportRequestData));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
    }
@ Test public void testSyncTransportChannelResponseMessage ( ) throws IOException { SyncTransportChannelResponseData transportRequestData = SyncTransportChannelResponseData . newBuilder ( ) . setRemoteSystemAddress ( "system" ) . setTransportLayerName ( "transport" ) . setRemoteSystemId ( 7 ) . setSourceSystemAddress ( "local" ) . build ( ) ; RemoteChannelLookupNamespace remoteNamespaceMessage = RemoteChannelLookupNamespace . newBuilder ( ) . setType ( RemoteChannelLookupMessageType . SyncTransportChannelResponse ) . setData ( transportRequestData . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createRemoteChannelMessage ( remoteNamespaceMessage ) ; TerraHarvestPayload payload = createPayload ( remoteNamespaceMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event postedEvent = eventCaptor . getValue ( ) ; assertThat ( postedEvent . getTopic ( ) , is ( RemoteConstants . TOPIC_MESSAGE_RECEIVED ) ) ; assertThat ( ( TerraHarvestMessage ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE ) , is ( message ) ) ; assertThat ( ( String ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( remoteNamespaceMessage . getType ( ) . toString ( ) ) ) ; assertThat ( ( RemoteChannelLookupNamespace ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( remoteNamespaceMessage ) ) ; assertThat ( ( SyncTransportChannelResponseData ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( transportRequestData ) ) ; assertThat ( ( RemoteChannel ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_CHANNEL ) , is ( channel ) ) ; }
Verify handling of the response to syncing a transport layer channel.
Verify handling of the response to syncing a transport layer channel .
// construct a single message containing data within a namespace message // mock the channel the message came from // replay // verify event is posted