mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/encryption/TestEncryptInfoMessageService.java
@Test
    public void testEncyptionInfoRequest() throws IOException
    {
        MessageResponseWrapper wrapper = mock(MessageResponseWrapper.class);
        
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.AES_ECDH_ECDSA);
        when(m_MessageFactory.createEncryptionInfoResponseMessage(Mockito.any(TerraHarvestMessage.class), 
                eq(EncryptionInfoMessageType.GetEncryptionTypeResponse), 
                Mockito.any(GetEncryptionTypeResponseData.class))).thenReturn(wrapper);
        when(wrapper.queue(m_RemoteChannel)).thenReturn(true);
                
        EncryptionInfoNamespace namepsaceMessage = EncryptionInfoNamespace.newBuilder().setType(
                EncryptionInfoMessageType.GetEncryptionTypeRequest).build();
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.createTerraHarvestMessage(0, 5, 
                Namespace.EncryptionInfo, 225, namepsaceMessage);
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(thMessage.getTerraHarvestPayload());
        
        m_SUT.handleMessage(thMessage, payload, m_RemoteChannel);
        
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        verify(wrapper).queue(m_RemoteChannel);
        verify(m_MessageFactory).createEncryptionInfoResponseMessage(Mockito.any(TerraHarvestMessage.class), 
                eq(EncryptionInfoMessageType.GetEncryptionTypeResponse), messageCaptor.capture());
        
        GetEncryptionTypeResponseData response = (GetEncryptionTypeResponseData)messageCaptor.getValue();
        assertThat(response.getType(), is(EncryptType.AES_ECDH_ECDSA));
        
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        
        Event postedEvent = eventCaptor.getValue();
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(EncryptionInfoMessageType.GetEncryptionTypeRequest.toString()));
        assertThat((TerraHarvestPayload)postedEvent.getProperty(RemoteConstants.EVENT_PROP_PAYLOAD), is(payload));
    }
/**
     * Verify that encryption info request message is handled appropriately.
     */
Verify that encryption info request message is handled appropriately.
Verify that encryption info request message is handled appropriately .
@Test
    public void testEncyptionInfoRequest() throws IOException
    {
        MessageResponseWrapper wrapper = mock(MessageResponseWrapper.class);
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.AES_ECDH_ECDSA);
        when(m_MessageFactory.createEncryptionInfoResponseMessage(Mockito.any(TerraHarvestMessage.class), 
                eq(EncryptionInfoMessageType.GetEncryptionTypeResponse), 
                Mockito.any(GetEncryptionTypeResponseData.class))).thenReturn(wrapper);
        when(wrapper.queue(m_RemoteChannel)).thenReturn(true);
        EncryptionInfoNamespace namepsaceMessage = EncryptionInfoNamespace.newBuilder().setType(
                EncryptionInfoMessageType.GetEncryptionTypeRequest).build();
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.createTerraHarvestMessage(0, 5, 
                Namespace.EncryptionInfo, 225, namepsaceMessage);
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(thMessage.getTerraHarvestPayload());
        m_SUT.handleMessage(thMessage, payload, m_RemoteChannel);
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        verify(wrapper).queue(m_RemoteChannel);
        verify(m_MessageFactory).createEncryptionInfoResponseMessage(Mockito.any(TerraHarvestMessage.class), 
                eq(EncryptionInfoMessageType.GetEncryptionTypeResponse), messageCaptor.capture());
        GetEncryptionTypeResponseData response = (GetEncryptionTypeResponseData)messageCaptor.getValue();
        assertThat(response.getType(), is(EncryptType.AES_ECDH_ECDSA));
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(EncryptionInfoMessageType.GetEncryptionTypeRequest.toString()));
        assertThat((TerraHarvestPayload)postedEvent.getProperty(RemoteConstants.EVENT_PROP_PAYLOAD), is(payload));
    }
@ Test public void testEncyptionInfoRequest ( ) throws IOException { MessageResponseWrapper wrapper = mock ( MessageResponseWrapper . class ) ; when ( m_RemoteSettings . getEncryptionMode ( ) ) . thenReturn ( EncryptionMode . AES_ECDH_ECDSA ) ; when ( m_MessageFactory . createEncryptionInfoResponseMessage ( Mockito . any ( TerraHarvestMessage . class ) , eq ( EncryptionInfoMessageType . GetEncryptionTypeResponse ) , Mockito . any ( GetEncryptionTypeResponseData . class ) ) ) . thenReturn ( wrapper ) ; when ( wrapper . queue ( m_RemoteChannel ) ) . thenReturn ( true ) ; EncryptionInfoNamespace namepsaceMessage = EncryptionInfoNamespace . newBuilder ( ) . setType ( EncryptionInfoMessageType . GetEncryptionTypeRequest ) . build ( ) ; TerraHarvestMessage thMessage = TerraHarvestMessageHelper . createTerraHarvestMessage ( 0 , 5 , Namespace . EncryptionInfo , 225 , namepsaceMessage ) ; TerraHarvestPayload payload = TerraHarvestPayload . parseFrom ( thMessage . getTerraHarvestPayload ( ) ) ; m_SUT . handleMessage ( thMessage , payload , m_RemoteChannel ) ; ArgumentCaptor < Message > messageCaptor = ArgumentCaptor . forClass ( Message . class ) ; verify ( wrapper ) . queue ( m_RemoteChannel ) ; verify ( m_MessageFactory ) . createEncryptionInfoResponseMessage ( Mockito . any ( TerraHarvestMessage . class ) , eq ( EncryptionInfoMessageType . GetEncryptionTypeResponse ) , messageCaptor . capture ( ) ) ; GetEncryptionTypeResponseData response = ( GetEncryptionTypeResponseData ) messageCaptor . getValue ( ) ; assertThat ( response . getType ( ) , is ( EncryptType . AES_ECDH_ECDSA ) ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event postedEvent = eventCaptor . getValue ( ) ; assertThat ( ( String ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( EncryptionInfoMessageType . GetEncryptionTypeRequest . toString ( ) ) ) ; assertThat ( ( TerraHarvestPayload ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_PAYLOAD ) , is ( payload ) ) ; }
Verify that encryption info request message is handled appropriately.
Verify that encryption info request message is handled appropriately .