public void testIsLoggable() throws Exception {
// create logger
org.apache.uima.util.Logger rootLogger = JSR47Logger_impl.getInstance();
org.apache.uima.util.Logger classLogger = JSR47Logger_impl.getInstance(this.getClass());
Level defaultLogLevel = (Level) logLevels.get(LogManager.getLogManager().getProperty(".level"));
if(defaultLogLevel == null) {
//no log level was specified, use default log level settings "INFO" that is also
//used by the Java logging framework.
defaultLogLevel = Level.INFO;
}
// check message logging for root logger based on default log level
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.ALL), rootLogger
.isLoggable(Level.ALL));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINEST), rootLogger
.isLoggable(Level.FINEST));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINER), rootLogger
.isLoggable(Level.FINER));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINE), rootLogger
.isLoggable(Level.FINE));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.CONFIG), rootLogger
.isLoggable(Level.CONFIG));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.INFO), rootLogger
.isLoggable(Level.INFO));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.WARNING), rootLogger
.isLoggable(Level.WARNING));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.SEVERE), rootLogger
.isLoggable(Level.SEVERE));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.OFF), rootLogger
.isLoggable(Level.OFF));
// check message logging for class logger based on default log level
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.ALL), classLogger
.isLoggable(Level.ALL));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINEST), classLogger
.isLoggable(Level.FINEST));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINER), classLogger
.isLoggable(Level.FINER));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINE), classLogger
.isLoggable(Level.FINE));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.CONFIG), classLogger
.isLoggable(Level.CONFIG));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.INFO), classLogger
.isLoggable(Level.INFO));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.WARNING), classLogger
.isLoggable(Level.WARNING));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.SEVERE), classLogger
.isLoggable(Level.SEVERE));
Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.OFF), classLogger
.isLoggable(Level.OFF));
// reset class logger level to OFF
// Logger.getLogger(this.getClass().getName()).setLevel(java.util.logging.Level.OFF);
classLogger.setLevel(Level.OFF);