use of java.util.logging.Logger in project j2objc by google.
the class LoggerTest method testGetResourceBundleName_Normal.
/*
* Test getResourceBundleName() when it it not null.
*/
public void testGetResourceBundleName_Normal() {
Logger log = Logger.getLogger("testGetResourceBundleName_Normal", VALID_RESOURCE_BUNDLE);
assertEquals(VALID_RESOURCE_BUNDLE, log.getResourceBundleName());
Logger mlog = new MockLogger(null, null);
assertNull(mlog.getResourceBundleName());
}
use of java.util.logging.Logger in project j2objc by google.
the class LoggerTest method testSevere_Null.
/*
* Test severe(String) with null values.
*/
public void testSevere_Null() {
Logger child = new MockLogger("childLogger", null);
Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2);
child.addHandler(new MockHandler());
child.setParent(parent);
child.setLevel(Level.SEVERE);
child.severe(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.SEVERE);
assertNull(r.getParameters());
assertSame(r.getThrown(), null);
this.sharedLogger.setLevel(Level.OFF);
this.sharedLogger.severe(null);
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.Logger in project j2objc by google.
the class LoggerTest method testGetSetFilter_NamedLoggerSufficientPrivilege.
/*
* Test getFilter & setFilter with normal value for a named logger, having
* sufficient privilege.
*/
public void testGetSetFilter_NamedLoggerSufficientPrivilege() {
Logger log = Logger.getLogger("testGetSetFilter_NamedLoggerSufficientPrivilege");
Filter f = new MockFilter();
assertNull(log.getFilter());
log.setFilter(f);
assertSame(f, log.getFilter());
}
use of java.util.logging.Logger in project j2objc by google.
the class LoggerTest method testGetName_Null.
/*
* Test getName() for null name.
*/
public void testGetName_Null() {
Logger log = Logger.getAnonymousLogger();
assertNull(log.getName());
Logger mlog = new MockLogger(null, null);
assertNull(mlog.getName());
}
use of java.util.logging.Logger 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());
}
Aggregations