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);
}
Aggregations