Search in sources :

Example 1 with MockLogService

use of org.apache.felix.cm.MockLogService in project felix by apache.

the class ConfigurationManagerTest method testLogWithLogService.

// this test always expects output since when using a LogService, the log
// level property is ignored
@Test
public void testLogWithLogService() throws IOException {
    LogService logService = new MockLogService();
    ConfigurationManager configMgr = createConfigurationManagerAndLog(logService);
    setLogLevel(LogService.LOG_WARNING);
    assertLog(configMgr, LogService.LOG_DEBUG, "Debug Test Message", null);
    assertLog(configMgr, LogService.LOG_INFO, "Info Test Message", null);
    assertLog(configMgr, LogService.LOG_WARNING, "Warning Test Message", null);
    assertLog(configMgr, LogService.LOG_ERROR, "Error Test Message", null);
    setLogLevel(LogService.LOG_ERROR);
    assertLog(configMgr, LogService.LOG_DEBUG, "Debug Test Message", null);
    assertLog(configMgr, LogService.LOG_INFO, "Info Test Message", null);
    assertLog(configMgr, LogService.LOG_WARNING, "Warning Test Message", null);
    assertLog(configMgr, LogService.LOG_ERROR, "Error Test Message", null);
    setLogLevel(LogService.LOG_ERROR - 1);
    assertLog(configMgr, LogService.LOG_DEBUG, "Debug Test Message", null);
    assertLog(configMgr, LogService.LOG_INFO, "Info Test Message", null);
    assertLog(configMgr, LogService.LOG_WARNING, "Warning Test Message", null);
    assertLog(configMgr, LogService.LOG_ERROR, "Error Test Message", null);
    setLogLevel(Integer.MIN_VALUE);
    assertLog(configMgr, LogService.LOG_DEBUG, "Debug Test Message", null);
    assertLog(configMgr, LogService.LOG_INFO, "Info Test Message", null);
    assertLog(configMgr, LogService.LOG_WARNING, "Warning Test Message", null);
    assertLog(configMgr, LogService.LOG_ERROR, "Error Test Message", null);
    setLogLevel(LogService.LOG_INFO);
    assertLog(configMgr, LogService.LOG_DEBUG, "Debug Test Message", null);
    assertLog(configMgr, LogService.LOG_INFO, "Info Test Message", null);
    assertLog(configMgr, LogService.LOG_WARNING, "Warning Test Message", null);
    assertLog(configMgr, LogService.LOG_ERROR, "Error Test Message", null);
    setLogLevel(LogService.LOG_DEBUG);
    assertLog(configMgr, LogService.LOG_DEBUG, "Debug Test Message", null);
    assertLog(configMgr, LogService.LOG_INFO, "Info Test Message", null);
    assertLog(configMgr, LogService.LOG_WARNING, "Warning Test Message", null);
    assertLog(configMgr, LogService.LOG_ERROR, "Error Test Message", null);
    setLogLevel(Integer.MAX_VALUE);
    assertLog(configMgr, LogService.LOG_DEBUG, "Debug Test Message", null);
    assertLog(configMgr, LogService.LOG_INFO, "Info Test Message", null);
    assertLog(configMgr, LogService.LOG_WARNING, "Warning Test Message", null);
    assertLog(configMgr, LogService.LOG_ERROR, "Error Test Message", null);
}
Also used : MockLogService(org.apache.felix.cm.MockLogService) LogService(org.osgi.service.log.LogService) MockLogService(org.apache.felix.cm.MockLogService) Test(org.junit.Test)

Aggregations

MockLogService (org.apache.felix.cm.MockLogService)1 Test (org.junit.Test)1 LogService (org.osgi.service.log.LogService)1