FileDocCategorySizeDatePackage
PatternLayoutTestCase.javaAPI DocApache log4j 1.2.1512893Sat Aug 25 00:09:34 BST 2007org.apache.log4j

PatternLayoutTestCase

public class PatternLayoutTestCase extends TestCase

Fields Summary
static String
TEMP
static String
FILTERED
Logger
root
Logger
logger
static String
EXCEPTION1
static String
EXCEPTION2
static String
EXCEPTION3
static String
EXCEPTION4
static String
EXCEPTION5
static String
PAT0
static String
PAT1
static String
PAT2
static String
PAT3
static String
PAT4
static String
PAT5
static String
PAT6
static String
PAT11a
static String
PAT11b
static String
PAT12
static String
PAT13
static String
PAT14
Constructors Summary
public PatternLayoutTestCase(String name)


     
    super(name);
  
Methods Summary
voidcommon()

    String oldThreadName = Thread.currentThread().getName();
    Thread.currentThread().setName("main");

    int i = -1;

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

    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.trace("Message " + ++i, e);
    logger.debug("Message " + ++i, e);
    logger.info("Message " + ++i, e);
    logger.warn("Message " + ++i , e);
    logger.error("Message " + ++i, e);
    logger.log(Level.FATAL, "Message " + ++i, e);

    Thread.currentThread().setName(oldThreadName);
  
public voidsetUp()

    root = Logger.getRootLogger();
    logger = Logger.getLogger(PatternLayoutTestCase.class);
  
public static junit.framework.Testsuite()

    TestSuite suite = new TestSuite();
    suite.addTest(new PatternLayoutTestCase("test1"));
    suite.addTest(new PatternLayoutTestCase("test2"));
    suite.addTest(new PatternLayoutTestCase("test3"));
    suite.addTest(new PatternLayoutTestCase("test4"));
    suite.addTest(new PatternLayoutTestCase("test5"));
    suite.addTest(new PatternLayoutTestCase("test6"));
    suite.addTest(new PatternLayoutTestCase("test7"));
    suite.addTest(new PatternLayoutTestCase("test8"));
    suite.addTest(new PatternLayoutTestCase("test9"));
    suite.addTest(new PatternLayoutTestCase("test10"));
    suite.addTest(new PatternLayoutTestCase("test11"));
    suite.addTest(new PatternLayoutTestCase("test12"));
    suite.addTest(new PatternLayoutTestCase("test13"));
    suite.addTest(new PatternLayoutTestCase("test14"));
    return suite;
  
public voidtearDown()

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

    PropertyConfigurator.configure("input/patternLayout1.properties");
    common();
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        new LineNumberFilter(), new SunReflectFilter(),
        new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.1"));
  
public voidtest10()

    PropertyConfigurator.configure("input/patternLayout10.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT6, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new SunReflectFilter(),
        new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.10"));
  
public voidtest11()

    PropertyConfigurator.configure("input/patternLayout11.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT11a, PAT11b, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new SunReflectFilter(),
        new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.11"));
  
public voidtest12()

    PropertyConfigurator.configure("input/patternLayout12.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT12, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new SunReflectFilter(),
        new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.12"));
  
public voidtest13()

    PropertyConfigurator.configure("input/patternLayout13.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT13, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new SunReflectFilter(),
        new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.13"));
  
public voidtest14()

    PropertyConfigurator.configure("input/patternLayout14.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT14, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new SunReflectFilter(),
        new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.14"));
  
public voidtest2()

    PropertyConfigurator.configure("input/patternLayout2.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT1, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new ISO8601Filter(),
        new SunReflectFilter(), new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.2"));
  
public voidtest3()

    PropertyConfigurator.configure("input/patternLayout3.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT1, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new ISO8601Filter(),
        new SunReflectFilter(), new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.3"));
  
public voidtest4()

    PropertyConfigurator.configure("input/patternLayout4.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT2, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new AbsoluteDateAndTimeFilter(),
        new SunReflectFilter(), new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.4"));
  
public voidtest5()

    PropertyConfigurator.configure("input/patternLayout5.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT2, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new AbsoluteDateAndTimeFilter(),
        new SunReflectFilter(), new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.5"));
  
public voidtest6()

    PropertyConfigurator.configure("input/patternLayout6.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT3, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new AbsoluteTimeFilter(),
        new SunReflectFilter(), new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.6"));
  
public voidtest7()

    PropertyConfigurator.configure("input/patternLayout7.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT3, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new AbsoluteTimeFilter(),
        new SunReflectFilter(), new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.7"));
  
public voidtest8()

    PropertyConfigurator.configure("input/patternLayout8.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT4, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new RelativeTimeFilter(),
        new SunReflectFilter(), new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.8"));
  
public voidtest9()

    PropertyConfigurator.configure("input/patternLayout9.properties");
    common();
    ControlFilter cf1 = new ControlFilter(new String[]{PAT5, EXCEPTION1, 
						       EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
    Transformer.transform(
      TEMP, FILTERED,
      new Filter[] {
        cf1, new LineNumberFilter(), new SunReflectFilter(),
        new JunitTestRunnerFilter()
      });
    assertTrue(Compare.compare(FILTERED, "witness/patternLayout.9"));