use of java.util.logging.Logger in project j2objc by google.
the class LoggerTest method testGetParent_NormalNamed.
/*
* Test getParent() for normal named loggers.
*/
public void testGetParent_NormalNamed() {
Logger log = Logger.getLogger("testGetParent_NormalNamed");
assertSame(log.getParent(), Logger.getLogger(""));
Logger child = Logger.getLogger("testGetParent_NormalNamed.child");
assertSame(child.getParent(), log);
Logger child2 = Logger.getLogger("testGetParent_NormalNamed.a.b.c");
assertSame(child2.getParent(), log);
}
use of java.util.logging.Logger 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);
}
use of java.util.logging.Logger in project j2objc by google.
the class LoggerTest method testGetSetLevel_Null.
/*
* Test getLevel & setLevel with null value, having sufficient privilege.
*/
public void testGetSetLevel_Null() {
Logger log = Logger.getLogger("testGetSetLevel_Null");
assertNull(log.getLevel());
log.setLevel(null);
assertNull(log.getLevel());
log.setLevel(Level.CONFIG);
log.setLevel(null);
assertNull(log.getLevel());
}
use of java.util.logging.Logger in project j2objc by google.
the class LoggerTest method testGetLoggerWithRes_Normal.
// /*
// * Test getLogger(String), getting a logger with existing parent, using
// * abnormal names (containing '.').
// */
// public void testGetLogger_WithParentAbnormal() {
// Logger log = Logger.getLogger(".");
// assertSame(log.getParent(), Logger.getLogger(""));
// Logger log2 = Logger.getLogger("..");
// assertSame(log2.getParent(), Logger.getLogger(""));
// //TODO: a lot more can be tested
// }
/*
* Test getLogger(String, String), getting a logger with no parent.
*/
public void testGetLoggerWithRes_Normal() throws Exception {
// config the level
Properties p = new Properties();
p.put("testGetLoggerWithRes_Normal_ANewLogger.level", "ALL");
LogManager.getLogManager().readConfiguration(EnvironmentHelper.PropertiesToInputStream(p));
assertNull(LogManager.getLogManager().getLogger("testGetLoggerWithRes_Normal_ANewLogger"));
// create a new logger
Logger log = Logger.getLogger("testGetLoggerWithRes_Normal_ANewLogger", VALID_RESOURCE_BUNDLE);
// get an existing logger
assertSame(log, Logger.getLogger("testGetLoggerWithRes_Normal_ANewLogger"));
// check it has been registered
assertSame(log, LogManager.getLogManager().getLogger("testGetLoggerWithRes_Normal_ANewLogger"));
assertNull(log.getFilter());
assertEquals(0, log.getHandlers().length);
// check it's set to the preconfigured level
assertSame(Level.ALL, log.getLevel());
assertEquals("testGetLoggerWithRes_Normal_ANewLogger", log.getName());
assertNull(log.getParent().getParent());
assertEquals(VALID_VALUE, log.getResourceBundle().getString(VALID_KEY));
assertEquals(log.getResourceBundleName(), VALID_RESOURCE_BUNDLE);
assertTrue(log.getUseParentHandlers());
}
use of java.util.logging.Logger in project j2objc by google.
the class LoggerTest method testGetLogger_Normal.
/*
* Test getLogger(String), getting a logger with no parent.
*/
public void testGetLogger_Normal() throws Exception {
// config the level
Properties p = new Properties();
p.put("testGetLogger_Normal_ANewLogger.level", "ALL");
LogManager.getLogManager().readConfiguration(EnvironmentHelper.PropertiesToInputStream(p));
assertNull(LogManager.getLogManager().getLogger("testGetLogger_Normal_ANewLogger"));
// create a new logger
Logger log = Logger.getLogger("testGetLogger_Normal_ANewLogger");
// get an existing logger
assertSame(log, Logger.getLogger("testGetLogger_Normal_ANewLogger"));
// check it has been registered
assertSame(log, LogManager.getLogManager().getLogger("testGetLogger_Normal_ANewLogger"));
assertNull(log.getFilter());
assertEquals(0, log.getHandlers().length);
// check it's set to the preconfigured level
assertSame(Level.ALL, log.getLevel());
assertEquals("testGetLogger_Normal_ANewLogger", log.getName());
assertNull(log.getParent().getParent());
assertNull(log.getResourceBundle());
assertNull(log.getResourceBundleName());
assertTrue(log.getUseParentHandlers());
}
Aggregations