@Test
  public void append_basic() {
    MockLoggingChannel log = new MockLoggingChannel();
    KettleLogChannelAppender appender = new KettleLogChannelAppender(log);
    Logger testLogger = Logger.getLogger(getClass());
    testLogger.setLevel(Level.ALL);
    Layout layout = new Log4jKettleLayout();

    // ALL, INFO, and WARN messages should be interpreted as "basic" messages
    @SuppressWarnings("deprecation")
    LoggingEvent infoEvent =
        new LoggingEvent("org.test", testLogger, Priority.INFO, "Testing Info", null);
    @SuppressWarnings("deprecation")
    LoggingEvent warnEvent =
        new LoggingEvent("org.test", testLogger, Priority.WARN, "Testing Warning", null);
    @SuppressWarnings("deprecation")
    LoggingEvent allEvent =
        new LoggingEvent(
            "org.test", testLogger, Priority.toPriority(Priority.ALL_INT), "Testing All", null);
    appender.doAppend(infoEvent);
    appender.doAppend(warnEvent);
    appender.doAppend(allEvent);

    assertEquals(0, log.getDebugMessages().size());
    assertEquals(0, log.getDetailedMessages().size());
    assertEquals(0, log.getErrorMessages().size());
    assertEquals(0, log.getMinimalMessages().size());
    assertEquals(0, log.getRowLevelMessages().size());

    assertEquals(3, log.getBasicMessages().size());
    assertEquals(layout.format(infoEvent), log.getBasicMessages().get(0).getMessage());
    assertEquals(layout.format(warnEvent), log.getBasicMessages().get(1).getMessage());
    assertEquals(layout.format(allEvent), log.getBasicMessages().get(2).getMessage());
  }
  @Test
  public void append_error() {
    MockLoggingChannel log = new MockLoggingChannel();
    KettleLogChannelAppender appender = new KettleLogChannelAppender(log);
    Logger testLogger = Logger.getLogger(getClass());
    testLogger.setLevel(Level.ALL);

    // ERROR and FATAL map to "error" messages
    Layout layout = new Log4jKettleLayout();
    @SuppressWarnings("deprecation")
    LoggingEvent errorEvent1 =
        new LoggingEvent("org.test", testLogger, Priority.ERROR, "Testing", null);
    Exception errorException = new Exception("something went wrong!");
    @SuppressWarnings("deprecation")
    LoggingEvent errorEvent2 =
        new LoggingEvent("org.test", testLogger, Priority.ERROR, "Testing", errorException);
    @SuppressWarnings("deprecation")
    LoggingEvent fatalEvent1 =
        new LoggingEvent("org.test", testLogger, Priority.FATAL, "Testing", null);
    Exception fatalException = new Exception("something went fatally wrong!");
    @SuppressWarnings("deprecation")
    LoggingEvent fatalEvent2 =
        new LoggingEvent("org.test", testLogger, Priority.FATAL, "Testing", fatalException);

    appender.doAppend(errorEvent1);
    appender.doAppend(errorEvent2);
    appender.doAppend(fatalEvent1);
    appender.doAppend(fatalEvent2);

    assertEquals(0, log.getDebugMessages().size());
    assertEquals(0, log.getDetailedMessages().size());
    assertEquals(0, log.getBasicMessages().size());
    assertEquals(0, log.getMinimalMessages().size());
    assertEquals(0, log.getRowLevelMessages().size());

    assertEquals(4, log.getErrorMessages().size());
    assertEquals(layout.format(errorEvent1), log.getErrorMessages().get(0).getMessage());
    assertEquals(layout.format(errorEvent1), log.getErrorMessages().get(1).getMessage());
    assertEquals(errorException, log.getErrorMessages().get(1).getThrowable());
    assertEquals(layout.format(fatalEvent1), log.getErrorMessages().get(2).getMessage());
    assertEquals(layout.format(fatalEvent2), log.getErrorMessages().get(3).getMessage());
    assertEquals(fatalException, log.getErrorMessages().get(3).getThrowable());
  }
  @Test
  public void append_debug() {
    MockLoggingChannel log = new MockLoggingChannel();
    KettleLogChannelAppender appender = new KettleLogChannelAppender(log);
    Logger testLogger = Logger.getLogger(getClass());
    testLogger.setLevel(Level.ALL);

    // DEBUG messages should be interpreted as "debug" messages
    Layout layout = new Log4jKettleLayout();
    @SuppressWarnings("deprecation")
    LoggingEvent event =
        new LoggingEvent("org.test", testLogger, Priority.DEBUG, "debug test!", null);

    appender.doAppend(event);
    assertEquals(0, log.getBasicMessages().size());
    assertEquals(0, log.getDetailedMessages().size());
    assertEquals(0, log.getErrorMessages().size());
    assertEquals(0, log.getMinimalMessages().size());
    assertEquals(0, log.getRowLevelMessages().size());

    assertEquals(1, log.getDebugMessages().size());
    assertEquals(layout.format(event), log.getDebugMessages().get(0).getMessage());
  }