mil.dod.th.ose.logging/test/mil/dod/th/ose/logging/TestEventLogger.java
@Test
    public void testEventHandler()
    {
        BundleContext context = mock(BundleContext.class);
        when(context.getProperty(EventLogger.LOG_EVENTS_ENABLED_PROPERTY)).thenReturn("true");
        
        //replay
        m_SUT.activate(context);
        
        //verify all events are registered for
        EventHandler handler = BundleContextMocker.assertEventHandler(context, "*");
        
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("prop1", 1);
        properties.put("other-prop", "string-value");
        Event event = new Event("test-topic", properties);
        handler.handleEvent(event);
        
        ArgumentCaptor<String> strCap = ArgumentCaptor.forClass(String.class);
        verify(m_Logging).debug(strCap.capture());
        
        assertThat(strCap.getValue(), containsString("Event: topic=[test-topic]"));
        assertThat(strCap.getValue(), containsString("prop1=1"));
        assertThat(strCap.getValue(), containsString("other-prop=string-value"));
        
        // try logging a log event to see what happens, should be ignored
        Event logEvent = new Event(OSGiEventConstants.TOPIC_LOG_ERROR, properties);
        handler.handleEvent(logEvent);
        
        // should be still holding at one
        verify(m_Logging, times(1)).debug(strCap.capture());
    }
/**
     * Test that passed events are logged.
     * 
     * Test that log events aren't logged or else we will never stop logging.
     */
Test that passed events are logged.

Test that log events aren't logged or else we will never stop logging.
Test that passed events are logged . Test that log events aren ' t logged or else we will never stop logging .
@Test
    public void testEventHandler()
    {
        BundleContext context = mock(BundleContext.class);
        when(context.getProperty(EventLogger.LOG_EVENTS_ENABLED_PROPERTY)).thenReturn("true");
        m_SUT.activate(context);
        EventHandler handler = BundleContextMocker.assertEventHandler(context, "*");
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("prop1", 1);
        properties.put("other-prop", "string-value");
        Event event = new Event("test-topic", properties);
        handler.handleEvent(event);
        ArgumentCaptor<String> strCap = ArgumentCaptor.forClass(String.class);
        verify(m_Logging).debug(strCap.capture());
        assertThat(strCap.getValue(), containsString("Event: topic=[test-topic]"));
        assertThat(strCap.getValue(), containsString("prop1=1"));
        assertThat(strCap.getValue(), containsString("other-prop=string-value"));
        Event logEvent = new Event(OSGiEventConstants.TOPIC_LOG_ERROR, properties);
        handler.handleEvent(logEvent);
        verify(m_Logging, times(1)).debug(strCap.capture());
    }
@ Test public void testEventHandler ( ) { BundleContext context = mock ( BundleContext . class ) ; when ( context . getProperty ( EventLogger . LOG_EVENTS_ENABLED_PROPERTY ) ) . thenReturn ( "true" ) ; m_SUT . activate ( context ) ; EventHandler handler = BundleContextMocker . assertEventHandler ( context , "*" ) ; Map < String , Object > properties = new HashMap < String , Object > ( ) ; properties . put ( "prop1" , 1 ) ; properties . put ( "other-prop" , "string-value" ) ; Event event = new Event ( "test-topic" , properties ) ; handler . handleEvent ( event ) ; ArgumentCaptor < String > strCap = ArgumentCaptor . forClass ( String . class ) ; verify ( m_Logging ) . debug ( strCap . capture ( ) ) ; assertThat ( strCap . getValue ( ) , containsString ( "Event: topic=[test-topic]" ) ) ; assertThat ( strCap . getValue ( ) , containsString ( "prop1=1" ) ) ; assertThat ( strCap . getValue ( ) , containsString ( "other-prop=string-value" ) ) ; Event logEvent = new Event ( OSGiEventConstants . TOPIC_LOG_ERROR , properties ) ; handler . handleEvent ( logEvent ) ; verify ( m_Logging , times ( 1 ) ) . debug ( strCap . capture ( ) ) ; }
Test that passed events are logged.
Test that passed events are logged .
//replay //verify all events are registered for // try logging a log event to see what happens, should be ignored // should be still holding at one