use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLog_ParentInformed.
/*
* Test that the parent's handler is notified for a new log record when
* getUseParentHandlers() is true.
*/
public void testLog_ParentInformed() {
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.log(r);
assertTrue(child.getUseParentHandlers());
// pop only once, pushed by the parent logger's handler, not by the
// parent itself!
assertSame(r, CallVerificationStack.getInstance().pop());
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), null);
assertEquals(r.getMessage(), "testLog_ParentInformed");
assertSame(r.getResourceBundleName(), null);
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.INFO);
assertNull(r.getParameters());
assertSame(r.getThrown(), null);
// set the child logger to disabling level
child.setLevel(Level.SEVERE);
child.log(r);
assertTrue(CallVerificationStack.getInstance().empty());
// set the parent logger to disabling level
child.setLevel(Level.INFO);
parent.setLevel(Level.SEVERE);
child.log(r);
assertSame(r, CallVerificationStack.getInstance().pop());
assertTrue(CallVerificationStack.getInstance().empty());
// set the child logger off
child.setLevel(Level.OFF);
child.log(r);
assertTrue(CallVerificationStack.getInstance().empty());
// set the record off
r.setLevel(Level.OFF);
child.log(r);
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testExiting_StringStringObject_Normal.
/*
* Test exiting(String, String, Object) with normal values.
*/
public void testExiting_StringStringObject_Normal() {
Object param = new Object();
this.sharedLogger.setLevel(Level.FINER);
this.sharedLogger.exiting("sourceClass", "sourceMethod", param);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "RETURN {0}");
assertSame(r.getResourceBundleName(), this.sharedLogger.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), "sourceClass");
assertSame(r.getSourceMethodName(), "sourceMethod");
assertSame(r.getLevel(), Level.FINER);
assertSame(r.getParameters()[0], param);
assertEquals(1, r.getParameters().length);
assertSame(r.getThrown(), null);
this.sharedLogger.setLevel(Level.FINE);
this.sharedLogger.exiting("sourceClass", "sourceMethod", param);
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLogrb_LevelStringStringStringThrowable_Normal.
/*
* Test logrb(Level, String, String, String, String, Throwable) with normal
* values.
*/
public void testLogrb_LevelStringStringStringThrowable_Normal() {
Throwable t = new Throwable();
this.sharedLogger.setLevel(Level.INFO);
this.sharedLogger.logrb(Level.parse("1611"), "sourceClass", "sourceMethod", VALID_RESOURCE_BUNDLE2, "logrb(Level, String, String, String, String, Throwable) msg", t);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "logrb(Level, String, String, String, String, Throwable) msg");
assertSame(r.getResourceBundleName(), VALID_RESOURCE_BUNDLE2);
assertSame(r.getSourceClassName(), "sourceClass");
assertSame(r.getSourceMethodName(), "sourceMethod");
assertSame(r.getLevel(), Level.parse("1611"));
assertNull(r.getParameters());
assertSame(r.getThrown(), t);
assertNull(Level.parse("1611").getResourceBundleName());
this.sharedLogger.logrb(Level.CONFIG, "sourceClass", "sourceMethod", VALID_RESOURCE_BUNDLE2, "logrb(Level, String, String, String, String, Throwable) msg", t);
assertTrue(CallVerificationStack.getInstance().empty());
this.sharedLogger.setLevel(Level.OFF);
this.sharedLogger.logrb(Level.OFF, "sourceClass", "sourceMethod", VALID_RESOURCE_BUNDLE2, "logrb(Level, String, String, String, String, Throwable) msg", t);
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLogrb_LevelStringStringStringThrowable_InvalidRes.
/*
* Test logrb(Level, String, String, String, String, Throwable) with invalid
* resource bundle.
*/
public void testLogrb_LevelStringStringStringThrowable_InvalidRes() {
Throwable t = new Throwable();
this.sharedLogger.setLevel(Level.ALL);
this.sharedLogger.logrb(Level.ALL, "sourceClass", "sourceMethod", INVALID_RESOURCE_BUNDLE, "logrb(Level, String, String, String, String) msg", t);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "logrb(Level, String, String, String, String) msg");
assertSame(r.getResourceBundleName(), INVALID_RESOURCE_BUNDLE);
assertSame(r.getResourceBundle(), null);
assertSame(r.getSourceClassName(), "sourceClass");
assertSame(r.getSourceMethodName(), "sourceMethod");
assertSame(r.getLevel(), Level.ALL);
assertNull(r.getParameters());
assertSame(r.getThrown(), t);
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLogp_LevelStringStringStringObjects_NullMsgObj.
/*
* Test logp(Level, String, String, String, Object[]) with null message and
* object.
*/
public void testLogp_LevelStringStringStringObjects_NullMsgObj() {
Logger child = new MockLogger("childLogger", null);
Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2);
child.addHandler(new MockHandler());
child.setParent(parent);
child.setLevel(Level.INFO);
child.logp(Level.INFO, null, null, null, (Object[]) null);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), child.getName());
assertNull(r.getMessage());
assertSame(r.getResourceBundleName(), parent.getResourceBundleName());
assertSame(r.getResourceBundle(), parent.getResourceBundle());
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.INFO);
assertNull(r.getParameters());
assertSame(r.getThrown(), null);
}
Aggregations