FileDocCategorySizeDatePackage
ErrorHandlerTestCase.javaAPI DocApache log4j 1.2.153957Sat Aug 25 00:09:32 BST 2007org.apache.log4j.varia

ErrorHandlerTestCase

public class ErrorHandlerTestCase extends TestCase

Fields Summary
static String
TEMP_A1
static String
TEMP_A2
static String
FILTERED_A1
static String
FILTERED_A2
static String
EXCEPTION1
static String
EXCEPTION2
static String
EXCEPTION3
static String
TEST1_1A_PAT
static String
TEST1_1B_PAT
static String
TEST1_2_PAT
Logger
root
Logger
logger
Constructors Summary
public ErrorHandlerTestCase(String name)


     
    super(name);
  
Methods Summary
voidcommon()

    int i = -1;
 
    logger.debug("Message " + ++i);
    root.debug("Message " + i);        

    logger.info ("Message " + ++i);
    root.info("Message " + i);        

    logger.warn ("Message " + ++i);
    root.warn("Message " + i);        

    logger.error("Message " + ++i);
    root.error("Message " + i);
    
    logger.log(Level.FATAL, "Message " + ++i);
    root.log(Level.FATAL, "Message " + i);    
    
    Exception e = new Exception("Just testing");
    logger.debug("Message " + ++i, e);
    root.debug("Message " + i, e);
    
    logger.error("Message " + ++i, e);
    root.error("Message " + i, e);    

  
public voidsetUp()

    root = Logger.getRootLogger();
    logger = Logger.getLogger("test");
  
public static junit.framework.Testsuite()

    TestSuite suite = new TestSuite();
    suite.addTest(new ErrorHandlerTestCase("test1"));
    return suite;
  
public voidtearDown()

  
    root.getLoggerRepository().resetConfiguration();
  
public voidtest1()

    DOMConfigurator.configure("input/xml/fallback1.xml");
    common();

    ControlFilter cf1 = new ControlFilter(new String[]{TEST1_1A_PAT, TEST1_1B_PAT, 
					       EXCEPTION1, EXCEPTION2, EXCEPTION3});

    ControlFilter cf2 = new ControlFilter(new String[]{TEST1_2_PAT, 
					       EXCEPTION1, EXCEPTION2, EXCEPTION3});

    Transformer.transform(TEMP_A1, FILTERED_A1, new Filter[] {cf1, 
							new LineNumberFilter()});

    Transformer.transform(TEMP_A2, FILTERED_A2, new Filter[] {cf2,
                                      new LineNumberFilter(), new ISO8601Filter()});

    assertTrue(Compare.compare(FILTERED_A1, "witness/dom.A1.1"));
    assertTrue(Compare.compare(FILTERED_A2, "witness/dom.A2.1"));