mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestLinkLayerMessageService.java
@Test
    public void testPerformBITRequestCComException() throws CCommException, IOException
    {
        // create request
        PerformBITRequestData request = PerformBITRequestData.newBuilder()
                .setLinkUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        
        LinkLayerNamespace llMessage = LinkLayerNamespace.newBuilder()
                .setType(LinkLayerMessageType.PerformBITRequest)
                .setData(request.toByteString())
                .build();
        
        TerraHarvestPayload payload = createPayload(llMessage);
        TerraHarvestMessage message = createLinkLayerMessage(llMessage);

        //mock exception from the layer
        when(testLayer.performBit()).thenThrow(new CCommException(FormatProblem.OTHER));
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        m_SUT.handleMessage(message, payload, channel);
        
        // make sure perform BIT was called on the test link layer
        verify(testLayer).performBit();

        verify(m_MessageFactory).createBaseErrorMessage(eq(message), eq(ErrorCode.CCOMM_ERROR), 
            anyString());
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test requesting a link layer to perform its BIT, and the layer does not support BIT.
     * Verify that a response message is sent.
     */
Test requesting a link layer to perform its BIT, and the layer does not support BIT.
Verify that a response message is sent.
Test requesting a link layer to perform its BIT and the layer does not support BIT . Verify that a response message is sent .
@Test
    public void testPerformBITRequestCComException() throws CCommException, IOException
    {
        PerformBITRequestData request = PerformBITRequestData.newBuilder()
                .setLinkUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        LinkLayerNamespace llMessage = LinkLayerNamespace.newBuilder()
                .setType(LinkLayerMessageType.PerformBITRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestPayload payload = createPayload(llMessage);
        TerraHarvestMessage message = createLinkLayerMessage(llMessage);
        when(testLayer.performBit()).thenThrow(new CCommException(FormatProblem.OTHER));
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        verify(testLayer).performBit();
        verify(m_MessageFactory).createBaseErrorMessage(eq(message), eq(ErrorCode.CCOMM_ERROR), 
            anyString());
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testPerformBITRequestCComException ( ) throws CCommException , IOException { PerformBITRequestData request = PerformBITRequestData . newBuilder ( ) . setLinkUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; LinkLayerNamespace llMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . PerformBITRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( llMessage ) ; TerraHarvestMessage message = createLinkLayerMessage ( llMessage ) ; when ( testLayer . performBit ( ) ) . thenThrow ( new CCommException ( FormatProblem . OTHER ) ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( testLayer ) . performBit ( ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( eq ( message ) , eq ( ErrorCode . CCOMM_ERROR ) , anyString ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test requesting a link layer to perform its BIT, and the layer does not support BIT.
Test requesting a link layer to perform its BIT and the layer does not support BIT .
// create request //mock exception from the layer // mock the channel the message came from // make sure perform BIT was called on the test link layer