You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ce...@apache.org on 2003/09/17 19:02:52 UTC

cvs commit: jakarta-log4j/src/java/org/apache/log4j PatternLayout.java

ceki        2003/09/17 10:02:52

  Modified:    tests/src/java/org/apache/log4j/helpers
                        PatternParserTestCase.java
               tests/witness dom.A2.1 dom.A1.1
               tests/src/java/org/apache/log4j/xml DOMTestCase.java
               tests/input patternLayout1.properties
               src/java/org/apache/log4j/xml DOMConfigurator.java
               src/java/org/apache/log4j PatternLayout.java
  Log:
  
  - Many tests (but not all run green).
  
  Given the recent changes to PatternLayout, it now requires that the 
  activateOptions be called. Otherwise, the conversion pattern settings 
  have no effect.
  
  DOMConfigurator had a bug whereby it forgot to call activateOptiions on
  nested components. Now it does call activateOptions on nested components.
  
  
  Revision  Changes    Path
  1.3       +11 -0     jakarta-log4j/tests/src/java/org/apache/log4j/helpers/PatternParserTestCase.java
  
  Index: PatternParserTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/helpers/PatternParserTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PatternParserTestCase.java	9 Oct 2002 22:50:08 -0000	1.2
  +++ PatternParserTestCase.java	17 Sep 2003 17:02:52 -0000	1.3
  @@ -71,42 +71,53 @@
       root.debug("starting mdc pattern test");
    
       layout.setConversionPattern(mdcMsgPattern1);
  +    layout.activateOptions();
       root.debug("empty mdc, no key specified in pattern");
       
       layout.setConversionPattern(mdcMsgPattern2);
  +    layout.activateOptions();
       root.debug("empty mdc, key1 in pattern");
       
       layout.setConversionPattern(mdcMsgPattern3);
  +    layout.activateOptions();
       root.debug("empty mdc, key2 in pattern");
       
       layout.setConversionPattern(mdcMsgPattern4);
  +    layout.activateOptions();
       root.debug("empty mdc, key3 in pattern");
       
       layout.setConversionPattern(mdcMsgPattern5);
  +    layout.activateOptions();
       root.debug("empty mdc, key1, key2, and key3 in pattern");
   
       MDC.put("key1", "value1");
       MDC.put("key2", "value2");
   
       layout.setConversionPattern(mdcMsgPattern1);
  +    layout.activateOptions();
       root.debug("filled mdc, no key specified in pattern");
       
       layout.setConversionPattern(mdcMsgPattern2);
  +    layout.activateOptions();
       root.debug("filled mdc, key1 in pattern");
       
       layout.setConversionPattern(mdcMsgPattern3);
  +    layout.activateOptions();
       root.debug("filled mdc, key2 in pattern");
       
       layout.setConversionPattern(mdcMsgPattern4);
  +    layout.activateOptions();
       root.debug("filled mdc, key3 in pattern");
       
       layout.setConversionPattern(mdcMsgPattern5);
  +    layout.activateOptions();
       root.debug("filled mdc, key1, key2, and key3 in pattern");
   
       MDC.remove("key1");
       MDC.remove("key2");
   
       layout.setConversionPattern(msgPattern);
  +    layout.activateOptions();
       root.debug("finished mdc pattern test");
   
       assertTrue(Compare.compare(OUTPUT_FILE+"_mdc", WITNESS_FILE+"_mdc"));
  
  
  
  1.5       +0 -8      jakarta-log4j/tests/witness/dom.A2.1
  
  Index: dom.A2.1
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/tests/witness/dom.A2.1,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- dom.A2.1	14 Nov 2002 08:48:40 -0000	1.4
  +++ dom.A2.1	17 Sep 2003 17:02:52 -0000	1.5
  @@ -21,8 +21,6 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
    [main] DEBUG root - Message 5
   java.lang.Exception: Just testing
   	at org.apache.log4j.xml.DOMTestCase.common(X)
  @@ -36,8 +34,6 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
    [main] ERROR org.apache.log4j.xml.DOMTestCase - Message 6
   java.lang.Exception: Just testing
   	at org.apache.log4j.xml.DOMTestCase.common(X)
  @@ -51,8 +47,6 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
    [main] ERROR root - Message 6
   java.lang.Exception: Just testing
   	at org.apache.log4j.xml.DOMTestCase.common(X)
  @@ -66,5 +60,3 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
  
  
  
  1.4       +0 -12     jakarta-log4j/tests/witness/dom.A1.1
  
  Index: dom.A1.1
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/tests/witness/dom.A1.1,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- dom.A1.1	14 Nov 2002 08:48:40 -0000	1.3
  +++ dom.A1.1	17 Sep 2003 17:02:52 -0000	1.4
  @@ -26,8 +26,6 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
   DEBUG xml.DOMTestCase - Message 5
   java.lang.Exception: Just testing
   	at org.apache.log4j.xml.DOMTestCase.common(X)
  @@ -41,8 +39,6 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
   DEBUG root - Message 5
   java.lang.Exception: Just testing
   	at org.apache.log4j.xml.DOMTestCase.common(X)
  @@ -56,8 +52,6 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
   ERROR xml.DOMTestCase - Message 6
   java.lang.Exception: Just testing
   	at org.apache.log4j.xml.DOMTestCase.common(X)
  @@ -71,8 +65,6 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
   ERROR xml.DOMTestCase - Message 6
   java.lang.Exception: Just testing
   	at org.apache.log4j.xml.DOMTestCase.common(X)
  @@ -86,8 +78,6 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
   ERROR root - Message 6
   java.lang.Exception: Just testing
   	at org.apache.log4j.xml.DOMTestCase.common(X)
  @@ -101,5 +91,3 @@
   	at junit.framework.TestCase.run(X)
   	at junit.framework.TestSuite.runTest(X)
   	at junit.framework.TestSuite.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(X)
  -	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(X)
  
  
  
  1.8       +3 -3      jakarta-log4j/tests/src/java/org/apache/log4j/xml/DOMTestCase.java
  
  Index: DOMTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/xml/DOMTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DOMTestCase.java	13 Nov 2002 16:44:58 -0000	1.7
  +++ DOMTestCase.java	17 Sep 2003 17:02:52 -0000	1.8
  @@ -8,6 +8,7 @@
   import org.apache.log4j.Logger;
   import org.apache.log4j.Level;
   import org.apache.log4j.util.Filter;
  +import org.apache.log4j.util.JunitTestRunnerFilter;
   import org.apache.log4j.util.LineNumberFilter;
   import org.apache.log4j.util.SunReflectFilter;
   import org.apache.log4j.util.ControlFilter;
  @@ -64,12 +65,11 @@
   					       EXCEPTION1, EXCEPTION2, EXCEPTION3});
   
       Transformer.transform(TEMP_A1, FILTERED_A1, new Filter[] {cf1, 
  -							new LineNumberFilter(),
  -                                                        new SunReflectFilter()});
  +							new LineNumberFilter(), new SunReflectFilter(), new JunitTestRunnerFilter()});
   
       Transformer.transform(TEMP_A2, FILTERED_A2, new Filter[] {cf2,
                                         new LineNumberFilter(), new ISO8601Filter(),
  -                                      new SunReflectFilter()});
  +                                      new SunReflectFilter(), new JunitTestRunnerFilter()});
   
       assertTrue(Compare.compare(FILTERED_A1, "witness/dom.A1.1"));
       assertTrue(Compare.compare(FILTERED_A2, "witness/dom.A2.1"));
  
  
  
  1.3       +0 -1      jakarta-log4j/tests/input/patternLayout1.properties
  
  Index: patternLayout1.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/tests/input/patternLayout1.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- patternLayout1.properties	17 Sep 2003 16:03:02 -0000	1.2
  +++ patternLayout1.properties	17 Sep 2003 17:02:52 -0000	1.3
  @@ -1,4 +1,3 @@
  -log4j.debug=true
   log4j.rootCategory=DEBUG, testAppender
   log4j.appender.testAppender=org.apache.log4j.FileAppender
   log4j.appender.testAppender.file=output/temp
  
  
  
  1.59      +9 -0      jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java
  
  Index: DOMConfigurator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- DOMConfigurator.java	11 Sep 2003 17:00:42 -0000	1.58
  +++ DOMConfigurator.java	17 Sep 2003 17:02:52 -0000	1.59
  @@ -299,6 +299,7 @@
   
       Object nestedComponent = null;
   
  +    // instantiate the nested component
       try {
         nestedComponent = Loader.loadClass(className).newInstance();
       } catch (Exception e) {
  @@ -308,6 +309,8 @@
         return;
       }
   
  +    // set the parameters of the nested component and/or configure the
  +    // nested compoments nested within
       NodeList children = nestedElement.getChildNodes();
       final int length = children.getLength();
       PropertySetter nestedBean = new PropertySetter(nestedComponent);
  @@ -340,6 +343,12 @@
           configureNestedComponent(nestedBean, currentElement);
         }
       }
  +    
  +    // once all the options are set, activate the nested component
  +    if(nestedComponent instanceof OptionHandler) { 
  +     ((OptionHandler)nestedComponent).activateOptions(); 
  +    } 
  +
   
       // Now let us attach the component
       switch (containmentType) {
  
  
  
  1.22      +2 -1      jakarta-log4j/src/java/org/apache/log4j/PatternLayout.java
  
  Index: PatternLayout.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/PatternLayout.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- PatternLayout.java	12 Sep 2003 18:24:26 -0000	1.21
  +++ PatternLayout.java	17 Sep 2003 17:02:52 -0000	1.22
  @@ -506,7 +506,8 @@
     }
   
     /**
  -     Does not do anything as options become effective
  +    Activates the conversion pattern. Do not forget to call this method after
  +    you change the parameters of the PatternLayout instance.
     */
     public void activateOptions() {
       PatternParser patternParser = createPatternParser(conversionPattern);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org