mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/osgi/TestBundleManagementMessageService.java
@Test
    public void testBundleNamespaceError() throws IOException
    {
        BundleNamespaceErrorData request = BundleNamespaceErrorData.newBuilder().
                setError(BundleErrorCode.OSGiBundleException).
                setErrorDescription("Error").
                build();
        
        TerraHarvestPayload payload = createPayload(request, BundleMessageType.BundleNamespaceError);
        TerraHarvestMessage message = createTerraHarvestMessage(request, BundleMessageType.BundleNamespaceError);
        
        //mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        // handle the message
        m_SUT.handleMessage(message, payload, channel);
        
        //capture the message
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();
        
        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((Integer)postedEvent.getProperty(RemoteConstants.EVENT_PROP_SOURCE_ID), is(0));
        assertThat((Integer)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DEST_ID), is(1));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE), is(Namespace.Bundle.
                toString()));
        
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(BundleMessageType.BundleNamespaceError.toString()));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
        assertThat((BundleNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(getNamespaceMessage(message)));
    }
/**
     * Verify the bundle namespace error message sends and event and that the messages in the event are correct.
     */
Verify the bundle namespace error message sends and event and that the messages in the event are correct.
Verify the bundle namespace error message sends and event and that the messages in the event are correct .
@Test
    public void testBundleNamespaceError() throws IOException
    {
        BundleNamespaceErrorData request = BundleNamespaceErrorData.newBuilder().
                setError(BundleErrorCode.OSGiBundleException).
                setErrorDescription("Error").
                build();
        TerraHarvestPayload payload = createPayload(request, BundleMessageType.BundleNamespaceError);
        TerraHarvestMessage message = createTerraHarvestMessage(request, BundleMessageType.BundleNamespaceError);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();
        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((Integer)postedEvent.getProperty(RemoteConstants.EVENT_PROP_SOURCE_ID), is(0));
        assertThat((Integer)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DEST_ID), is(1));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE), is(Namespace.Bundle.
                toString()));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(BundleMessageType.BundleNamespaceError.toString()));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
        assertThat((BundleNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(getNamespaceMessage(message)));
    }
@ Test public void testBundleNamespaceError ( ) throws IOException { BundleNamespaceErrorData request = BundleNamespaceErrorData . newBuilder ( ) . setError ( BundleErrorCode . OSGiBundleException ) . setErrorDescription ( "Error" ) . build ( ) ; TerraHarvestPayload payload = createPayload ( request , BundleMessageType . BundleNamespaceError ) ; TerraHarvestMessage message = createTerraHarvestMessage ( request , BundleMessageType . BundleNamespaceError ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event postedEvent = eventCaptor . getValue ( ) ; assertThat ( postedEvent . getTopic ( ) , is ( RemoteConstants . TOPIC_MESSAGE_RECEIVED ) ) ; assertThat ( ( TerraHarvestMessage ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE ) , is ( message ) ) ; assertThat ( ( Integer ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_SOURCE_ID ) , is ( 0 ) ) ; assertThat ( ( Integer ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_DEST_ID ) , is ( 1 ) ) ; assertThat ( ( String ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE ) , is ( Namespace . Bundle . toString ( ) ) ) ; assertThat ( ( String ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( BundleMessageType . BundleNamespaceError . toString ( ) ) ) ; assertThat ( ( RemoteChannel ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_CHANNEL ) , is ( channel ) ) ; assertThat ( ( BundleNamespace ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( getNamespaceMessage ( message ) ) ) ; }
Verify the bundle namespace error message sends and event and that the messages in the event are correct.
Verify the bundle namespace error message sends and event and that the messages in the event are correct .
//mock the channel the message came from // handle the message //capture the message