mil.dod.th.ose.datastream/test/mil/dod/th/ose/datastream/TestDataStreamServiceImpl.java
@SuppressWarnings("unchecked")
    @Test
    public void testPidRemovedListener() throws InvalidSyntaxException
    {
        String host = "225.1.2.3";
        int port = 5004;
        StreamProfileInternal spi = mock(StreamProfileInternal.class);
        
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(DataStreamServiceConfig.CONFIG_PROP_MULTICAST_HOST, host);
        props.put(DataStreamServiceConfig.CONFIG_PROP_START_PORT, port);
        
        m_SUT.activate(Collections.unmodifiableMap(props), m_BundleContext);
        
        ArgumentCaptor<EventHandler> handlerCaptor = ArgumentCaptor.forClass(EventHandler.class);
        verify(m_BundleContext, times(2)).registerService(eq(EventHandler.class), handlerCaptor.capture(), 
                Mockito.any(Dictionary.class));
        
        PidRemovedListener listener = (PidRemovedListener)handlerCaptor.getValue();
        
        Map<String, Object> topicProps = new HashMap<>();
        topicProps.put(FactoryDescriptor.EVENT_PROP_OBJ, spi);
        Event pidRemovedEvent = new Event(FactoryDescriptor.TOPIC_FACTORY_OBJ_PID_REMOVED, topicProps);
        
        listener.handleEvent(pidRemovedEvent);
        
        verify(spi).delete();
    }
/**
     * Verify that the listener removes the stream profile factory object that just had its PID removed.
     */
Verify that the listener removes the stream profile factory object that just had its PID removed.
Verify that the listener removes the stream profile factory object that just had its PID removed .
@SuppressWarnings("unchecked")
    @Test
    public void testPidRemovedListener() throws InvalidSyntaxException
    {
        String host = "225.1.2.3";
        int port = 5004;
        StreamProfileInternal spi = mock(StreamProfileInternal.class);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(DataStreamServiceConfig.CONFIG_PROP_MULTICAST_HOST, host);
        props.put(DataStreamServiceConfig.CONFIG_PROP_START_PORT, port);
        m_SUT.activate(Collections.unmodifiableMap(props), m_BundleContext);
        ArgumentCaptor<EventHandler> handlerCaptor = ArgumentCaptor.forClass(EventHandler.class);
        verify(m_BundleContext, times(2)).registerService(eq(EventHandler.class), handlerCaptor.capture(), 
                Mockito.any(Dictionary.class));
        PidRemovedListener listener = (PidRemovedListener)handlerCaptor.getValue();
        Map<String, Object> topicProps = new HashMap<>();
        topicProps.put(FactoryDescriptor.EVENT_PROP_OBJ, spi);
        Event pidRemovedEvent = new Event(FactoryDescriptor.TOPIC_FACTORY_OBJ_PID_REMOVED, topicProps);
        listener.handleEvent(pidRemovedEvent);
        verify(spi).delete();
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testPidRemovedListener ( ) throws InvalidSyntaxException { String host = "225.1.2.3" ; int port = 5004 ; StreamProfileInternal spi = mock ( StreamProfileInternal . class ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( DataStreamServiceConfig . CONFIG_PROP_MULTICAST_HOST , host ) ; props . put ( DataStreamServiceConfig . CONFIG_PROP_START_PORT , port ) ; m_SUT . activate ( Collections . unmodifiableMap ( props ) , m_BundleContext ) ; ArgumentCaptor < EventHandler > handlerCaptor = ArgumentCaptor . forClass ( EventHandler . class ) ; verify ( m_BundleContext , times ( 2 ) ) . registerService ( eq ( EventHandler . class ) , handlerCaptor . capture ( ) , Mockito . any ( Dictionary . class ) ) ; PidRemovedListener listener = ( PidRemovedListener ) handlerCaptor . getValue ( ) ; Map < String , Object > topicProps = new HashMap < > ( ) ; topicProps . put ( FactoryDescriptor . EVENT_PROP_OBJ , spi ) ; Event pidRemovedEvent = new Event ( FactoryDescriptor . TOPIC_FACTORY_OBJ_PID_REMOVED , topicProps ) ; listener . handleEvent ( pidRemovedEvent ) ; verify ( spi ) . delete ( ) ; }
Verify that the listener removes the stream profile factory object that just had its PID removed.
Verify that the listener removes the stream profile factory object that just had its PID removed .