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 Ceki Gülcü <ce...@qos.ch> on 2005/03/07 11:49:09 UTC

Re: cvs commit: logging-log4j/tests/witness/xml dom.A1.3 dom.A2.3

Do you think it is wise to go into all this trouble?

At 06:35 AM 3/7/2005, carnold@apache.org wrote:
>carnold     2005/03/06 21:35:19
>
>   Modified:    src/java/org/apache/log4j/xml DOMConfigurator.java
>                tests/src/java/org/apache/log4j/xml DOMTest.java
>   Added:       tests/input/xml DOMTest3.xml
>                tests/witness/xml dom.A1.3 dom.A2.3
>   Log:
>   Bug 33870: Restore DOMConfigurator.doConfigure(Element)
>
>   Revision  Changes    Path
>   1.73      +125 
> -8    logging-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java
>
>   Index: DOMConfigurator.java
>   ===================================================================
>   RCS file: 
> /home/cvs/logging-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java,v
>   retrieving revision 1.72
>   retrieving revision 1.73
>   diff -u -r1.72 -r1.73
>   --- DOMConfigurator.java      9 Jan 2005 13:04:17 -0000       1.72
>   +++ DOMConfigurator.java      7 Mar 2005 05:35:18 -0000       1.73
>   @@ -1,12 +1,12 @@
>    /*
>   - * Copyright 1999,2004 The Apache Software Foundation.
>   - *
>   + * Copyright 1999,2005 The Apache Software Foundation.
>   + *
>     * Licensed under the Apache License, Version 2.0 (the "License");
>     * you may not use this file except in compliance with the License.
>     * You may obtain a copy of the License at
>   - *
>   + *
>     *      http://www.apache.org/licenses/LICENSE-2.0
>   - *
>   + *
>     * Unless required by applicable law or agreed to in writing, software
>     * distributed under the License is distributed on an "AS IS" BASIS,
>     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
> implied.
>   @@ -16,14 +16,26 @@
>
>    package org.apache.log4j.xml;
>
>   +import org.apache.log4j.LogManager;
>   +import org.apache.log4j.joran.JoranConfigurator;
>   +import org.apache.log4j.spi.LoggerRepository;
>   +
>   +import org.w3c.dom.Element;
>   +import org.w3c.dom.NamedNodeMap;
>   +import org.w3c.dom.Node;
>   +
>   +import org.xml.sax.SAXException;
>   +import org.xml.sax.helpers.AttributesImpl;
>   +import org.xml.sax.helpers.DefaultHandler;
>   +
>    import java.net.URL;
>
>   -import org.apache.log4j.*;
>   -import org.apache.log4j.joran.JoranConfigurator;
>   +import javax.xml.parsers.SAXParser;
>
>
>    // Contributors:   Mark Womack
>   -//                 Arun Katkere
>   +//                 Arun Katkere
>   +//                 Curt Arnold
>
>    /**
>       Use this class to initialize the log4j environment using a DOM tree.
>   @@ -50,7 +62,6 @@
>       @deprecated Replaced by the much more flexible {@link 
> org.apache.log4j.joran.JoranConfigurator}.
>       @since 0.8.3 */
>    public class DOMConfigurator extends JoranConfigurator {
>   -
>      public static void configure(String file) {
>        JoranConfigurator joran = new JoranConfigurator();
>        joran.doConfigure(file, LogManager.getLoggerRepository());
>   @@ -60,4 +71,110 @@
>        JoranConfigurator joran = new JoranConfigurator();
>        joran.doConfigure(url, LogManager.getLoggerRepository());
>      }
>   +
>   +  /**
>   +   *  Configure log4j using a <code>configuration</code> element.
>   +   * @param element element, may not be null.
>   +  */
>   +  public static void configure(final Element element) {
>   +    DOMConfigurator configurator = new DOMConfigurator();
>   +    configurator.doConfigure(element, LogManager.getLoggerRepository());
>   +  }
>   +
>   +  /**
>   +   *  Configure by taking in an DOM element.
>   +   * @param element configuration element, may not be null.
>   +   * @param repository logger repository.
>   +  */
>   +  public void doConfigure(
>   +    final Element element, final LoggerRepository repository) {
>   +    ParseAction action = new DOMElementParseAction(element);
>   +    doConfigure(action, repository);
>   +  }
>   +
>   +  /**
>   +   *  Class that "parses" a DOM element by replaying the
>   +   * corresponding SAX events.
>   +   */
>   +  private static class DOMElementParseAction implements ParseAction {
>   +    private final Element element;
>   +    private final AttributesImpl attributes = new AttributesImpl();
>   +
>   +    /**
>   +     * Creates an DOMElementParser.
>   +     * @param element configuration element.
>   +     */
>   +    public DOMElementParseAction(final Element element) {
>   +      this.element = element;
>   +    }
>   +
>   +    /**
>   +     * Generates the SAX events corresponding to the document element.
>   +     * @param parser SAX parser, ignored.
>   +     * @param handler content receiver, may not be null.
>   +     * @throws SAXException thrown on content or handling exception.
>   +     */
>   +    public void parse(final SAXParser parser, final DefaultHandler 
> handler)
>   +      throws SAXException {
>   +      handler.startDocument();
>   +      replay(element, handler);
>   +      handler.endDocument();
>   +    }
>   +
>   +    /**
>   +     * Generates the SAX events corresponding to the element.
>   +     *
>   +     * @param element element, may not be null.
>   +     * @param handler content handler, may not be null.
>   +     * @throws SAXException if content error.
>   +     */
>   +    private void replay(final Element element, final DefaultHandler 
> handler)
>   +      throws SAXException {
>   +      String localName = element.getLocalName();
>   +      String nsURI = element.getNamespaceURI();
>   +      String qName = element.getNodeName();
>   +
>   +      if (localName == null) {
>   +        localName = qName;
>   +      }
>   +
>   +      attributes.clear();
>   +
>   +      NamedNodeMap attrNodes = element.getAttributes();
>   +      int attrCount = attrNodes.getLength();
>   +      Node attr;
>   +
>   +      for (int i = 0; i < attrCount; i++) {
>   +        attr = attrNodes.item(i);
>   +
>   +        String attrQName = attr.getNodeName();
>   +        String attrName = attr.getLocalName();
>   +
>   +        if (attrName == null) {
>   +          attrName = attrQName;
>   +        }
>   +
>   +        String attrNsURI = attr.getNamespaceURI();
>   +        String attrValue = attr.getNodeValue();
>   +        attributes.addAttribute(
>   +          attrNsURI, attrName, attrQName, "#PCDATA", attrValue);
>   +      }
>   +
>   +      handler.startElement(nsURI, localName, qName, attributes);
>   +
>   +      for (
>   +        Node child = element.getFirstChild(); child != null;
>   +          child = child.getNextSibling()) {
>   +        //
>   +        //   Joran only inteprets element content,
>   +        //      so unnecessary to playback comments, character data, etc.
>   +        //
>   +        if (child.getNodeType() == Node.ELEMENT_NODE) {
>   +          replay((Element) child, handler);
>   +        }
>   +      }
>   +
>   +      handler.endElement(nsURI, localName, qName);
>   +    }
>   +  }
>    }
>
>
>
>   1.1                  logging-log4j/tests/input/xml/DOMTest3.xml
>
>   Index: DOMTest3.xml
>   ===================================================================
>   <?xml version="1.0" encoding="UTF-8" ?>
>
>   <log4j:configuration xmlns:log4j='http://logging.apache.org/'>
>     <appender name="A1" class="org.apache.log4j.FileAppender">
>
>       <param name="File"   value="output/temp.A1.3" />
>       <param name="Append" value="false" />
>
>       <layout class="org.apache.log4j.PatternLayout">
>         <param name="ConversionPattern" value="%-5p %c{2} - %m%n"/>
>       </layout>
>     </appender>
>
>     <appender name="A2" class="org.apache.log4j.FileAppender">
>       <param name="File" value="output/temp.A2.3" />
>       <param name="Append" value="false" />
>       <layout class="org.apache.log4j.TTCCLayout">
>         <param name="DateFormat" value="ISO8601" />
>       </layout>
>     </appender>
>
>     <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
>     <logger name="org.apache.log4j.joran"><level value="INFO" /></logger>
>     <logger name="org.apache.log4j.joran.action.PriorityAction"><level 
> value="ERROR" /></logger>
>     <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
>     <logger name="org.apache.log4j.FileAppender"><level value="INFO" 
> /></logger>
>     <logger name="org.apache.log4j.xml.DOMConfigurator"><level 
> value="INFO" /></logger>
>
>     <logger name="org.apache.log4j.xml">
>       <level value="debug" />
>       <appender-ref ref="A1" />
>     </logger>
>
>     <root>
>       <priority value ="debug" />
>       <appender-ref ref="A1" />
>       <appender-ref ref="A2" />
>     </root>
>
>   </log4j:configuration>
>
>
>
>   1.2       +150 
> -99   logging-log4j/tests/src/java/org/apache/log4j/xml/DOMTest.java
>
>   Index: DOMTest.java
>   ===================================================================
>   RCS file: 
> /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/xml/DOMTest.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- DOMTest.java      18 Feb 2005 17:23:45 -0000      1.1
>   +++ DOMTest.java      7 Mar 2005 05:35:19 -0000       1.2
>   @@ -1,12 +1,12 @@
>    /*
>   - * Copyright 1999-2005 The Apache Software Foundation.
>   - *
>   + * Copyright 1999,2005 The Apache Software Foundation.
>   + *
>     * Licensed under the Apache License, Version 2.0 (the "License");
>     * you may not use this file except in compliance with the License.
>     * You may obtain a copy of the License at
>   - *
>   + *
>     *      http://www.apache.org/licenses/LICENSE-2.0
>   - *
>   + *
>     * Unless required by applicable law or agreed to in writing, software
>     * distributed under the License is distributed on an "AS IS" BASIS,
>     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
> implied.
>   @@ -16,50 +16,39 @@
>
>    package org.apache.log4j.xml;
>
>   -import java.util.List;
>   -
>   -import junit.framework.Test;
>    import junit.framework.TestCase;
>   -import junit.framework.TestSuite;
>
>   +import org.apache.log4j.Level;
>    import org.apache.log4j.LogManager;
>    import org.apache.log4j.Logger;
>   -import org.apache.log4j.Level;
>    import org.apache.log4j.joran.JoranConfigurator;
>    import org.apache.log4j.spi.ErrorItem;
>   -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;
>   -import org.apache.log4j.util.ISO8601Filter;
>   -import org.apache.log4j.util.Transformer;
>   -import org.apache.log4j.util.Compare;
>   +import org.apache.log4j.util.*;
>   +
>    import java.io.File;
>
>   -public class DOMTest extends TestCase {
>   +import java.util.List;
>   +
>   +import javax.xml.parsers.DocumentBuilder;
>   +import javax.xml.parsers.DocumentBuilderFactory;
>   +
>
>   +public class DOMTest extends TestCase {
>      static String TEMP_A1 = "output/temp.A1";
>      static String TEMP_A2 = "output/temp.A2";
>      static String FILTERED_A1 = "output/filtered.A1";
>      static String FILTERED_A2 = "output/filtered.A2";
>   -
>   -
>      static String EXCEPTION1 = "java.lang.Exception: Just testing";
>      static String EXCEPTION2 = "\\s*at .*\\(.*:\\d{1,4}\\)";
>      static String EXCEPTION3 = "\\s*at .*\\(Native Method\\)";
>   -
>   -  static String TEST1_1A_PAT =
>   -                       "(DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - 
> Message \\d";
>   -
>   -  static String TEST1_1B_PAT = "(DEBUG|INFO |WARN |ERROR|FATAL) root - 
> Message \\d";
>   -
>   -  static String TEST1_2_PAT = "^\\d{4}-\\d{2}-\\d{2} 
> \\d{2}:\\d{2}:\\d{2},\\d{3} "+
>   -                        "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - 
> Message \\d";
>   -
>   -
>   -
>   -  Logger root;
>   +  static String TEST1_1A_PAT =
>   +    "(DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - Message \\d";
>   +  static String TEST1_1B_PAT =
>   +    "(DEBUG|INFO |WARN |ERROR|FATAL) root - Message \\d";
>   +  static String TEST1_2_PAT =
>   +    "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} "
>   +    + "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d";
>   +  Logger root;
>      Logger logger;
>
>      public DOMTest(String name) {
>   @@ -70,8 +59,8 @@
>        root = Logger.getRootLogger();
>        logger = Logger.getLogger(DOMTest.class);
>      }
>   -
>   -  public void tearDown() {
>   +
>   +  public void tearDown() {
>        root.getLoggerRepository().resetConfiguration();
>      }
>
>   @@ -82,20 +71,29 @@
>        dumpErrors(jc.getErrorList());
>        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(),
>   -              new SunReflectFilter(),
>   -              new JunitTestRunnerFilter()});
>   -
>   -    Transformer.transform(TEMP_A2, FILTERED_A2, new Filter[] {cf2,
>   -                                      new LineNumberFilter(), new 
> ISO8601Filter(),
>   -                                      new SunReflectFilter(), new 
> JunitTestRunnerFilter()});
>   +    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(), new SunReflectFilter(),
>   +        new JunitTestRunnerFilter()
>   +      });
>   +
>   +    Transformer.transform(
>   +      TEMP_A2, FILTERED_A2,
>   +      new Filter[] {
>   +        cf2, new LineNumberFilter(), new ISO8601Filter(),
>   +        new SunReflectFilter(), new JunitTestRunnerFilter()
>   +      });
>
>        assertTrue(Compare.compare(FILTERED_A1, "witness/xml/dom.A1.1"));
>        assertTrue(Compare.compare(FILTERED_A2, "witness/xml/dom.A2.1"));
>   @@ -103,82 +101,135 @@
>
>      /**
>       * Identical test except that backslashes are used instead of
>   -   * forward slashes on all file specifications.  Test is
>   +   * forward slashes on all file specifications.  Test is
>       * only applicable to Windows.
>   -   *
>   +   *
>       * @throws Exception Any exception will cause test to fail
>       */
>      public void test2() throws Exception {
>   -     if (File.separatorChar == '\\') {
>   -         JoranConfigurator jc = new JoranConfigurator();
>   -         jc.doConfigure("input\\xml\\DOMTest2.xml", 
> LogManager.getLoggerRepository());
>   -         dumpErrors(jc.getErrorList());
>   -         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 + ".2", FILTERED_A1 + ".2", new 
> Filter[] {cf1,
>   -                                                             new 
> LineNumberFilter(),
>   -                   new SunReflectFilter(),
>   -                   new JunitTestRunnerFilter()});
>   -
>   -         Transformer.transform(TEMP_A2 + ".2", FILTERED_A2 + ".2", new 
> Filter[] {cf2,
>   -                                           new LineNumberFilter(), new 
> ISO8601Filter(),
>   -                                           new SunReflectFilter(), new 
> JunitTestRunnerFilter()});
>   -
>   -         assertTrue(Compare.compare(FILTERED_A1, "witness/xml/dom.A1.2"));
>   -         assertTrue(Compare.compare(FILTERED_A2, "witness/xml/dom.A2.2"));
>   -     }
>   -  }
>   -
>   -
>   -
>   +    if (File.separatorChar == '\\') {
>   +      JoranConfigurator jc = new JoranConfigurator();
>   +      jc.doConfigure(
>   +        "input\\xml\\DOMTest2.xml", LogManager.getLoggerRepository());
>   +      dumpErrors(jc.getErrorList());
>   +      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 + ".2", FILTERED_A1 + ".2",
>   +        new Filter[] {
>   +          cf1, new LineNumberFilter(), new SunReflectFilter(),
>   +          new JunitTestRunnerFilter()
>   +        });
>   +
>   +      Transformer.transform(
>   +        TEMP_A2 + ".2", FILTERED_A2 + ".2",
>   +        new Filter[] {
>   +          cf2, new LineNumberFilter(), new ISO8601Filter(),
>   +          new SunReflectFilter(), new JunitTestRunnerFilter()
>   +        });
>   +
>   +      assertTrue(Compare.compare(FILTERED_A1 + ".2", 
> "witness/xml/dom.A1.2"));
>   +      assertTrue(Compare.compare(FILTERED_A2 + ".2", 
> "witness/xml/dom.A2.2"));
>   +    }
>   +  }
>   +
>   +  /**
>   +   * This test checks the implementation of 
> DOMConfigurator.doConfigure(Element)
>   +   * which is provided for compatibility with log4j 1.2 and used by 
> excalibur-logging.
>   +   *
>   +   * @deprecated This test checks a deprecated method and so needs to 
> be deprecated itself.
>   +   *
>   +   * @throws Exception on failure to find parser, etc.
>   +   */
>   +  public void test3() throws Exception {
>   +    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
>   +    factory.setNamespaceAware(true);
>   +
>   +    DocumentBuilder builder = factory.newDocumentBuilder();
>   +    org.w3c.dom.Document doc =
>   +      builder.parse(new File("input/xml/DOMTest3.xml"));
>   +
>   +    DOMConfigurator domConfig = new DOMConfigurator();
>   +    domConfig.doConfigure(
>   +      doc.getDocumentElement(), LogManager.getLoggerRepository());
>   +
>   +    dumpErrors(domConfig.getErrorList());
>   +    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 + ".3", FILTERED_A1 + ".3",
>   +      new Filter[] {
>   +        cf1, new LineNumberFilter(), new SunReflectFilter(),
>   +        new JunitTestRunnerFilter()
>   +      });
>   +
>   +    Transformer.transform(
>   +      TEMP_A2 + ".3", FILTERED_A2 + ".3",
>   +      new Filter[] {
>   +        cf2, new LineNumberFilter(), new ISO8601Filter(),
>   +        new SunReflectFilter(), new JunitTestRunnerFilter()
>   +      });
>   +
>   +    assertTrue(Compare.compare(FILTERED_A1 + ".3", 
> "witness/xml/dom.A1.3"));
>   +    assertTrue(Compare.compare(FILTERED_A2 + ".3", 
> "witness/xml/dom.A2.3"));
>   +  }
>   +
>      void common() {
>        int i = -1;
>   -
>   +
>        logger.debug("Message " + ++i);
>   -    root.debug("Message " + i);
>   +    root.debug("Message " + i);
>
>   -    logger.info ("Message " + ++i);
>   -    root.info("Message " + i);
>   +    logger.info("Message " + ++i);
>   +    root.info("Message " + i);
>
>   -    logger.warn ("Message " + ++i);
>   -    root.warn("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);
>   -
>   +    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);
>   +    root.error("Message " + i, e);
>      }
>
>      void dumpErrors(List errorList) {
>   -    for(int i = 0; i < errorList.size(); i++) {
>   +    for (int i = 0; i < errorList.size(); i++) {
>          ErrorItem ei = (ErrorItem) errorList.get(i);
>          System.out.println(ei);
>   +
>          Throwable t = ei.getException();
>   -      if(t != null) {
>   +
>   +      if (t != null) {
>            t.printStackTrace(System.out);
>          }
>        }
>      }
>   -
>   -  public static Test suite() {
>   -    TestSuite suite = new TestSuite();
>   -    suite.addTest(new DOMTest("test1"));
>   -    //suite.addTest(new DOMTest("test2"));
>   -    return suite;
>   -  }
>   -
>    }
>
>
>
>   1.1                  logging-log4j/tests/witness/xml/dom.A1.3
>
>   Index: dom.A1.3
>   ===================================================================
>   DEBUG xml.DOMTest - Message 0
>   DEBUG xml.DOMTest - Message 0
>   DEBUG root - Message 0
>   INFO  xml.DOMTest - Message 1
>   INFO  xml.DOMTest - Message 1
>   INFO  root - Message 1
>   WARN  xml.DOMTest - Message 2
>   WARN  xml.DOMTest - Message 2
>   WARN  root - Message 2
>   ERROR xml.DOMTest - Message 3
>   ERROR xml.DOMTest - Message 3
>   ERROR root - Message 3
>   FATAL xml.DOMTest - Message 4
>   FATAL xml.DOMTest - Message 4
>   FATAL root - Message 4
>   DEBUG xml.DOMTest - Message 5
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>   DEBUG xml.DOMTest - Message 5
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>   DEBUG root - Message 5
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>   ERROR xml.DOMTest - Message 6
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>   ERROR xml.DOMTest - Message 6
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>   ERROR root - Message 6
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>
>
>
>   1.1                  logging-log4j/tests/witness/xml/dom.A2.3
>
>   Index: dom.A2.3
>   ===================================================================
>    [main] DEBUG org.apache.log4j.xml.DOMTest - Message 0
>    [main] DEBUG root - Message 0
>    [main] INFO org.apache.log4j.xml.DOMTest - Message 1
>    [main] INFO root - Message 1
>    [main] WARN org.apache.log4j.xml.DOMTest - Message 2
>    [main] WARN root - Message 2
>    [main] ERROR org.apache.log4j.xml.DOMTest - Message 3
>    [main] ERROR root - Message 3
>    [main] FATAL org.apache.log4j.xml.DOMTest - Message 4
>    [main] FATAL root - Message 4
>    [main] DEBUG org.apache.log4j.xml.DOMTest - Message 5
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>    [main] DEBUG root - Message 5
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>    [main] ERROR org.apache.log4j.xml.DOMTest - Message 6
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>    [main] ERROR root - Message 6
>   java.lang.Exception: Just testing
>         at org.apache.log4j.xml.DOMTest.common(X)
>         at org.apache.log4j.xml.DOMTest.test3(X)
>         at java.lang.reflect.Method.invoke(X)
>         at junit.framework.TestCase.runTest(X)
>         at junit.framework.TestCase.runBare(X)
>         at junit.framework.TestResult$1.protect(X)
>         at junit.framework.TestResult.runProtected(X)
>         at junit.framework.TestResult.run(X)
>         at junit.framework.TestCase.run(X)
>         at junit.framework.TestSuite.runTest(X)
>         at junit.framework.TestSuite.run(X)
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-dev-help@logging.apache.org

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



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


Re: cvs commit: logging-log4j/tests/witness/xml dom.A1.3 dom.A2.3

Posted by Curt Arnold <ca...@apache.org>.
On Mar 7, 2005, at 4:49 AM, Ceki Gülcü wrote:

> Do you think it is wise to go into all this trouble?
>


DOMConfiguration.doConfigure(Element) is used within Apache Excalibur  
(http://cvs.apache.org/viewcvs.cgi/excalibur/trunk/containerkit/logger/ 
src/java/org/apache/avalon/excalibur/logger/ 
Log4JConfLoggerManager.java?root=Apache-SVN&rev=22712&view=markup) to  
configure log4j from an in-memory DOM tree.  There is not a simple  
modification that would allow that code to work with both 1.2 and 1.3  
without those methods being restored.

The method was clearly part of the log4j 1.2 API (that is it wasn't  
some internal method that wasn't intended for use by end-users) and it  
served a useful and unique purpose (configuration from a subtree of an  
larger document).  By restoring that part of our API, we prevent  
Excalibur from working only with 1.2 or writing an equivalently complex  
workaround.  In addition to restoring Excalibur, it should also prevent  
that issue from reappearing when more people start evaluating log4j  
1.3.

The actual implementation was fairly simple and clear.  The bulk of the  
commit was cut and paste from the existing DOMConfigurator tests.  It  
would have been nice if the tests weren't so bulky, but it would have  
been a lot more effort to try to write new more compact tests.


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