mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestCustomCommsMessageService.java
@Test
    public final void testInvalidFactoryError() throws IOException
    {
        //mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // test LinkLayerCapabilities invalid value:
        CustomCommsNamespace commsMessage = 
                createGetCapsRequestMessage(CommType.Linklayer, "bad.link.layer.name");
        TerraHarvestPayload payload = createPayload(commsMessage);
        TerraHarvestMessage message = createCustomCommsMessage(commsMessage);
        
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INVALID_VALUE,
                "Cannot complete request. Link layer factory not found.");
        verify(m_ResponseWrapper).queue(channel);
        
        // test TransportLayerCapabilities invalid value:
        // use LinkLayer.class as the product type this time, error should still be thrown because
        // there are no TransportLayer factories corresponding to LinkLayer.class
        commsMessage = createGetCapsRequestMessage(CommType.TransportLayer, LinkLayer.class.getName());
        payload = createPayload(commsMessage);
        message = createCustomCommsMessage(commsMessage);
        
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INVALID_VALUE,
                "Cannot complete request. Transport layer factory not found.");
        //reused channel
        verify(m_ResponseWrapper, times(2)).queue(channel);
    
        // test PhysicalLinkCapabilities invalid value:
        commsMessage = createGetCapsRequestMessage(CommType.PhysicalLink, "bad.physcial.link.name");
        payload = createPayload(commsMessage);
        message = createCustomCommsMessage(commsMessage);
        
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INVALID_VALUE,
                "Cannot complete request. Physical link factory not found.");
        //reused channel
        verify(m_ResponseWrapper, times(3)).queue(channel);
    }
/**
     * Test that an invalid fqcn value is correctly handled for all comms layer types
     * during the get capabilities operation. This error occurs if the fqcn included in the message
     * does not correspond to a factory of the given type in the custom comms service registry.
     */
Test that an invalid fqcn value is correctly handled for all comms layer types
during the get capabilities operation. This error occurs if the fqcn included in the message
does not correspond to a factory of the given type in the custom comms service registry.
Test that an invalid fqcn value is correctly handled for all comms layer types during the get capabilities operation . This error occurs if the fqcn included in the message does not correspond to a factory of the given type in the custom comms service registry .
@Test
    public final void testInvalidFactoryError() throws IOException
    {
        RemoteChannel channel = mock(RemoteChannel.class);
        CustomCommsNamespace commsMessage = 
                createGetCapsRequestMessage(CommType.Linklayer, "bad.link.layer.name");
        TerraHarvestPayload payload = createPayload(commsMessage);
        TerraHarvestMessage message = createCustomCommsMessage(commsMessage);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INVALID_VALUE,
                "Cannot complete request. Link layer factory not found.");
        verify(m_ResponseWrapper).queue(channel);
        commsMessage = createGetCapsRequestMessage(CommType.TransportLayer, LinkLayer.class.getName());
        payload = createPayload(commsMessage);
        message = createCustomCommsMessage(commsMessage);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INVALID_VALUE,
                "Cannot complete request. Transport layer factory not found.");
        verify(m_ResponseWrapper, times(2)).queue(channel);
        commsMessage = createGetCapsRequestMessage(CommType.PhysicalLink, "bad.physcial.link.name");
        payload = createPayload(commsMessage);
        message = createCustomCommsMessage(commsMessage);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INVALID_VALUE,
                "Cannot complete request. Physical link factory not found.");
        verify(m_ResponseWrapper, times(3)).queue(channel);
    }
@ Test public final void testInvalidFactoryError ( ) throws IOException { RemoteChannel channel = mock ( RemoteChannel . class ) ; CustomCommsNamespace commsMessage = createGetCapsRequestMessage ( CommType . Linklayer , "bad.link.layer.name" ) ; TerraHarvestPayload payload = createPayload ( commsMessage ) ; TerraHarvestMessage message = createCustomCommsMessage ( commsMessage ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( message , ErrorCode . INVALID_VALUE , "Cannot complete request. Link layer factory not found." ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; commsMessage = createGetCapsRequestMessage ( CommType . TransportLayer , LinkLayer . class . getName ( ) ) ; payload = createPayload ( commsMessage ) ; message = createCustomCommsMessage ( commsMessage ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( message , ErrorCode . INVALID_VALUE , "Cannot complete request. Transport layer factory not found." ) ; verify ( m_ResponseWrapper , times ( 2 ) ) . queue ( channel ) ; commsMessage = createGetCapsRequestMessage ( CommType . PhysicalLink , "bad.physcial.link.name" ) ; payload = createPayload ( commsMessage ) ; message = createCustomCommsMessage ( commsMessage ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( message , ErrorCode . INVALID_VALUE , "Cannot complete request. Physical link factory not found." ) ; verify ( m_ResponseWrapper , times ( 3 ) ) . queue ( channel ) ; }
Test that an invalid fqcn value is correctly handled for all comms layer types
 during the get capabilities operation.
Test that an invalid fqcn value is correctly handled for all comms layer types during the get capabilities operation .
//mock the channel the message came from // test LinkLayerCapabilities invalid value: // test TransportLayerCapabilities invalid value: // use LinkLayer.class as the product type this time, error should still be thrown because // there are no TransportLayer factories corresponding to LinkLayer.class //reused channel // test PhysicalLinkCapabilities invalid value: //reused channel