@Test
public void testPatternWithConfiguration() throws Exception {
final Configuration config = new DefaultConfiguration();
final MessagePatternConverter converter = MessagePatternConverter.newInstance(config, null);
Message msg = new SimpleMessage("Hello!");
LogEvent event = new Log4jLogEvent("MyLogger", null, null, Level.DEBUG, msg, null);
StringBuilder sb = new StringBuilder();
converter.format(event, sb);
assertTrue("Unexpected result", "Hello!".equals(sb.toString()));
event = new Log4jLogEvent("MyLogger", null, null, Level.DEBUG, null, null);
sb = new StringBuilder();
converter.format(event, sb);
assertTrue("Incorrect length: " + sb.length(), sb.length() == 0);
msg = new SimpleMessage(null);
event = new Log4jLogEvent("MyLogger", null, null, Level.DEBUG, msg, null);
sb = new StringBuilder();
converter.format(event, sb);
assertTrue("Incorrect length: " + sb.length(), sb.length() == 4);
}