Hi,

Here's a patch to build.xml that forces all log objects to be NoOpLog
when running tests. This suppresses all the annoying output currently
generated.

Setting "suppressLogOutputDuringTests=false" in a build.properties file
will re-enable logging during tests again.

There might be a more compact way of doing this in the build.xml file;
ant specialists are welcome to optimise. In particular, if the
<condition> tag can be used outside a <target> tag, that would help.

Also attached is a patch to remove System.out.println(...) calls from
some of the unit tests.

Regards,

Simon
Index: build.xml
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/build.xml,v
retrieving revision 1.47
diff -u -r1.47 build.xml
--- build.xml	4 Oct 2003 12:26:51 -0000	1.47
+++ build.xml	8 Oct 2003 03:03:45 -0000
@@ -99,6 +99,14 @@
 
 <!-- ========== Test Execution Defaults =================================== -->
 
+  <property name="suppressLogOutputDuringTests" value="true"/>
+  <property name="log.factoryopt" value="org.apache.commons.logging.Log"/>
+  <property name="log.noop" value="org.apache.commons.logging.impl.NoOpLog"/>
+  <property name="log.class" value="${log.noop}"/>
+  
+  <!--
+  <property name="logclass" value="org.apache.commons.logging.impl.NoOpLog"/>
+  -->
 
   <!-- Construct unit test classpath -->
   <path id="test.classpath">
@@ -272,8 +280,12 @@
   <target name="test.factory" depends="compile.tests"
    description="Run tests for loading Digester rules from XML ...">
     <echo message="Running factory create tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.TestFactoryCreate"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -282,8 +294,12 @@
   <target name="test.xmlrules" depends="compile.tests"
    description="Run tests for loading Digester rules from XML ...">
     <echo message="Running xmlrules tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.xmlrules.DigesterLoaderTestSuite"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -293,8 +309,12 @@
   <target name="test.bpsr" depends="compile.tests"
    description="Run tests for BeanPropertySetterRule ...">
     <echo message="Running BeanPropertySetterRule tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.BeanPropertySetterRuleTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -304,8 +324,12 @@
   <target name="test.callmethod" depends="compile.tests"
    description="Run tests for CallMethodRule and CallParamRule ...">
     <echo message="Running CallMethodRule tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.CallMethodRuleTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -314,8 +338,12 @@
   <target name="test.objectparam" depends="compile.tests"
    description="Run tests for ObjectParamRule ...">
     <echo message="Running ObjectParamRule tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.ObjectParamRuleTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -324,8 +352,12 @@
   <target name="test.digester" depends="compile.tests"
    description="Run basic Digester unit tests ...">
     <echo message="Running basic Digester tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.DigesterTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -335,8 +367,12 @@
   <target name="test.matching" depends="compile.tests"
    description="Run rule Digester test cases">
     <echo message="Running rule Digester tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.RulesBaseTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -345,8 +381,12 @@
   <target name="test.regex" depends="compile.tests"
    description="Run tests for RegexRules">
     <echo message="Running tests for RegexRules ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.RegexRulesTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -355,8 +395,12 @@
   <target name="test.wdrules" depends="compile.tests"
    description="Run tests for WithDefaultsRulesWrapper">
     <echo message="Running tests for WithDefaultsRulesWrapper ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.WDRulesWrapperTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -365,8 +409,12 @@
   <target name="test.matching.extended" depends="compile.tests"
    description="Run rule Digester extended test cases">
     <echo message="Running rule Digester tests for ExtendedBaseRules ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.EBRTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -376,8 +424,12 @@
   <target name="test.rss" depends="compile.tests"
    description="Run RSSDigester test cases">
     <echo message="Running RSSDigester tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="org.apache.commons.digester.rss.RSSDigester"
                fork="yes">
+      <jvmarg value="-D${logopt}"/>
       <classpath refid="rss.classpath"/>
     </java>
   </target>
@@ -386,8 +438,12 @@
   <target name="test.rule" depends="compile.tests"
    description="Run rule Digester unit tests ...">
     <echo message="Running Rule tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.RuleTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -396,8 +452,12 @@
   <target name="test.spr" depends="compile.tests"
    description="Run tests for SetPropertyRule ...">
     <echo message="Running SetPropertyRule tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.SetPropertyRuleTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -407,8 +467,12 @@
   <target name="test.node" depends="compile.tests"
           description="Run NodeCreateRule tests ...">
     <echo message="Running NodeCreateRule tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.NodeCreateRuleTestCase"/>
       <classpath refid="test.classpath"/>
     </java>
