jakarta-commons  

[SUBMIT] Digester matching rules test case

robert burrell donkin
Tue, 04 Sep 2001 15:47:02 -0700

this is an additional test case aimed at matching rules.
it takes the (two) original matching rules tests defined in the basic 
DigesterTestCase
and adds another couple.
the main reason for separating out from the basic DigesterTestCase is that 
this class should allow subclasses to test extensions of the basic 
matching rules.

i was going to remove the duplicate tests from DigesterTestCase but i don'
t see any real harm in keeping them around (for the moment).

i couldn't help noticing that the build.xml uses a <java> (ant) task to 
perform the tests. the latest version of ant has quite a nice task that 
does junit testing that i've used before and i think works pretty well. 
the patch for the build script uses the existing method but i'd be willing 
to provide a patch converting it to use the ant junit tasks if people 
think that's a good idea.

- robert

Index: digester/src/test/org/apache/commons/digester/TestRule.java
===================================================================
RCS file: 
/home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/TestRule.java,v
retrieving revision 1.1
diff -u -r1.1 TestRule.java
--- digester/src/test/org/apache/commons/digester/TestRule.java 2001/08/08 03:21:17    
 1.1
+++ digester/src/test/org/apache/commons/digester/TestRule.java 2001/09/04 21:27:34
@@ -82,7 +82,7 @@
      * Base constructor.
      *
      * @param digester The digester with which this rule is associated
-     * @param identifier Used to tell which TestRule is which.
+     * @param identifier Used to tell which TestRule is which
      */
     public TestRule(Digester digester, String identifier) {
 
@@ -91,7 +91,20 @@
     }
     
     
-    
+    /**
+     * Constructor sets namespace uri.
+     *
+     * @param digester The digester with which this rule is associated
+     * @param identifier Used to tell which TestRule is which
+     * @param namespaceURI Set rule namespace
+     */
+    public TestRule(Digester digester, String identifier,String namespaceURI) {
+
+       super(digester);
+        this.identifier=identifier;
+        setNamespaceURI(namespaceURI);
+    }
+        
 
     // ------------------------------------------------ Methods
     
Index: digester/build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/digester/build.xml,v
retrieving revision 1.7
diff -u -r1.7 build.xml
--- digester/build.xml  2001/08/20 21:59:43     1.7
+++ digester/build.xml  2001/09/04 21:26:24
@@ -224,7 +224,8 @@
 
   <target name="test" depends="compile.tests,
                                test.digester,
-                               test.rule
+                               test.rule,
+                               test.matching
                               "
    description="Run all unit test cases">
   </target>
@@ -260,6 +261,15 @@
     </java>
   </target>
 
+  <target name="test.matching" depends="compile.tests"
+   description="Run rule Digester unit tests ...">
+    <echo message="Running Rules Matching tests ..."/>
+    <java classname="${test.runner}" fork="yes"
+        failonerror="${test.failonerror}">
+      <arg value="org.apache.commons.digester.RulesBaseTestCase"/>
+      <classpath refid="test.classpath"/>
+    </java>
+  </target>
 
 
 </project>

RulesBaseTestCase.java