mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestMessageRouterImpl.java
@Test
    public void testHandleMessage_UnarshalException() throws Exception
    {
        // construct a single base namespace message just to satisfy input
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.ControllerInfo)
                .build();
        TerraHarvestMessage baseMessage = 
                TerraHarvestMessageHelper.createTerraHarvestMessage(0, m_SystemId, Namespace.Base, 100, 
                        baseNamespaceMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        when(channel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        
        // register a service that will throw exception when handling message
        MessageService baseMessageService = mock(MessageService.class);
        when(baseMessageService.getNamespace()).thenReturn(Namespace.Base);
        
        UnmarshalException exception = new UnmarshalException("exception-message");
        doThrow(exception).when(baseMessageService).handleMessage(Mockito.any(TerraHarvestMessage.class), 
            Mockito.any(TerraHarvestPayload.class),eq(channel));
        
        m_SUT.bindMessageService(baseMessageService);
        
        //decryption call
        when(m_EcryptService.decryptRemoteMessage(Mockito.any(TerraHarvestMessage.class))).
            thenReturn(TerraHarvestPayload.parseFrom(baseMessage.getTerraHarvestPayload()));
        
        // replay
        m_SUT.handleMessage(baseMessage, channel);
        
        // verify error response is queued from the channel
        verifyBaseErrorResponse(channel, ErrorCode.JAXB_ERROR, 
                "JAXB error when handling [Base] namespace message: exception-message");
    }
/**
     * Verify message handler handles an {@link UnmarshalException}. Verify the channel the message
     * was sent on queues an error response message for the exception.
     */
Verify message handler handles an  UnmarshalException. Verify the channel the message
was sent on queues an error response message for the exception.
Verify message handler handles an UnmarshalException . Verify the channel the message was sent on queues an error response message for the exception .
@Test
    public void testHandleMessage_UnarshalException() throws Exception
    {
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.ControllerInfo)
                .build();
        TerraHarvestMessage baseMessage = 
                TerraHarvestMessageHelper.createTerraHarvestMessage(0, m_SystemId, Namespace.Base, 100, 
                        baseNamespaceMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        when(channel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        MessageService baseMessageService = mock(MessageService.class);
        when(baseMessageService.getNamespace()).thenReturn(Namespace.Base);
        UnmarshalException exception = new UnmarshalException("exception-message");
        doThrow(exception).when(baseMessageService).handleMessage(Mockito.any(TerraHarvestMessage.class), 
            Mockito.any(TerraHarvestPayload.class),eq(channel));
        m_SUT.bindMessageService(baseMessageService);
        when(m_EcryptService.decryptRemoteMessage(Mockito.any(TerraHarvestMessage.class))).
            thenReturn(TerraHarvestPayload.parseFrom(baseMessage.getTerraHarvestPayload()));
        m_SUT.handleMessage(baseMessage, channel);
        verifyBaseErrorResponse(channel, ErrorCode.JAXB_ERROR, 
                "JAXB error when handling [Base] namespace message: exception-message");
    }
@ Test public void testHandleMessage_UnarshalException ( ) throws Exception { BaseNamespace baseNamespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . ControllerInfo ) . build ( ) ; TerraHarvestMessage baseMessage = TerraHarvestMessageHelper . createTerraHarvestMessage ( 0 , m_SystemId , Namespace . Base , 100 , baseNamespaceMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; when ( channel . queueMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( true ) ; MessageService baseMessageService = mock ( MessageService . class ) ; when ( baseMessageService . getNamespace ( ) ) . thenReturn ( Namespace . Base ) ; UnmarshalException exception = new UnmarshalException ( "exception-message" ) ; doThrow ( exception ) . when ( baseMessageService ) . handleMessage ( Mockito . any ( TerraHarvestMessage . class ) , Mockito . any ( TerraHarvestPayload . class ) , eq ( channel ) ) ; m_SUT . bindMessageService ( baseMessageService ) ; when ( m_EcryptService . decryptRemoteMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( TerraHarvestPayload . parseFrom ( baseMessage . getTerraHarvestPayload ( ) ) ) ; m_SUT . handleMessage ( baseMessage , channel ) ; verifyBaseErrorResponse ( channel , ErrorCode . JAXB_ERROR , "JAXB error when handling [Base] namespace message: exception-message" ) ; }
Verify message handler handles an {@link UnmarshalException}.
Verify message handler handles an { @link UnmarshalException } .
// construct a single base namespace message just to satisfy input // mock the channel the message came from // register a service that will throw exception when handling message //decryption call // replay // verify error response is queued from the channel