@@ -417,8 +481,12 @@
   <target name="test.plugins" depends="compile.tests"
           description="Run Plugins tests ...">
     <echo message="Running Plugins tests ..."/>
+    <condition property="logopt" value="${log.factoryopt}=${log.class}">
+      <istrue value="${suppressLogOutputDuringTests}"/>
+    </condition>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
+      <jvmarg value="-D${logopt}"/>
       <arg value="org.apache.commons.digester.plugins.TestAll"/>
       <classpath refid="test.classpath"/>
     </java>
Index: src/test/org/apache/commons/digester/BeanPropertySetterRuleTestCase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/src/test/org/apache/commons/digester/BeanPropertySetterRuleTestCase.java,v
retrieving revision 1.11
diff -u -r1.11 BeanPropertySetterRuleTestCase.java
--- src/test/org/apache/commons/digester/BeanPropertySetterRuleTestCase.java	5 Oct 2003 15:35:50 -0000	1.11
+++ src/test/org/apache/commons/digester/BeanPropertySetterRuleTestCase.java	8 Oct 2003 03:04:26 -0000
@@ -363,7 +363,6 @@
                 digester.parse(xmlTestReader());
             fail("Should have thrown NoSuchMethodException");
         } catch (Exception e) {
-            e.printStackTrace(System.err);
             if (e instanceof InvocationTargetException) {
                 Throwable t =
                     ((InvocationTargetException) e).getTargetException();
Index: src/test/org/apache/commons/digester/CallMethodRuleTestCase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/src/test/org/apache/commons/digester/CallMethodRuleTestCase.java,v
retrieving revision 1.10
diff -u -r1.10 CallMethodRuleTestCase.java
--- src/test/org/apache/commons/digester/CallMethodRuleTestCase.java	5 Oct 2003 15:36:14 -0000	1.10
+++ src/test/org/apache/commons/digester/CallMethodRuleTestCase.java	8 Oct 2003 03:04:26 -0000
@@ -517,8 +517,6 @@
         digester.push(list);
         digester.parse(reader);
         
-        System.out.println(list);
-        
         NamedBean bean = (NamedBean) list.get(0);
         assertEquals("Wrong name (1)", "Simple", bean.getName());
         // these are added in deepest first order by the addRootRule
Index: src/test/org/apache/commons/digester/EBRTestCase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/src/test/org/apache/commons/digester/EBRTestCase.java,v
retrieving revision 1.8
diff -u -r1.8 EBRTestCase.java
--- src/test/org/apache/commons/digester/EBRTestCase.java	5 Oct 2003 15:35:57 -0000	1.8
+++ src/test/org/apache/commons/digester/EBRTestCase.java	8 Oct 2003 03:04:26 -0000
@@ -386,7 +386,6 @@
     }
     
     public void testAncesterMatch() throws Exception {
-        System.out.println("Starting ancester match...");
         // test fixed root ancester
         digester.getRules().clear();
         
@@ -445,6 +444,5 @@
         list = digester.getRules().match(null, "b/b/c/e/d"); 
         assertEquals("Wild ancester match (2)", 1, list.size());
         assertEquals("Match missed (5)", "star-b-c-star" , ((TestRule) list.get(0)).getIdentifier());    
-        System.out.println("Finished ancester match.");
     }
 }
Index: src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTest.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTest.java,v
retrieving revision 1.14
diff -u -r1.14 DigesterLoaderTest.java
--- src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTest.java	5 Oct 2003 15:29:04 -0000	1.14
+++ src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTest.java	8 Oct 2003 03:04:27 -0000
@@ -113,7 +113,6 @@
         digester.push(new ArrayList());
         Object root = digester.parse(input.openStream());
         assertEquals("[foo1 baz1 foo2, foo3 foo4]",root.toString());
-        //System.out.println(root);
     }
 
     /**
@@ -295,7 +294,7 @@
             fail("Exception should have been propagated from create method.");
         } catch (Exception e) {
             /* What we expected */
-            System.out.println(e.getClass().getName());
+            assertEquals(org.xml.sax.SAXParseException.class, e.getClass());
         }        
     }
 

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

Reply via email to