CompactFormatter extends java.util.logging.Formatter { @Override public String formatMessage(final LogRecord record) { String msg = super.formatMessage(record); msg = replaceClassName(msg, record.getThrown()); msg = replaceClassName(msg, record.getParameters()); return msg; } CompactFormatter();  CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecord record); String formatMessage(final Throwable t); String formatLevel(final LogRecord record); String formatSource(final LogRecord record); String formatLoggerName(final LogRecord record); String formatThrown(final LogRecord record); String formatBackTrace(LogRecord record);  }
@Test(expected = NullPointerException.class) public void testFormatMessageNull() { CompactFormatter cf = new CompactFormatter(); cf.formatMessage((LogRecord) null); fail(cf.toString()); }
@Test(timeout = 30000) public void testFormatMessage_LogRecordEvil() { LogRecord record = new LogRecord(Level.SEVERE, ""); record.setThrown(createEvilThrowable()); CompactFormatter cf = new CompactFormatter(); cf.formatMessage(record); }
@Test public void testFormatMessage_Throwable() { Exception e = new IOException(Exception.class.getName()); e = new Exception(e.toString(), e); assertNotNull(e.getMessage(), e.getMessage()); CompactFormatter cf = new CompactFormatter(); String result = cf.formatMessage(e); assertEquals(result, Exception.class.getSimpleName()); }
@Test(timeout = 30000) public void testFormatMessage_ThrowableEvil() { CompactFormatter cf = new CompactFormatter(); cf.formatMessage(createEvilThrowable()); }