mil.dod.th.ose.logging/test/mil/dod/th/ose/logging/TestLogWriter.java
@Test
    public void testDefaultBufferSize() throws Exception
    {
        BundleContext context = mock(BundleContext.class);
        Map<String, Object> props = new HashMap<String, Object>(getComponentProperties());
        when(context.getProperty(LogWriter.LOG_DIR_PROPERTY)).thenReturn("TempLogDir");

        // Setting key value pair
        m_SUT.activate(context, props);
        // This is to mimic the log file created during activation.
        setUpFileNaming();

        // testing that activation/openLogFile methods
        long fileLength = m_LogFile.length();

        // ensuring the file size has not changed
        LogEntry logEntry = mock(LogEntry.class);
        when(logEntry.getBundle()).thenReturn(m_Bundle);
        when(logEntry.getLevel()).thenReturn(LogService.LOG_DEBUG);
        when(logEntry.getTime()).thenReturn(1L);
        m_SUT.logged(logEntry);
        //should be immediately be larger as the default buffer size is 1
        assertThat(m_LogFile.length(), greaterThan(fileLength));
    }
/**
     * Test the default buffer size is 1, essentially set to not buffer.
     * Verify that the file size increases instantly.
     */
Test the default buffer size is 1, essentially set to not buffer.
Verify that the file size increases instantly.
Test the default buffer size is 1 essentially set to not buffer . Verify that the file size increases instantly .
@Test
    public void testDefaultBufferSize() throws Exception
    {
        BundleContext context = mock(BundleContext.class);
        Map<String, Object> props = new HashMap<String, Object>(getComponentProperties());
        when(context.getProperty(LogWriter.LOG_DIR_PROPERTY)).thenReturn("TempLogDir");
        m_SUT.activate(context, props);
        setUpFileNaming();
        long fileLength = 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);
        m_SUT.logged(logEntry);
        assertThat(m_LogFile.length(), greaterThan(fileLength));
    }
@ Test public void testDefaultBufferSize ( ) throws Exception { BundleContext context = mock ( BundleContext . class ) ; Map < String , Object > props = new HashMap < String , Object > ( getComponentProperties ( ) ) ; when ( context . getProperty ( LogWriter . LOG_DIR_PROPERTY ) ) . thenReturn ( "TempLogDir" ) ; m_SUT . activate ( context , props ) ; setUpFileNaming ( ) ; long fileLength = 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 ) ; m_SUT . logged ( logEntry ) ; assertThat ( m_LogFile . length ( ) , greaterThan ( fileLength ) ) ; }
Test the default buffer size is 1, essentially set to not buffer.
Test the default buffer size is 1 essentially set to not buffer .
// Setting key value pair // This is to mimic the log file created during activation. // testing that activation/openLogFile methods // ensuring the file size has not changed //should be immediately be larger as the default buffer size is 1