mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/util/TestMetatypeInformationListener.java
@Test
    public void testHandleBundleEvent() throws InterruptedException, IOException, SAXException, URISyntaxException
    {
        //mock behavior
        when(m_XMLParsingService.getPidAttribute(m_TestURL.toURI())).thenReturn("metatype.bundle.SWEETNESS");

        //handle event
        m_BundleHandler.handleEvent(xmlServiceEvent());
        
        //wait for thread to finish
        Thread.sleep(100);
        
        //verify event posted with expected data
        ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(captor.capture());
        @SuppressWarnings("unchecked")
        List<String> listPids = (List<String>)captor.getValue().getProperty(RemoteMetatypeConstants.EVENT_PROP_PIDS);
        assertThat(listPids, hasItem("metatype.bundle.SWEETNESS"));
        assertThat((Long)captor.getValue().getProperty(RemoteMetatypeConstants.EVENT_PROP_BUNDLE_ID), is(1L));
    }
/**
     * Test a bundle event where the bundle has XML data.
     * Verify event is posted with the pids and bundle ID.
     */
Test a bundle event where the bundle has XML data.
Verify event is posted with the pids and bundle ID.
Test a bundle event where the bundle has XML data . Verify event is posted with the pids and bundle ID .
@Test
    public void testHandleBundleEvent() throws InterruptedException, IOException, SAXException, URISyntaxException
    {
        when(m_XMLParsingService.getPidAttribute(m_TestURL.toURI())).thenReturn("metatype.bundle.SWEETNESS");
        m_BundleHandler.handleEvent(xmlServiceEvent());
        Thread.sleep(100);
        ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(captor.capture());
        @SuppressWarnings("unchecked")
        List<String> listPids = (List<String>)captor.getValue().getProperty(RemoteMetatypeConstants.EVENT_PROP_PIDS);
        assertThat(listPids, hasItem("metatype.bundle.SWEETNESS"));
        assertThat((Long)captor.getValue().getProperty(RemoteMetatypeConstants.EVENT_PROP_BUNDLE_ID), is(1L));
    }
@ Test public void testHandleBundleEvent ( ) throws InterruptedException , IOException , SAXException , URISyntaxException { when ( m_XMLParsingService . getPidAttribute ( m_TestURL . toURI ( ) ) ) . thenReturn ( "metatype.bundle.SWEETNESS" ) ; m_BundleHandler . handleEvent ( xmlServiceEvent ( ) ) ; Thread . sleep ( 100 ) ; ArgumentCaptor < Event > captor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( captor . capture ( ) ) ; @ SuppressWarnings ( "unchecked" ) List < String > listPids = ( List < String > ) captor . getValue ( ) . getProperty ( RemoteMetatypeConstants . EVENT_PROP_PIDS ) ; assertThat ( listPids , hasItem ( "metatype.bundle.SWEETNESS" ) ) ; assertThat ( ( Long ) captor . getValue ( ) . getProperty ( RemoteMetatypeConstants . EVENT_PROP_BUNDLE_ID ) , is ( 1L ) ) ; }
Test a bundle event where the bundle has XML data.
Test a bundle event where the bundle has XML data .
//mock behavior //handle event //wait for thread to finish //verify event posted with expected data