hillion     02/05/17 06:36:11

  Modified:    test-resources/org/apache/batik/dom unitTesting.xml
  Added:       test-resources/org/apache/batik/dom dummyXML4.xml
               test-sources/org/apache/batik/dom
                        GetElementsByTagNameNSTest.java
  Log:
  Added a test for the bug found in getElementByTagNameNS().
  
  Revision  Changes    Path
  1.7       +11 -1     xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml
  
  Index: unitTesting.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- unitTesting.xml   12 Apr 2002 17:22:17 -0000      1.6
  +++ unitTesting.xml   17 May 2002 13:36:11 -0000      1.7
  @@ -9,7 +9,7 @@
   <!-- ========================================================================= -->
   <!-- @author [EMAIL PROTECTED]                                         -->
   <!-- @author [EMAIL PROTECTED]                                                  -->
  -<!-- @version $Id: unitTesting.xml,v 1.6 2002/04/12 17:22:17 vhardy Exp $  -->
  +<!-- @version $Id: unitTesting.xml,v 1.7 2002/05/17 13:36:11 hillion Exp $  -->
   <!-- ========================================================================= -->
   <testSuite id="dom.unitTesting" name="org.apache.batik.dom package - Unit Testing">
   
  @@ -109,6 +109,16 @@
           <arg class="java.lang.String"
                value="test-resources/org/apache/batik/dom/dummyXML2.xml"/>
           <arg class="java.lang.String" value="doc"/>
  +    </test>
  +
  +    <!-- ========================================================================== 
-->
  +    <!-- getElementsByTagNameNS test                                                
-->
  +    <!-- ========================================================================== 
-->
  +    <test id="getElementsByTagNameNS" 
class="org.apache.batik.dom.GetElementsByTagNameNSTest" >
  +        <arg class="java.lang.String"
  +             value="test-resources/org/apache/batik/dom/dummyXML4.xml"/>
  +        <arg class="java.lang.String" value="doc" />
  +        <arg class="java.lang.String" value="elt4" />
       </test>
   
   </testSuite>
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/dom/dummyXML4.xml
  
  Index: dummyXML4.xml
  ===================================================================
  <doc id="root" attr="value1">
    <elt1/>
    <elt2 id="elt2" attr2="value2" xmlns="">
      Content
    </elt2>
    <elt3><elt4/></elt3>
  </doc>
  
  
  
  1.1                  
xml-batik/test-sources/org/apache/batik/dom/GetElementsByTagNameNSTest.java
  
  Index: GetElementsByTagNameNSTest.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.dom;
  
  import org.w3c.dom.*;
  
  import java.io.*;
  import java.net.*;
  import org.apache.batik.dom.util.*;
  import org.apache.batik.util.*;
  import org.apache.batik.test.*;
  
  /**
   * This class tests the getElementsByTagNameNS method.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: GetElementsByTagNameNSTest.java,v 1.1 2002/05/17 13:36:11 hillion 
Exp $
   */
  public class GetElementsByTagNameNSTest extends AbstractTest {
      protected String testFileName;
      protected String rootTag;
      protected String tagName;
  
      public GetElementsByTagNameNSTest(String file,
                                        String root,
                                        String tag) {
          testFileName = file;
          rootTag = root;
          tagName = tag;
      }
  
      public TestReport runImpl() throws Exception {
          String parser =
              XMLResourceDescriptor.getXMLParserClassName();
  
          DocumentFactory df 
              = new SAXDocumentFactory
              (GenericDOMImplementation.getDOMImplementation(), parser);
  
          File f = (new File(testFileName));
          URL url = f.toURL();
          Document doc = df.createDocument(null,
                                           rootTag,
                                           url.toString(),
                                           url.openStream());
          
          Element root = doc.getDocumentElement();
          NodeList lst = root.getElementsByTagNameNS(null, tagName);
  
          if (lst.getLength() != 1) {
              DefaultTestReport report = new DefaultTestReport(this);
              report.setErrorCode("error.getElementByTagNameNS.failed");
              report.setPassed(false);
              return report;
          }
          
          Node n;
          while ((n = root.getFirstChild()) != null) {
              root.removeChild(n);
          }
  
          if (lst.getLength() != 0) {
              DefaultTestReport report = new DefaultTestReport(this);
              report.setErrorCode("error.getElementByTagNameNS.failed");
              report.setPassed(false);
              return report;
          }
  
          return reportSuccess();
      }
      
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to