FileDocCategorySizeDatePackage
TelnetAppenderTest.javaAPI DocApache log4j 1.2.152228Sat Aug 25 00:09:34 BST 2007org.apache.log4j.net

TelnetAppenderTest

public class TelnetAppenderTest extends TestCase

Fields Summary
int
port
ByteArrayOutputStream
bo
Constructors Summary
Methods Summary
public voidtestIt()

    int oldActive = Thread.activeCount();
    TelnetAppender ta = new TelnetAppender();
    ta.setName("ta");
    ta.setPort(port);
    ta.setLayout(new PatternLayout("%p - %m"));
    ta.activateOptions();
    Logger l = Logger.getLogger("x");
    l.addAppender(ta);
    Thread t = new ReadThread();
    t.start();
    Thread.sleep(200);
    l.info("hi");
    Thread.sleep(1000);
    ta.close();
    Thread.sleep(200);
    t.interrupt();
    t.join();
    String s = bo.toString();
    assertTrue(s.endsWith("INFO - hi"));
    assertEquals(oldActive, Thread.activeCount());