mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestMessageRouterImpl.java
@Test
    public void testHandleEncryptionInfoMessage() throws Exception
    {
        EncryptionInfoNamespace namepsaceMessage = EncryptionInfoNamespace.newBuilder().setType(
                EncryptionInfoMessageType.GetEncryptionTypeRequest).build();
        
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.createTerraHarvestMessage(0, m_SystemId, 
                Namespace.EncryptionInfo, 225, namepsaceMessage, EncryptType.NONE);
        
        //payload
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(thMessage.getTerraHarvestPayload());
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        when(channel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        
        //encryption service behavior
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.AES_ECDH_ECDSA);
        when(m_EcryptService.decryptRemoteMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(payload);
        
        MessageService encryptInfoMessageService = mock(MessageService.class);
        when(encryptInfoMessageService.getNamespace()).thenReturn(Namespace.EncryptionInfo);
        m_SUT.bindMessageService(encryptInfoMessageService);
        
        // replay
        m_SUT.handleMessage(thMessage, channel);
        
        // verify proper message service is sent the same message
        verify(encryptInfoMessageService).handleMessage(thMessage, payload, channel);
        
        // verify no error response is queued from the channel
        verify(channel, never()).queueMessage(Mockito.any(TerraHarvestMessage.class));
    }
/**
     * Verify that the Encryption information message is always acknowledged and handled appropriately even when the 
     * system has an encryption level higher than none.
     */
Verify that the Encryption information message is always acknowledged and handled appropriately even when the
system has an encryption level higher than none.
Verify that the Encryption information message is always acknowledged and handled appropriately even when the system has an encryption level higher than none .
@Test
    public void testHandleEncryptionInfoMessage() throws Exception
    {
        EncryptionInfoNamespace namepsaceMessage = EncryptionInfoNamespace.newBuilder().setType(
                EncryptionInfoMessageType.GetEncryptionTypeRequest).build();
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.createTerraHarvestMessage(0, m_SystemId, 
                Namespace.EncryptionInfo, 225, namepsaceMessage, EncryptType.NONE);
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(thMessage.getTerraHarvestPayload());
        RemoteChannel channel = mock(RemoteChannel.class);
        when(channel.queueMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(true);
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.AES_ECDH_ECDSA);
        when(m_EcryptService.decryptRemoteMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(payload);
        MessageService encryptInfoMessageService = mock(MessageService.class);
        when(encryptInfoMessageService.getNamespace()).thenReturn(Namespace.EncryptionInfo);
        m_SUT.bindMessageService(encryptInfoMessageService);
        m_SUT.handleMessage(thMessage, channel);
        verify(encryptInfoMessageService).handleMessage(thMessage, payload, channel);
        verify(channel, never()).queueMessage(Mockito.any(TerraHarvestMessage.class));
    }
@ Test public void testHandleEncryptionInfoMessage ( ) throws Exception { EncryptionInfoNamespace namepsaceMessage = EncryptionInfoNamespace . newBuilder ( ) . setType ( EncryptionInfoMessageType . GetEncryptionTypeRequest ) . build ( ) ; TerraHarvestMessage thMessage = TerraHarvestMessageHelper . createTerraHarvestMessage ( 0 , m_SystemId , Namespace . EncryptionInfo , 225 , namepsaceMessage , EncryptType . NONE ) ; TerraHarvestPayload payload = TerraHarvestPayload . parseFrom ( thMessage . getTerraHarvestPayload ( ) ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; when ( channel . queueMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( true ) ; when ( m_RemoteSettings . getEncryptionMode ( ) ) . thenReturn ( EncryptionMode . AES_ECDH_ECDSA ) ; when ( m_EcryptService . decryptRemoteMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( payload ) ; MessageService encryptInfoMessageService = mock ( MessageService . class ) ; when ( encryptInfoMessageService . getNamespace ( ) ) . thenReturn ( Namespace . EncryptionInfo ) ; m_SUT . bindMessageService ( encryptInfoMessageService ) ; m_SUT . handleMessage ( thMessage , channel ) ; verify ( encryptInfoMessageService ) . handleMessage ( thMessage , payload , channel ) ; verify ( channel , never ( ) ) . queueMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ; }
Verify that the Encryption information message is always acknowledged and handled appropriately even when the
 system has an encryption level higher than none.
Verify that the Encryption information message is always acknowledged and handled appropriately even when the system has an encryption level higher than none .
//payload // mock the channel the message came from //encryption service behavior // replay // verify proper message service is sent the same message // verify no error response is queued from the channel