use of java.util.logging.LogRecord in project jersey by jersey.
the class AsyncResponseTest method testResumeException.
private void testResumeException(final String path, final String entity) throws Exception {
final WebTarget errorResource = target("errorResource");
final Future<Response> suspended = errorResource.path("suspend").request().async().get();
final Response response = errorResource.path(path).request().get();
assertThat(response.getStatus(), equalTo(200));
assertThat(response.readEntity(String.class), equalTo("ok"));
final Response suspendedResponse = suspended.get();
assertThat(suspendedResponse.getStatus(), equalTo(500));
if (entity != null) {
assertThat(suspendedResponse.readEntity(String.class), equalTo(entity));
}
suspendedResponse.close();
// Check there is no NPE.
for (final LogRecord record : getLoggedRecords()) {
final Throwable thrown = record.getThrown();
if (thrown != null && thrown instanceof NullPointerException) {
fail("Unexpected NPE.");
}
}
}
use of java.util.logging.LogRecord in project buck by facebook.
the class ConsoleHandlerTest method consoleHandlerDoesNotWriteBelowLevelToStream.
@Test
public void consoleHandlerDoesNotWriteBelowLevelToStream() {
ConsoleHandler handler = new ConsoleHandler(ConsoleHandler.utf8OutputStreamWriter(outputStream), new MessageOnlyFormatter(), Level.INFO, state);
publishAndFlush(handler, new LogRecord(Level.FINE, "Shh.."));
assertThat(outputStream.size(), equalTo(0));
}
use of java.util.logging.LogRecord in project buck by facebook.
the class LogFormatterTest method logRecord.
private static LogRecord logRecord(Level level, String message, String loggerName, int tid, long millis) {
LogRecord result = new LogRecord(level, message);
result.setLoggerName(loggerName);
result.setMillis(millis);
result.setThreadID(tid);
return result;
}
use of java.util.logging.LogRecord in project buck by facebook.
the class ConsoleHandlerTest method consoleHandlerCanChangeOutputStreamWithoutClosing.
@Test
public void consoleHandlerCanChangeOutputStreamWithoutClosing() throws IOException {
FakeOutputStream outputStream1 = new FakeOutputStream();
FakeOutputStream outputStream2 = new FakeOutputStream();
ConsoleHandler handler = new ConsoleHandler(ConsoleHandler.utf8OutputStreamWriter(outputStream1), new MessageOnlyFormatter(), Level.INFO, state);
publishAndFlush(handler, new LogRecord(Level.INFO, "Stream 1"));
assertThat(outputStream1.toString("UTF-8"), equalTo("Stream 1"));
threadIdToCommandId.put(49152L, "commandIdForOutputStream2");
registerOutputStream("commandIdForOutputStream2", outputStream2);
assertThat(outputStream1.isClosed(), equalTo(false));
publishAndFlush(handler, newLogRecordWithThreadId(Level.INFO, "Stream 2", 49152));
assertThat(outputStream1.toString("UTF-8"), equalTo("Stream 1"));
assertThat(outputStream2.toString("UTF-8"), equalTo("Stream 2"));
unregisterOutputStream("commandIdForOutputStream2");
assertThat(outputStream2.isClosed(), equalTo(false));
publishAndFlush(handler, new LogRecord(Level.INFO, " - DONE"));
assertThat(outputStream1.toString("UTF-8"), equalTo("Stream 1 - DONE"));
assertThat(outputStream2.toString("UTF-8"), equalTo("Stream 2"));
}
use of java.util.logging.LogRecord in project buck by facebook.
the class ConsoleHandlerTest method newLogRecordWithThreadId.
private static LogRecord newLogRecordWithThreadId(Level level, String contents, int threadId) {
LogRecord result = new LogRecord(level, contents);
result.setThreadID(threadId);
return result;
}
Aggregations