예제 #1
0
  public void testChildThread() throws InterruptedException {

    String job = "My Important Job";

    Log4jArchiver archiver = new Log4jArchiver(this, "[%X{ojname}] %m%n");

    MyLL ll = new MyLL();
    archiver.addLogListener(ll, this, LogLevel.INFO, -1, 100);

    OddjobNDC.push(loggerName(), job);

    Thread t =
        new Thread(
            new Runnable() {
              public void run() {
                logger.info("Child Thread Message.");
              }
            });

    OddjobNDC.pop();

    t.start();

    t.join();

    assertEquals("[My Important Job] Child Thread Message." + OddjobTestHelper.LS, ll.message);
  }
예제 #2
0
  public void testWithArchiver() {

    Log4jArchiver archiver = new Log4jArchiver(this, "%m%n");

    MyLL ll = new MyLL();
    archiver.addLogListener(ll, this, LogLevel.INFO, -1, 100);

    logger.info("Will not be archived!");

    assertNull(ll.message);

    OddjobNDC.push(loggerName(), new Object());

    logger.info("Will be archived!");
    assertEquals("Will be archived!" + OddjobTestHelper.LS, ll.message);

    OddjobNDC.pop();
  }