mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestMessageRouterImpl.java
@Test
    public void testHandleMessageNoChannel() throws UnmarshalException, IOException, ObjectConverterException, 
        InvalidKeySignatureException
    {
        // construct a single base namespace message to verify sent to base message service
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.ControllerInfo)
                .build();
        TerraHarvestPayload payload = TerraHarvestPayload.newBuilder().
            setNamespace(Namespace.Base).
            setNamespaceMessage(baseNamespaceMessage.toByteString()).
            build();
        
        TerraHarvestMessage baseMessage = 
                TerraHarvestMessageHelper.createTerraHarvestMessage(0, m_SystemId, Namespace.Base, 100, 
                        baseNamespaceMessage);
        
        //decryption call
        when(m_EcryptService.decryptRemoteMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(payload);
        
        // now register a service that will handle the message
        MessageService baseMessageService = mock(MessageService.class);
        when(baseMessageService.getNamespace()).thenReturn(Namespace.Base);
        m_SUT.bindMessageService(baseMessageService);
        
        // replay
        m_SUT.handleMessage(baseMessage);
        
        ArgumentCaptor<EventChannel> channelCaptor = ArgumentCaptor.forClass(EventChannel.class);
        
        // verify proper message service is sent the same message
        verify(baseMessageService).handleMessage(eq(baseMessage), eq(payload), channelCaptor.capture());
        
        EventChannel channel = channelCaptor.getValue();
        assertThat(channel.getRemoteSystemId(), is(0));
    }
/**
     * Verify that an event channel is used if no channel is specified when handling a message.
     */
Verify that an event channel is used if no channel is specified when handling a message.
Verify that an event channel is used if no channel is specified when handling a message .
@Test
    public void testHandleMessageNoChannel() throws UnmarshalException, IOException, ObjectConverterException, 
        InvalidKeySignatureException
    {
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.ControllerInfo)
                .build();
        TerraHarvestPayload payload = TerraHarvestPayload.newBuilder().
            setNamespace(Namespace.Base).
            setNamespaceMessage(baseNamespaceMessage.toByteString()).
            build();
        TerraHarvestMessage baseMessage = 
                TerraHarvestMessageHelper.createTerraHarvestMessage(0, m_SystemId, Namespace.Base, 100, 
                        baseNamespaceMessage);
        when(m_EcryptService.decryptRemoteMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(payload);
        MessageService baseMessageService = mock(MessageService.class);
        when(baseMessageService.getNamespace()).thenReturn(Namespace.Base);
        m_SUT.bindMessageService(baseMessageService);
        m_SUT.handleMessage(baseMessage);
        ArgumentCaptor<EventChannel> channelCaptor = ArgumentCaptor.forClass(EventChannel.class);
        verify(baseMessageService).handleMessage(eq(baseMessage), eq(payload), channelCaptor.capture());
        EventChannel channel = channelCaptor.getValue();
        assertThat(channel.getRemoteSystemId(), is(0));
    }
@ Test public void testHandleMessageNoChannel ( ) throws UnmarshalException , IOException , ObjectConverterException , InvalidKeySignatureException { BaseNamespace baseNamespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . ControllerInfo ) . build ( ) ; TerraHarvestPayload payload = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . Base ) . setNamespaceMessage ( baseNamespaceMessage . toByteString ( ) ) . build ( ) ; TerraHarvestMessage baseMessage = TerraHarvestMessageHelper . createTerraHarvestMessage ( 0 , m_SystemId , Namespace . Base , 100 , baseNamespaceMessage ) ; when ( m_EcryptService . decryptRemoteMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( payload ) ; MessageService baseMessageService = mock ( MessageService . class ) ; when ( baseMessageService . getNamespace ( ) ) . thenReturn ( Namespace . Base ) ; m_SUT . bindMessageService ( baseMessageService ) ; m_SUT . handleMessage ( baseMessage ) ; ArgumentCaptor < EventChannel > channelCaptor = ArgumentCaptor . forClass ( EventChannel . class ) ; verify ( baseMessageService ) . handleMessage ( eq ( baseMessage ) , eq ( payload ) , channelCaptor . capture ( ) ) ; EventChannel channel = channelCaptor . getValue ( ) ; assertThat ( channel . getRemoteSystemId ( ) , is ( 0 ) ) ; }
Verify that an event channel is used if no channel is specified when handling a message.
Verify that an event channel is used if no channel is specified when handling a message .
// construct a single base namespace message to verify sent to base message service //decryption call // now register a service that will handle the message // replay // verify proper message service is sent the same message