@Beta @GwtCompatible public class TestLogHandler extends java.util.logging.Handler
TestLogHandler handler; protected void setUp() throws Exception { super.setUp(); handler = new TestLogHandler(); SomeClass.logger.addHandler(handler); addTearDown(new TearDown() { public void tearDown() throws Exception { SomeClass.logger.removeHandler(handler); } }); } public void test() { SomeClass.foo(); LogRecord firstRecord = handler.getStoredLogRecords().get(0); assertEquals("some message", firstRecord.getMessage()); }
Constructor and Description |
---|
TestLogHandler() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
close() |
void |
flush() |
java.util.List<java.util.logging.LogRecord> |
getStoredLogRecords()
Returns a snapshot of the logged records.
|
void |
publish(java.util.logging.LogRecord record)
Adds the most recently logged record to our list.
|
public TestLogHandler()
public void publish(@NullableDecl java.util.logging.LogRecord record)
publish
in class java.util.logging.Handler
public void flush()
flush
in class java.util.logging.Handler
public void close()
close
in class java.util.logging.Handler
public void clear()
public java.util.List<java.util.logging.LogRecord> getStoredLogRecords()
Copyright © 2010-2017. All Rights Reserved.