mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@SuppressWarnings("unchecked")
    @Test
    public void testLoadTemplatesExceptions() throws IOException, ObjectConverterException
    {
        //activate the mission programming message service
        m_SUT.activate();
        //create a simple mission template to send
        MissionProgramTemplateGen.MissionProgramTemplate template = MissionProgramTemplateGen.MissionProgramTemplate.
            newBuilder().setName("IamATest").setSource("TheSource!@@#(*&$^%_@##$").build();
        //construct a message        
        LoadTemplateRequestData programMessage = MissionProgramMessages.LoadTemplateRequestData.newBuilder().
            setMission(template).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
            setType(MissionProgrammingMessageType.LoadTemplateRequest).setData(programMessage.toByteString()).build();
        TerraHarvestPayload payload = createPayload(missionMessage);
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenThrow(ObjectConverterException.class);

        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, payload, channel);

        // verify loaded program response NEVER sent back 
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.CONVERTER_ERROR, 
                "Failed to create template object from message. " + null);
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test load templates with converter exception.
     * 
     * Verify CONVERTER_ERROR is part of the response message.
     */
Test load templates with converter exception.

Verify CONVERTER_ERROR is part of the response message.
Test load templates with converter exception . Verify CONVERTER_ERROR is part of the response message .
@SuppressWarnings("unchecked")
    @Test
    public void testLoadTemplatesExceptions() throws IOException, ObjectConverterException
    {
        m_SUT.activate();
        MissionProgramTemplateGen.MissionProgramTemplate template = MissionProgramTemplateGen.MissionProgramTemplate.
            newBuilder().setName("IamATest").setSource("TheSource!@@#(*&$^%_@##$").build();
        LoadTemplateRequestData programMessage = MissionProgramMessages.LoadTemplateRequestData.newBuilder().
            setMission(template).build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
            setType(MissionProgrammingMessageType.LoadTemplateRequest).setData(programMessage.toByteString()).build();
        TerraHarvestPayload payload = createPayload(missionMessage);
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenThrow(ObjectConverterException.class);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.CONVERTER_ERROR, 
                "Failed to create template object from message. " + null);
        verify(m_ResponseWrapper).queue(channel);
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testLoadTemplatesExceptions ( ) throws IOException , ObjectConverterException { m_SUT . activate ( ) ; MissionProgramTemplateGen . MissionProgramTemplate template = MissionProgramTemplateGen . MissionProgramTemplate . newBuilder ( ) . setName ( "IamATest" ) . setSource ( "TheSource!@@#(*&$^%_@##$" ) . build ( ) ; LoadTemplateRequestData programMessage = MissionProgramMessages . LoadTemplateRequestData . newBuilder ( ) . setMission ( template ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . LoadTemplateRequest ) . setData ( programMessage . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( missionMessage ) ; TerraHarvestMessage message = createMissionProgrammingMessage ( missionMessage ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenThrow ( ObjectConverterException . class ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( message , ErrorCode . CONVERTER_ERROR , "Failed to create template object from message. " + null ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test load templates with converter exception.
Test load templates with converter exception .
//activate the mission programming message service //create a simple mission template to send //construct a message         // mock the channel the message came from // replay // verify loaded program response NEVER sent back 