mil.dod.th.ose.datastream/test/mil/dod/th/ose/datastream/TestStreamProfileConfigListener.java
@SuppressWarnings("unchecked")
    @Test
    public void testConfigurationListener()
    {
        m_SUT.registerConfigListener("some.factory");
        
        ArgumentCaptor<EventHandler> handlerCaptor = ArgumentCaptor.forClass(EventHandler.class);
        
        verify(m_Context).registerService(eq(EventHandler.class), handlerCaptor.capture(), 
                Mockito.any(Dictionary.class));
        
        ConfigurationListener configListener = (ConfigurationListener)handlerCaptor.getValue();
        
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("propA", 100);
        props.put("propB", "test this");
        props.put("propC", 1337);
        Event configUpdatedEvent = new Event(ConfigurationEventConstants.TOPIC_CONFIGURATION_UPDATED_EVENT, props);
        
        configListener.handleEvent(configUpdatedEvent);
        
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        
        Event event = eventCaptor.getValue();
        assertThat(event.getTopic(), is(StreamProfileConfigListener.TOPIC_STREAM_PROFILE_CONFIG_UPDATED));
        assertThat(event.containsProperty("propA"), is(true));
        assertThat(event.containsProperty("propB"), is(true));
        assertThat(event.containsProperty("propC"), is(true));
        assertThat(event.getProperty("propA"), is(100));
        assertThat(event.getProperty("propB"), is("test this"));
        assertThat(event.getProperty("propC"), is(1337));
    }
/**
     * Verify that the configuration listener reposts the event appropriately.
     */
Verify that the configuration listener reposts the event appropriately.
Verify that the configuration listener reposts the event appropriately .
@SuppressWarnings("unchecked")
    @Test
    public void testConfigurationListener()
    {
        m_SUT.registerConfigListener("some.factory");
        ArgumentCaptor<EventHandler> handlerCaptor = ArgumentCaptor.forClass(EventHandler.class);
        verify(m_Context).registerService(eq(EventHandler.class), handlerCaptor.capture(), 
                Mockito.any(Dictionary.class));
        ConfigurationListener configListener = (ConfigurationListener)handlerCaptor.getValue();
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("propA", 100);
        props.put("propB", "test this");
        props.put("propC", 1337);
        Event configUpdatedEvent = new Event(ConfigurationEventConstants.TOPIC_CONFIGURATION_UPDATED_EVENT, props);
        configListener.handleEvent(configUpdatedEvent);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat(event.getTopic(), is(StreamProfileConfigListener.TOPIC_STREAM_PROFILE_CONFIG_UPDATED));
        assertThat(event.containsProperty("propA"), is(true));
        assertThat(event.containsProperty("propB"), is(true));
        assertThat(event.containsProperty("propC"), is(true));
        assertThat(event.getProperty("propA"), is(100));
        assertThat(event.getProperty("propB"), is("test this"));
        assertThat(event.getProperty("propC"), is(1337));
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testConfigurationListener ( ) { m_SUT . registerConfigListener ( "some.factory" ) ; ArgumentCaptor < EventHandler > handlerCaptor = ArgumentCaptor . forClass ( EventHandler . class ) ; verify ( m_Context ) . registerService ( eq ( EventHandler . class ) , handlerCaptor . capture ( ) , Mockito . any ( Dictionary . class ) ) ; ConfigurationListener configListener = ( ConfigurationListener ) handlerCaptor . getValue ( ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( "propA" , 100 ) ; props . put ( "propB" , "test this" ) ; props . put ( "propC" , 1337 ) ; Event configUpdatedEvent = new Event ( ConfigurationEventConstants . TOPIC_CONFIGURATION_UPDATED_EVENT , props ) ; configListener . handleEvent ( configUpdatedEvent ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( event . getTopic ( ) , is ( StreamProfileConfigListener . TOPIC_STREAM_PROFILE_CONFIG_UPDATED ) ) ; assertThat ( event . containsProperty ( "propA" ) , is ( true ) ) ; assertThat ( event . containsProperty ( "propB" ) , is ( true ) ) ; assertThat ( event . containsProperty ( "propC" ) , is ( true ) ) ; assertThat ( event . getProperty ( "propA" ) , is ( 100 ) ) ; assertThat ( event . getProperty ( "propB" ) , is ( "test this" ) ) ; assertThat ( event . getProperty ( "propC" ) , is ( 1337 ) ) ; }
Verify that the configuration listener reposts the event appropriately.
Verify that the configuration listener reposts the event appropriately .