mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestCustomCommsMessageService.java
@Test
    public final void testGetTransportLayerCapabilities() throws UnmarshalException, ObjectConverterException, 
        IOException
    { 
        CustomCommsNamespace transportLayerMessage = 
                createGetCapsRequestMessage(CommType.TransportLayer, TransportLayer.class.getName());
        TerraHarvestPayload payload = createPayload(transportLayerMessage);
        TerraHarvestMessage message = createCustomCommsMessage(transportLayerMessage);
        
        Message capsGen = TransportLayerCapabilitiesGen.TransportLayerCapabilities.newBuilder().
                setBase(BaseCapabilitiesGen.BaseCapabilities.newBuilder().
                    setManufacturer("Super Cool Transport Layers Inc").
                    setDescription("The best transport layer.").
                    setProductName("CoolTransportLayer")).
                build();
        
        //mock necessary objects/actions
        TransportLayerCapabilities capabilities = mock(TransportLayerCapabilities.class);
        when(m_TransportLayerFactory.getTransportLayerCapabilities()).thenReturn(capabilities);
        when(m_Converter.convertToProto(capabilities)).thenReturn(capsGen);
        
        //mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // reply
        m_SUT.handleMessage(message, payload, channel);
        
        //capture and verify event has been posted locally
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((GetCapabilitiesRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
            is(GetCapabilitiesRequestData.newBuilder().
                    setCommType(CommType.TransportLayer).setProductType(TransportLayer.class.getName()).build()));
        
        //capture and verify response
        ArgumentCaptor<GetCapabilitiesResponseData> messageCaptor = ArgumentCaptor.
                forClass(GetCapabilitiesResponseData.class);
        verify(m_MessageFactory).createCustomCommsResponseMessage(eq(message),
                eq(CustomCommsMessageType.GetCapabilitiesResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetCapabilitiesResponseData response = messageCaptor.getValue();
        
        //ensure all necessary fields are set
        assertThat(response.hasTransportCapabilities(), is(true));
        assertThat(response.getTransportCapabilities(), is(capsGen));
        assertThat(response.getProductType(), is(TransportLayer.class.getName()));
        m_SUT.deactivate();
    }
/**
     * Test the get capabilities request/response message system for transport layers.
     * Specifically, the following behaviors are tested:
     *     Verify incoming request message is posted to the event admin.
     *     Verify capabilities are gotten from the appropriate transport factory.
     *     Verify response (containing correct data) is sent after completing request.
     */
Test the get capabilities request/response message system for transport layers.
Specifically, the following behaviors are tested:
Verify incoming request message is posted to the event admin.
Verify capabilities are gotten from the appropriate transport factory.
Verify response (containing correct data) is sent after completing request.
Test the get capabilities request / response message system for transport layers . Specifically the following behaviors are tested : Verify incoming request message is posted to the event admin . Verify capabilities are gotten from the appropriate transport factory . Verify response ( containing correct data ) is sent after completing request .
@Test
    public final void testGetTransportLayerCapabilities() throws UnmarshalException, ObjectConverterException, 
        IOException
    { 
        CustomCommsNamespace transportLayerMessage = 
                createGetCapsRequestMessage(CommType.TransportLayer, TransportLayer.class.getName());
        TerraHarvestPayload payload = createPayload(transportLayerMessage);
        TerraHarvestMessage message = createCustomCommsMessage(transportLayerMessage);
        Message capsGen = TransportLayerCapabilitiesGen.TransportLayerCapabilities.newBuilder().
                setBase(BaseCapabilitiesGen.BaseCapabilities.newBuilder().
                    setManufacturer("Super Cool Transport Layers Inc").
                    setDescription("The best transport layer.").
                    setProductName("CoolTransportLayer")).
                build();
        TransportLayerCapabilities capabilities = mock(TransportLayerCapabilities.class);
        when(m_TransportLayerFactory.getTransportLayerCapabilities()).thenReturn(capabilities);
        when(m_Converter.convertToProto(capabilities)).thenReturn(capsGen);
        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 event = eventCaptor.getValue();
        assertThat((GetCapabilitiesRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
            is(GetCapabilitiesRequestData.newBuilder().
                    setCommType(CommType.TransportLayer).setProductType(TransportLayer.class.getName()).build()));
        ArgumentCaptor<GetCapabilitiesResponseData> messageCaptor = ArgumentCaptor.
                forClass(GetCapabilitiesResponseData.class);
        verify(m_MessageFactory).createCustomCommsResponseMessage(eq(message),
                eq(CustomCommsMessageType.GetCapabilitiesResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetCapabilitiesResponseData response = messageCaptor.getValue();
        assertThat(response.hasTransportCapabilities(), is(true));
        assertThat(response.getTransportCapabilities(), is(capsGen));
        assertThat(response.getProductType(), is(TransportLayer.class.getName()));
        m_SUT.deactivate();
    }
@ Test public final void testGetTransportLayerCapabilities ( ) throws UnmarshalException , ObjectConverterException , IOException { CustomCommsNamespace transportLayerMessage = createGetCapsRequestMessage ( CommType . TransportLayer , TransportLayer . class . getName ( ) ) ; TerraHarvestPayload payload = createPayload ( transportLayerMessage ) ; TerraHarvestMessage message = createCustomCommsMessage ( transportLayerMessage ) ; Message capsGen = TransportLayerCapabilitiesGen . TransportLayerCapabilities . newBuilder ( ) . setBase ( BaseCapabilitiesGen . BaseCapabilities . newBuilder ( ) . setManufacturer ( "Super Cool Transport Layers Inc" ) . setDescription ( "The best transport layer." ) . setProductName ( "CoolTransportLayer" ) ) . build ( ) ; TransportLayerCapabilities capabilities = mock ( TransportLayerCapabilities . class ) ; when ( m_TransportLayerFactory . getTransportLayerCapabilities ( ) ) . thenReturn ( capabilities ) ; when ( m_Converter . convertToProto ( capabilities ) ) . thenReturn ( capsGen ) ; 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 event = eventCaptor . getValue ( ) ; assertThat ( ( GetCapabilitiesRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( GetCapabilitiesRequestData . newBuilder ( ) . setCommType ( CommType . TransportLayer ) . setProductType ( TransportLayer . class . getName ( ) ) . build ( ) ) ) ; ArgumentCaptor < GetCapabilitiesResponseData > messageCaptor = ArgumentCaptor . forClass ( GetCapabilitiesResponseData . class ) ; verify ( m_MessageFactory ) . createCustomCommsResponseMessage ( eq ( message ) , eq ( CustomCommsMessageType . GetCapabilitiesResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetCapabilitiesResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . hasTransportCapabilities ( ) , is ( true ) ) ; assertThat ( response . getTransportCapabilities ( ) , is ( capsGen ) ) ; assertThat ( response . getProductType ( ) , is ( TransportLayer . class . getName ( ) ) ) ; m_SUT . deactivate ( ) ; }
Test the get capabilities request/response message system for transport layers.
Test the get capabilities request / response message system for transport layers .
//mock necessary objects/actions //mock the channel the message came from // reply //capture and verify event has been posted locally //capture and verify response //ensure all necessary fields are set