mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/osgi/TestBundleManagementMessageService.java
@Test
    public void testUpdateBundle() throws IOException, BundleException
    {
        //mock
        Bundle updateBundle = mock(Bundle.class);
        when(updateBundle.getBundleId()).thenReturn(6L);
        when(m_Context.getBundle(6L)).thenReturn(updateBundle);
        
        //request
        UpdateRequestData request = UpdateRequestData.newBuilder().
            setBundleFile(ByteString.copyFrom(new byte[] { 0, 1, 3, 5, 9, (byte)0xff, 0x3f, 0x56, (byte)0xdd, 18})).
            setBundleId(6L).build();
        
        TerraHarvestPayload payload = createPayload(request, BundleMessageType.UpdateRequest);
        TerraHarvestMessage message = createTerraHarvestMessage(request, BundleMessageType.UpdateRequest);

        //mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        // handle the message
        m_SUT.handleMessage(message, payload, channel);
        
        //verify
        verify(m_MessageFactory).createBundleResponseMessage(message, BundleMessageType.UpdateResponse, 
            null);
        verify(m_ResponseWrapper).queue(channel);
        ArgumentCaptor<InputStream> stream = ArgumentCaptor.forClass(InputStream.class);
        verify(updateBundle).update(stream.capture());
        
        byte[] actualBytes = new byte[10];
        stream.getValue().read(actualBytes);
        assertThat(actualBytes, is(new byte[] { 0, 1, 3, 5, 9, (byte)0xff, 0x3f, 0x56, (byte)0xdd, 18}));
    }
/**
     * Test update bundle request.
     * 
     * Verify correct response is sent.
     */
Test update bundle request.

Verify correct response is sent.
Test update bundle request . Verify correct response is sent .
@Test
    public void testUpdateBundle() throws IOException, BundleException
    {
        Bundle updateBundle = mock(Bundle.class);
        when(updateBundle.getBundleId()).thenReturn(6L);
        when(m_Context.getBundle(6L)).thenReturn(updateBundle);
        UpdateRequestData request = UpdateRequestData.newBuilder().
            setBundleFile(ByteString.copyFrom(new byte[] { 0, 1, 3, 5, 9, (byte)0xff, 0x3f, 0x56, (byte)0xdd, 18})).
            setBundleId(6L).build();
        TerraHarvestPayload payload = createPayload(request, BundleMessageType.UpdateRequest);
        TerraHarvestMessage message = createTerraHarvestMessage(request, BundleMessageType.UpdateRequest);
         the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBundleResponseMessage(message, BundleMessageType.UpdateResponse, 
            null);
        verify(m_ResponseWrapper).queue(channel);
        ArgumentCaptor<InputStream> stream = ArgumentCaptor.forClass(InputStream.class);
        verify(updateBundle).update(stream.capture());
        byte[] actualBytes = new byte[10];
        stream.getValue().read(actualBytes);
        assertThat(actualBytes, is(new byte[] { 0, 1, 3, 5, 9, (byte)0xff, 0x3f, 0x56, (byte)0xdd, 18}));
    }
@ Test public void testUpdateBundle ( ) throws IOException , BundleException { Bundle updateBundle = mock ( Bundle . class ) ; when ( updateBundle . getBundleId ( ) ) . thenReturn ( 6L ) ; when ( m_Context . getBundle ( 6L ) ) . thenReturn ( updateBundle ) ; UpdateRequestData request = UpdateRequestData . newBuilder ( ) . setBundleFile ( ByteString . copyFrom ( new byte [ ] { 0 , 1 , 3 , 5 , 9 , ( byte ) 0xff , 0x3f , 0x56 , ( byte ) 0xdd , 18 } ) ) . setBundleId ( 6L ) . build ( ) ; TerraHarvestPayload payload = createPayload ( request , BundleMessageType . UpdateRequest ) ; TerraHarvestMessage message = createTerraHarvestMessage ( request , BundleMessageType . UpdateRequest ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory ) . createBundleResponseMessage ( message , BundleMessageType . UpdateResponse , null ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; ArgumentCaptor < InputStream > stream = ArgumentCaptor . forClass ( InputStream . class ) ; verify ( updateBundle ) . update ( stream . capture ( ) ) ; byte [ ] actualBytes = new byte [ 10 ] ; stream . getValue ( ) . read ( actualBytes ) ; assertThat ( actualBytes , is ( new byte [ ] { 0 , 1 , 3 , 5 , 9 , ( byte ) 0xff , 0x3f , 0x56 , ( byte ) 0xdd , 18 } ) ) ; }
Test update bundle request.
Test update bundle request .
//mock //request //mock the channel the message came from // handle the message //verify