mil.dod.th.ose.logging/test/mil/dod/th/ose/logging/TestLogWriter.java
@Test
    public void testNullPropertiesNoConfigAdmin()
    {
        BundleContext context = mock(BundleContext.class);
        Map<String, Object> props = new HashMap<String, Object>(getComponentProperties());
        when(context.getProperty(LogWriter.LOG_DIR_PROPERTY)).thenReturn("TempLogDir");
        when(context.getProperty(LogWriter.LOG_DAYS_ALIVE_PROPERTY)).thenReturn(null);
        when(context.getProperty(LogWriter.LOG_FILE_BUFFER_SIZE_PROPERTY)).thenReturn(null);
        when(context.getProperty(LogWriter.LOG_LEVEL_PROPERTY)).thenReturn(null);
        when(context.getProperty(LogWriter.LOG_SIZE_PROPERTY)).thenReturn(null);
        // Setting key value pair
        m_SUT.activate(context, props);
        setUpFileNaming();

        long prelength = m_LogFile.length();

        LogEntry logEntry = mock(LogEntry.class);
        when(logEntry.getBundle()).thenReturn(m_Bundle);
        // ask to log at a level that is acceptable
        when(logEntry.getLevel()).thenReturn(LogService.LOG_DEBUG);
        when(logEntry.getTime()).thenReturn(1L);
        when(logEntry.getMessage()).thenReturn("AROOOGA!");
        m_SUT.logged(logEntry);

        //verify that the log entry was successful, this proves that even if the config admin is unavailable and there
        //are no properties known to the framework that the log service will still function.
        assertThat(m_LogFile.length(), greaterThan(prelength));
    }
/**
     * Test that if no values are set in the property file that local defaults are used.
     * Verify logging still works.
     */
Test that if no values are set in the property file that local defaults are used.
Verify logging still works.
Test that if no values are set in the property file that local defaults are used . Verify logging still works .
@Test
    public void testNullPropertiesNoConfigAdmin()
    {
        BundleContext context = mock(BundleContext.class);
        Map<String, Object> props = new HashMap<String, Object>(getComponentProperties());
        when(context.getProperty(LogWriter.LOG_DIR_PROPERTY)).thenReturn("TempLogDir");
        when(context.getProperty(LogWriter.LOG_DAYS_ALIVE_PROPERTY)).thenReturn(null);
        when(context.getProperty(LogWriter.LOG_FILE_BUFFER_SIZE_PROPERTY)).thenReturn(null);
        when(context.getProperty(LogWriter.LOG_LEVEL_PROPERTY)).thenReturn(null);
        when(context.getProperty(LogWriter.LOG_SIZE_PROPERTY)).thenReturn(null);
        m_SUT.activate(context, props);
        setUpFileNaming();
        long prelength = m_LogFile.length();
        LogEntry logEntry = mock(LogEntry.class);
        when(logEntry.getBundle()).thenReturn(m_Bundle);
        when(logEntry.getLevel()).thenReturn(LogService.LOG_DEBUG);
        when(logEntry.getTime()).thenReturn(1L);
        when(logEntry.getMessage()).thenReturn("AROOOGA!");
        m_SUT.logged(logEntry);
        assertThat(m_LogFile.length(), greaterThan(prelength));
    }
@ Test public void testNullPropertiesNoConfigAdmin ( ) { BundleContext context = mock ( BundleContext . class ) ; Map < String , Object > props = new HashMap < String , Object > ( getComponentProperties ( ) ) ; when ( context . getProperty ( LogWriter . LOG_DIR_PROPERTY ) ) . thenReturn ( "TempLogDir" ) ; when ( context . getProperty ( LogWriter . LOG_DAYS_ALIVE_PROPERTY ) ) . thenReturn ( null ) ; when ( context . getProperty ( LogWriter . LOG_FILE_BUFFER_SIZE_PROPERTY ) ) . thenReturn ( null ) ; when ( context . getProperty ( LogWriter . LOG_LEVEL_PROPERTY ) ) . thenReturn ( null ) ; when ( context . getProperty ( LogWriter . LOG_SIZE_PROPERTY ) ) . thenReturn ( null ) ; m_SUT . activate ( context , props ) ; setUpFileNaming ( ) ; long prelength = m_LogFile . length ( ) ; LogEntry logEntry = mock ( LogEntry . class ) ; when ( logEntry . getBundle ( ) ) . thenReturn ( m_Bundle ) ; when ( logEntry . getLevel ( ) ) . thenReturn ( LogService . LOG_DEBUG ) ; when ( logEntry . getTime ( ) ) . thenReturn ( 1L ) ; when ( logEntry . getMessage ( ) ) . thenReturn ( "AROOOGA!" ) ; m_SUT . logged ( logEntry ) ; assertThat ( m_LogFile . length ( ) , greaterThan ( prelength ) ) ; }
Test that if no values are set in the property file that local defaults are used.
Test that if no values are set in the property file that local defaults are used .
// Setting key value pair // ask to log at a level that is acceptable //verify that the log entry was successful, this proves that even if the config admin is unavailable and there //are no properties known to the framework that the log service will still function.