use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLog_LevelStringObject_Normal.
/*
* Test log(Level, String, Object) with normal values.
*/
public void testLog_LevelStringObject_Normal() {
Object param = new Object();
this.sharedLogger.setLevel(Level.INFO);
this.sharedLogger.log(Level.INFO, "log(Level, String, Object) msg", param);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "log(Level, String, Object) msg");
assertSame(r.getResourceBundleName(), this.sharedLogger.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.INFO);
assertEquals(1, r.getParameters().length);
assertSame(param, r.getParameters()[0]);
assertSame(r.getThrown(), null);
this.sharedLogger.log(Level.CONFIG, "log(Level, String, Object) msg", param);
assertTrue(CallVerificationStack.getInstance().empty());
this.sharedLogger.setLevel(Level.OFF);
this.sharedLogger.log(Level.OFF, "log(Level, String, Object) msg", param);
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project randomizedtesting by randomizedtesting.
the class WithNestedTestClass method setupNested.
@BeforeClass
public static final void setupNested() throws IOException {
runningNested = true;
zombieToken = new Object();
// capture sysout/ syserr.
sw = new StringWriter();
sysout = System.out;
syserr = System.err;
System.setOut(new PrintStream(new TeeOutputStream(System.out, new WriterOutputStream(sw))));
System.setErr(new PrintStream(new TeeOutputStream(System.err, new WriterOutputStream(sw))));
// Add custom logging handler because java logging keeps a reference to previous System.err.
loggingMessages = new StringWriter();
logger = Logger.getLogger("");
handlers = logger.getHandlers();
for (Handler h : handlers) logger.removeHandler(h);
logger.addHandler(new Handler() {
final SimpleFormatter formatter = new SimpleFormatter();
@Override
public void publish(LogRecord record) {
loggingMessages.write(formatter.format(record) + "\n");
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
});
}
use of java.util.logging.LogRecord in project byte-buddy by raphw.
the class ByteBuddyLogHandlerTest method testLogPublishDebug.
@Test
public void testLogPublishDebug() throws Exception {
ByteBuddyLogHandler byteBuddyLogHandler = new ByteBuddyLogHandler(log, mock(Logger.class), false);
LogRecord logRecord = new LogRecord(Level.INFO, FOO);
when(log.isDebugEnabled()).thenReturn(true);
byteBuddyLogHandler.publish(logRecord);
verify(log).isDebugEnabled();
verify(log).debug(byteBuddyLogHandler.getFormatter().format(logRecord));
verifyNoMoreInteractions(log);
}
use of java.util.logging.LogRecord in project byte-buddy by raphw.
the class ByteBuddyLogHandlerTest method testLogPublishNoDebug.
@Test
public void testLogPublishNoDebug() throws Exception {
ByteBuddyLogHandler byteBuddyLogHandler = new ByteBuddyLogHandler(log, mock(Logger.class), false);
LogRecord logRecord = new LogRecord(Level.INFO, FOO);
byteBuddyLogHandler.publish(logRecord);
verify(log).isDebugEnabled();
verifyNoMoreInteractions(log);
}
use of java.util.logging.LogRecord in project robovm by robovm.
the class OldFileHandlerTest method setUp.
protected void setUp() throws Exception {
super.setUp();
manager.reset();
//initProp
props.clear();
props.put("java.util.logging.FileHandler.level", "FINE");
props.put("java.util.logging.FileHandler.filter", className + "$MockFilter");
props.put("java.util.logging.FileHandler.formatter", className + "$MockFormatter");
props.put("java.util.logging.FileHandler.encoding", "iso-8859-1");
// limit to only two message
props.put("java.util.logging.FileHandler.limit", "1000");
// rotation count is 2
props.put("java.util.logging.FileHandler.count", "2");
// using append mode
props.put("java.util.logging.FileHandler.append", "true");
props.put("java.util.logging.FileHandler.pattern", "%t/log/java%u.test");
HOMEPATH = System.getProperty("user.home");
TEMPPATH = System.getProperty("java.io.tmpdir");
File file = new File(TEMPPATH + SEP + "log");
file.mkdir();
manager.readConfiguration(propertiesToInputStream(props));
handler = new FileHandler();
r = new LogRecord(Level.CONFIG, "msg");
}
Aggregations