public void testBasicLogger() {
Log.clearLogHandlers();
Log.setDefaultLevel(Level.INFO);
final ListLogHandler handler = new ListLogHandler();
Log.addLogHandler(handler);
// Check set up
assertEquals(Level.INFO, Log.getDefaultLevel());
// Check level iterator.
Iterator<Level> iterator = Log.levelIterator();
assertEquals(Level.ALL, iterator.next());
assertEquals(Level.FINEST, iterator.next());
assertEquals(Level.FINER, iterator.next());
// Basic Test.
Log.severe("severe");
assertEquals("severe", getLastMessage(handler));
Log.finest("finest");
assertEquals("severe", getLastMessage(handler));
// Test setting the log level.
// On
Log.setDefaultLevel(Level.FINEST);
Log.finest("finest");
assertEquals("finest", getLastMessage(handler));
// Off
Log.setDefaultLevel(Level.OFF);
Log.severe("going into the void");
assertEquals("finest", getLastMessage(handler));
// Test category filters.
String cParent = "com.mycompany";
String cChild1 = "com.mycompany.package1";
String cChild2 = "com.mycompany.package2";
Log.setDefaultLevel(Level.CONFIG);
Log.config("config", cChild1);
assertEquals("config", getLastMessage(handler));
assertEquals(cChild1, handler.getLast().getCategory());
Log.setDefaultLevel(Level.WARNING);
Log.config("bad", cChild1);
assertEquals("config", getLastMessage(handler));
Log.setLevel(cParent, Level.CONFIG);
Log.setLevel(cChild2, Level.INFO);