use of java.util.logging.StreamHandler in project j2objc by google.
the class StreamHandlerTest method testPublish_NullMsg.
/*
* Test publish(), a log record with null msg, having output stream
*/
public void testPublish_NullMsg() {
ByteArrayOutputStream aos = new ByteArrayOutputStream();
StreamHandler h = new StreamHandler(aos, new MockFormatter());
LogRecord r = new LogRecord(Level.INFO, null);
h.publish(r);
h.flush();
assertEquals("MockFormatter_Head", aos.toString());
}
use of java.util.logging.StreamHandler in project j2objc by google.
the class StreamHandlerTest method testPublish_NoOutputStream.
/*
* Test publish(), use no filter, having output stream, normal log record.
*/
public void testPublish_NoOutputStream() {
StreamHandler h = new StreamHandler();
LogRecord r = new LogRecord(Level.INFO, "testPublish_NoOutputStream");
h.publish(r);
h.setLevel(Level.WARNING);
h.publish(r);
h.setLevel(Level.CONFIG);
h.publish(r);
r.setLevel(Level.OFF);
h.setLevel(Level.OFF);
h.publish(r);
}
use of java.util.logging.StreamHandler in project j2objc by google.
the class StreamHandlerTest method testIsLoggable_WithFilter.
/*
* Test isLoggable(), use a filter, having output stream
*/
public void testIsLoggable_WithFilter() {
StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), new SimpleFormatter());
LogRecord r = new LogRecord(Level.INFO, null);
h.setFilter(new MockFilter());
assertFalse(h.isLoggable(r));
assertSame(r, CallVerificationStack.getInstance().pop());
h.setLevel(Level.CONFIG);
assertFalse(h.isLoggable(r));
assertSame(r, CallVerificationStack.getInstance().pop());
h.setLevel(Level.WARNING);
assertFalse(h.isLoggable(r));
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.StreamHandler in project j2objc by google.
the class StreamHandlerTest method testClose_NoOutputStream.
/*
* Test close() when having insufficient privilege.
*
public void testClose_InsufficientPrivilege() {
SecurityManager oldMan = System.getSecurityManager();
System.setSecurityManager(new MockSecurityManager());
try {
StreamHandler h = new StreamHandler(new ByteArrayOutputStream(),
new MockFormatter());
h.close();
fail("Should throw SecurityException!");
} catch (SecurityException e) {
// expected
} finally {
System.setSecurityManager(oldMan);
}
}
/*
* Test close() when having no output stream.
*/
public void testClose_NoOutputStream() {
StreamHandler h = new StreamHandler();
h.close();
}
use of java.util.logging.StreamHandler in project j2objc by google.
the class StreamHandlerTest method testFlush_NoOutputStream.
/*
* Test flush() when having no output stream.
*/
public void testFlush_NoOutputStream() {
StreamHandler h = new StreamHandler();
h.flush();
}
Aggregations