use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLog_LevelStringThrowable_Normal.
/*
* Test log(Level, String, Throwable) with normal values.
*/
public void testLog_LevelStringThrowable_Normal() {
Throwable t = new Throwable();
this.sharedLogger.setLevel(Level.INFO);
this.sharedLogger.log(Level.INFO, "log(Level, String, Throwable) msg", t);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "log(Level, String, Throwable) msg");
assertSame(r.getResourceBundleName(), this.sharedLogger.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.INFO);
assertNull(r.getParameters());
assertSame(r.getThrown(), t);
this.sharedLogger.log(Level.CONFIG, "log(Level, String, Throwable) msg", t);
assertTrue(CallVerificationStack.getInstance().empty());
this.sharedLogger.setLevel(Level.OFF);
this.sharedLogger.log(Level.OFF, "log(Level, String, Throwable) msg", t);
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLog_ParentNotInformed.
/*
* Test that the parent's handler is notified for a new log record when
* getUseParentHandlers() is false.
*/
public void testLog_ParentNotInformed() {
Logger child = new MockLogger("childLogger", VALID_RESOURCE_BUNDLE);
Logger parent = new MockParentLogger("parentLogger", VALID_RESOURCE_BUNDLE2);
child.setParent(parent);
child.setLevel(Level.INFO);
parent.setLevel(Level.INFO);
parent.addHandler(new MockHandler());
LogRecord r = new LogRecord(Level.INFO, "testLog_ParentInformed");
child.setUseParentHandlers(false);
child.log(r);
assertFalse(child.getUseParentHandlers());
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testConfig_Normal.
/*
* Test config(String) with normal values.
*/
public void testConfig_Normal() {
this.sharedLogger.setLevel(Level.CONFIG);
this.sharedLogger.config("config msg");
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "config msg");
assertSame(r.getResourceBundleName(), this.sharedLogger.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.CONFIG);
assertNull(r.getParameters());
assertSame(r.getThrown(), null);
this.sharedLogger.setLevel(Level.INFO);
this.sharedLogger.config("config again");
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLog_NullResHasParent.
/*
* Test that a logger inherits its parent resource bundle when its resource
* bundle is null.
*/
public void testLog_NullResHasParent() {
Logger child = new MockLogger("childLogger", null);
Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2);
child.addHandler(new MockHandler());
child.setParent(parent);
parent.setLevel(Level.FINER);
assertNull(child.getResourceBundle());
assertNull(child.getResourceBundleName());
child.log(Level.FINE, "testLog_NullResHasParent");
// pop only once, pushed by the child logger's handler
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), "childLogger");
assertEquals(r.getMessage(), "testLog_NullResHasParent");
assertSame(r.getResourceBundleName(), VALID_RESOURCE_BUNDLE2);
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.FINE);
assertNull(r.getParameters());
assertSame(r.getThrown(), null);
assertNull(child.getResourceBundle());
assertNull(child.getResourceBundleName());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLogp_LevelStringStringStringObject_Normal.
/*
* Test logp(Level, String, String, String, Object) with normal values.
*/
public void testLogp_LevelStringStringStringObject_Normal() {
Object param = new Object();
this.sharedLogger.setLevel(Level.INFO);
this.sharedLogger.logp(Level.INFO, "sourceClass", "sourceMethod", "logp(Level, String, String, String, Object) msg", param);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "logp(Level, String, String, String, Object) msg");
assertSame(r.getResourceBundleName(), this.sharedLogger.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), "sourceClass");
assertSame(r.getSourceMethodName(), "sourceMethod");
assertSame(r.getLevel(), Level.INFO);
assertEquals(1, r.getParameters().length);
assertSame(param, r.getParameters()[0]);
assertSame(r.getThrown(), null);
this.sharedLogger.logp(Level.CONFIG, "sourceClass", "sourceMethod", "logp(Level, String, String, String, Object) msg", param);
assertTrue(CallVerificationStack.getInstance().empty());
this.sharedLogger.setLevel(Level.OFF);
this.sharedLogger.logp(Level.OFF, "sourceClass", "sourceMethod", "logp(Level, String, String, String, Object) msg", param);
assertTrue(CallVerificationStack.getInstance().empty());
}
Aggregations