mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestTerraHarvestMessageUtil.java
@Test
    public final void testBuildEncryptionErrorResponseMessage() throws InvalidProtocolBufferException
    {    
        // build a base namespace message
        final BaseNamespace namespaceMessage = BaseNamespace.newBuilder().
                setType(BaseMessageType.RequestControllerInfo).
                build();
        //build a TerraHarvestPayLoad message
        final TerraHarvestPayload payLoad = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(namespaceMessage.toByteString()).
                build();
       
        TerraHarvestMessage requestMessage = TerraHarvestMessageUtil.getPartialMessage().
                setSourceId(0).
                setDestId(1).
                setMessageId(100).             
                setTerraHarvestPayload(payLoad.toByteString()).
                build();
        
        TerraHarvestMessage testMessage = TerraHarvestMessageUtil.buildEncryptionErrorResponseMessage(requestMessage, 
                EncryptionErrorCode.INVALID_ENCRYPTION_LEVEL, "errorrrrrr", EncryptionMode.AES_ECDH_ECDSA);

        TerraHarvestPayload payLoadTest = TerraHarvestPayload.parseFrom(testMessage.getTerraHarvestPayload());
        EncryptionInfoNamespace encryptionTest = EncryptionInfoNamespace.parseFrom(payLoadTest.getNamespaceMessage()); 
        EncryptionInfoErrorResponseData encryptionErrorResponseTest = 
                EncryptionInfoErrorResponseData.parseFrom(encryptionTest.getData());
        
        assertThat(testMessage.getVersion(), is(RemoteConstants.SPEC_VERSION));
        assertThat(encryptionErrorResponseTest.getError(), is(EncryptionErrorCode.INVALID_ENCRYPTION_LEVEL));
        assertThat(encryptionErrorResponseTest.getErrorDescription(), is("errorrrrrr"));
        assertThat(encryptionErrorResponseTest.getType(), is(EncryptType.AES_ECDH_ECDSA));
        assertThat(testMessage.getSourceId(), is(requestMessage.getDestId()));
        assertThat(testMessage.getDestId(), is(requestMessage.getSourceId()));
        assertThat(testMessage.getMessageId(), is(requestMessage.getMessageId()));
        assertThat(payLoadTest.getNamespace(), is(Namespace.EncryptionInfo));
        assertThat(payLoadTest.getNamespaceMessage(), is(encryptionTest.toByteString()));
    }
/**
     * Verify that a error response message can be built, and has the correct values from the util class.
     * 
     */
Verify that a error response message can be built, and has the correct values from the util class.
Verify that a error response message can be built and has the correct values from the util class .
@Test
    public final void testBuildEncryptionErrorResponseMessage() throws InvalidProtocolBufferException
    {    
        final BaseNamespace namespaceMessage = BaseNamespace.newBuilder().
                setType(BaseMessageType.RequestControllerInfo).
                build();
        final TerraHarvestPayload payLoad = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(namespaceMessage.toByteString()).
                build();
        TerraHarvestMessage requestMessage = TerraHarvestMessageUtil.getPartialMessage().
                setSourceId(0).
                setDestId(1).
                setMessageId(100).             
                setTerraHarvestPayload(payLoad.toByteString()).
                build();
        TerraHarvestMessage testMessage = TerraHarvestMessageUtil.buildEncryptionErrorResponseMessage(requestMessage, 
                EncryptionErrorCode.INVALID_ENCRYPTION_LEVEL, "errorrrrrr", EncryptionMode.AES_ECDH_ECDSA);
        TerraHarvestPayload payLoadTest = TerraHarvestPayload.parseFrom(testMessage.getTerraHarvestPayload());
        EncryptionInfoNamespace encryptionTest = EncryptionInfoNamespace.parseFrom(payLoadTest.getNamespaceMessage()); 
        EncryptionInfoErrorResponseData encryptionErrorResponseTest = 
                EncryptionInfoErrorResponseData.parseFrom(encryptionTest.getData());
        assertThat(testMessage.getVersion(), is(RemoteConstants.SPEC_VERSION));
        assertThat(encryptionErrorResponseTest.getError(), is(EncryptionErrorCode.INVALID_ENCRYPTION_LEVEL));
        assertThat(encryptionErrorResponseTest.getErrorDescription(), is("errorrrrrr"));
        assertThat(encryptionErrorResponseTest.getType(), is(EncryptType.AES_ECDH_ECDSA));
        assertThat(testMessage.getSourceId(), is(requestMessage.getDestId()));
        assertThat(testMessage.getDestId(), is(requestMessage.getSourceId()));
        assertThat(testMessage.getMessageId(), is(requestMessage.getMessageId()));
        assertThat(payLoadTest.getNamespace(), is(Namespace.EncryptionInfo));
        assertThat(payLoadTest.getNamespaceMessage(), is(encryptionTest.toByteString()));
    }
@ Test public final void testBuildEncryptionErrorResponseMessage ( ) throws InvalidProtocolBufferException { final BaseNamespace namespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . RequestControllerInfo ) . build ( ) ; final TerraHarvestPayload payLoad = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . Base ) . setNamespaceMessage ( namespaceMessage . toByteString ( ) ) . build ( ) ; TerraHarvestMessage requestMessage = TerraHarvestMessageUtil . getPartialMessage ( ) . setSourceId ( 0 ) . setDestId ( 1 ) . setMessageId ( 100 ) . setTerraHarvestPayload ( payLoad . toByteString ( ) ) . build ( ) ; TerraHarvestMessage testMessage = TerraHarvestMessageUtil . buildEncryptionErrorResponseMessage ( requestMessage , EncryptionErrorCode . INVALID_ENCRYPTION_LEVEL , "errorrrrrr" , EncryptionMode . AES_ECDH_ECDSA ) ; TerraHarvestPayload payLoadTest = TerraHarvestPayload . parseFrom ( testMessage . getTerraHarvestPayload ( ) ) ; EncryptionInfoNamespace encryptionTest = EncryptionInfoNamespace . parseFrom ( payLoadTest . getNamespaceMessage ( ) ) ; EncryptionInfoErrorResponseData encryptionErrorResponseTest = EncryptionInfoErrorResponseData . parseFrom ( encryptionTest . getData ( ) ) ; assertThat ( testMessage . getVersion ( ) , is ( RemoteConstants . SPEC_VERSION ) ) ; assertThat ( encryptionErrorResponseTest . getError ( ) , is ( EncryptionErrorCode . INVALID_ENCRYPTION_LEVEL ) ) ; assertThat ( encryptionErrorResponseTest . getErrorDescription ( ) , is ( "errorrrrrr" ) ) ; assertThat ( encryptionErrorResponseTest . getType ( ) , is ( EncryptType . AES_ECDH_ECDSA ) ) ; assertThat ( testMessage . getSourceId ( ) , is ( requestMessage . getDestId ( ) ) ) ; assertThat ( testMessage . getDestId ( ) , is ( requestMessage . getSourceId ( ) ) ) ; assertThat ( testMessage . getMessageId ( ) , is ( requestMessage . getMessageId ( ) ) ) ; assertThat ( payLoadTest . getNamespace ( ) , is ( Namespace . EncryptionInfo ) ) ; assertThat ( payLoadTest . getNamespaceMessage ( ) , is ( encryptionTest . toByteString ( ) ) ) ; }
Verify that a error response message can be built, and has the correct values from the util class.
Verify that a error response message can be built and has the correct values from the util class .
// build a base namespace message //build a TerraHarvestPayLoad message