Author: niallp
Date: Wed Jan 16 18:56:18 2008
New Revision: 612686

URL: http://svn.apache.org/viewvc?rev=612686&view=rev
Log:
IO-127 - Changes so that the tests run on JDK 1.3 using the Ant build:
- Remove RegexFileFilter tests from FileFilterTestCase and put them in a new 
separate test case (RegexFileFilterTestCase)
- Remove the other JDK 1.4 dependant classes from the package test suites
- change the Ant build to conditionally compile and run the tests based on 
whether Java version is JDK 1.3 or higher

Added:
    
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java
   (with props)
Modified:
    commons/proper/io/trunk/build.xml
    commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java
    
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
    
commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java
    
commons/proper/io/trunk/src/test/org/apache/commons/io/output/PackageTestSuite.java
    commons/proper/io/trunk/xdocs/building.xml

Modified: commons/proper/io/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/build.xml?rev=612686&r1=612685&r2=612686&view=diff
==============================================================================
--- commons/proper/io/trunk/build.xml (original)
+++ commons/proper/io/trunk/build.xml Wed Jan 16 18:56:18 2008
@@ -158,7 +158,7 @@
           description="Compile ALL classes">
     <echo message="*** Compiling all classes ***" />
 
-    <!-- check JDK 1.3 -->
+    <!-- check JDK 1.4 -->
     <fail message="switch to JDK 1.4+">
       <condition>
         <equals arg1="${ant.java.version}" arg2="1.3" />
@@ -181,6 +181,7 @@
           description="Compile ONLY JDK 1.3 compatible classes ">
     <echo message="*** Compiling ONLY JDK 1.3 compatible classes ***" />
 
+    <!-- check JDK 1.3 -->
     <fail message="switch to JDK 1.3">
       <condition>
         <not><equals arg1="${ant.java.version}" arg2="1.3" /></not>
@@ -203,64 +204,99 @@
 
 <!-- ========== Unit Test Targets ========================================= -->
 
+    <target name="compile.tests" depends="compile, download-dependencies" 
description="Compile unit test cases dependant on JDK version">
+      <antcall target="compile.tests.jdk13" />
+      <antcall target="compile.tests.all" />
+    </target>
+    
+    <!-- Compile all classes -->
+    <target name="compile.tests.all" unless="is.jdk13"
+            description="Compile ALL test classes">
+      <echo message="*** Compiling all test classes ***" />
+
+      <!-- check JDK 1.4 -->
+      <fail message="switch to JDK 1.4+">
+        <condition>
+          <equals arg1="${ant.java.version}" arg2="1.3" />
+        </condition>
+      </fail>
 
-  <target name="compile.tests" depends="compile,download-dependencies"
-   description="Compile unit test cases">
-    <javac  srcdir="${test.home}"
-           destdir="${build.home}/test-classes"
+      <javac srcdir="${test.home}"
+             destdir="${build.home}/test-classes"
              debug="${compile.debug}"
-       deprecation="${compile.deprecation}"
-          optimize="${compile.optimize}">
-      <classpath refid="test.classpath"/>
-    </javac>
-  </target>
-
+             deprecation="${compile.deprecation}"
+             optimize="${compile.optimize}">
+          <classpath refid="test.classpath"/>
+      </javac>
+    </target>
+
+    <!-- Compile excluding JDK 1.4 classes -->
+    <target name="compile.tests.jdk13" unless="not.jdk13"
+            description="Compile ONLY JDK 1.3 compatible test classes ">
+      <echo message="*** Compiling ONLY JDK 1.3 compatible test classes ***" />
+
+      <fail message="switch to JDK 1.3">
+        <condition>
+          <not><equals arg1="${ant.java.version}" arg2="1.3" /></not>
+        </condition>
+      </fail>
+      <javac srcdir="${test.home}"
+               destdir="${build.home}/test-classes"
+               debug="${compile.debug}"
+               deprecation="${compile.deprecation}"
+               optimize="${compile.optimize}">             
+          <classpath refid="test.classpath"/>
+          <include name="**/*.java"/>            
+          <exclude name="**/RegexFileFilterTestCase.java"/>
+          <exclude name="**/FileWriterWithEncodingTest.java"/>
+          <exclude name="**/IOExceptionWithCauseTestCase.java"/>
+          <exclude name="**/CharSequenceReaderTest.java"/>
+      </javac>
+    </target>
 
-  <target name="test"  
depends="compile.tests,test.main,test.comparator,test.filefilter,test.input,test.output"
+  <target name="test"  depends="compile.tests"
                        description="Run all unit test cases">
+      <antcall target="run.tests.jdk13" />
+      <antcall target="run.tests.jdk14" />
   </target>
 
-  <target name="test.main"  depends="compile.tests" description="Run main unit 
test cases">
-    <echo message="Running main tests ..."/>
-    <java classname="${test.runner}" fork="yes"
-        failonerror="${test.failonerror}">
-      <arg value="org.apache.commons.io.PackageTestSuite"/>
-      <classpath refid="test.classpath"/>
-    </java>
-  </target>
+  <target name="run.tests.jdk13"
+          description="Run ONLY JDK 1.3 compatible test classes ">
 
-  <target name="test.comparator"  depends="compile.tests" description="Run 
comparator unit test cases">
-    <echo message="Running comparator tests ..."/>
-    <java classname="${test.runner}" fork="yes"
-        failonerror="${test.failonerror}">
-      <arg value="org.apache.commons.io.comparator.PackageTestSuite"/>
-      <classpath refid="test.classpath"/>
-    </java>
-  </target>
+    <echo message="**** Running JDK 1.3 compatible test classes ****"/>
+
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.PackageTestSuite"/></antcall>
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.comparator.PackageTestSuite"/></antcall>
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.filefilter.PackageTestSuite"/></antcall>
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.input.PackageTestSuite"/></antcall>
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.output.PackageTestSuite"/></antcall>
 
-  <target name="test.filefilter"  depends="compile.tests" description="Run 
filefilter unit test cases">
-    <echo message="Running filefilter tests ..."/>
-    <java classname="${test.runner}" fork="yes"
-        failonerror="${test.failonerror}">
-      <arg value="org.apache.commons.io.filefilter.PackageTestSuite"/>
-      <classpath refid="test.classpath"/>
-    </java>
   </target>
 
-  <target name="test.input"  depends="compile.tests" description="Run input 
unit test cases">
-    <echo message="Running input tests ..."/>
-    <java classname="${test.runner}" fork="yes"
-        failonerror="${test.failonerror}">
-      <arg value="org.apache.commons.io.input.PackageTestSuite"/>
-      <classpath refid="test.classpath"/>
-    </java>
+  <target name="run.tests.jdk14"  unless="is.jdk13"
+          description="Run ONLY tests requiring JDK 1.4">
+
+    <echo message="**** Running tests requiring JDK 1.4 ****"/>
+
+    <!-- check JDK 1.4 -->
+    <fail message="switch to JDK 1.4+">
+      <condition>
+        <equals arg1="${ant.java.version}" arg2="1.3" />
+      </condition>
+    </fail>
+
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.IOExceptionWithCauseTestCase"/></antcall>
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.filefilter.RegexFileFilterTestCase"/></antcall>
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.input.CharSequenceReaderTest"/></antcall>
+    <antcall target="exec.test"><param name="testclass" 
value="org.apache.commons.io.output.FileWriterWithEncodingTest"/></antcall>
+
   </target>
 
-  <target name="test.output"  depends="compile.tests" description="Run output 
unit test cases">
-    <echo message="Running output tests ..."/>
+  <target name="exec.test" description="Run a unit test case">
+    <echo message="Running Test ${testclass} ..."/>
     <java classname="${test.runner}" fork="yes"
         failonerror="${test.failonerror}">
-      <arg value="org.apache.commons.io.output.PackageTestSuite"/>
+      <arg value="${testclass}"/>
       <classpath refid="test.classpath"/>
     </java>
   </target>

Modified: 
commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java?rev=612686&r1=612685&r2=612686&view=diff
==============================================================================
--- 
commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java 
(original)
+++ 
commons/proper/io/trunk/src/test/org/apache/commons/io/PackageTestSuite.java 
Wed Jan 16 18:56:18 2008
@@ -35,7 +35,6 @@
 
     public static Test suite() {
         TestSuite suite = new TestSuite("IO Utilities");
-        suite.addTest(new TestSuite(IOExceptionWithCauseTestCase.class));
         suite.addTest(new TestSuite(CopyUtilsTest.class));
         suite.addTest(new TestSuite(DemuxTestCase.class));
         suite.addTest(new TestSuite(DirectoryWalkerTestCase.class));

Modified: 
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java?rev=612686&r1=612685&r2=612686&view=diff
==============================================================================
--- 
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
 (original)
+++ 
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
 Wed Jan 16 18:56:18 2008
@@ -23,7 +23,6 @@
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
-import java.util.regex.Pattern;
 
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
@@ -820,61 +819,6 @@
         assertFiltering(EmptyFileFilter.EMPTY, notEmptyFile, false);
         assertFiltering(EmptyFileFilter.NOT_EMPTY, notEmptyFile, true);
         FileUtils.forceDelete(emptyDir);
-    }
-
-    public void testRegex() throws Exception {
-        IOFileFilter filter = new 
RegexFileFilter("^.*[tT]est(-\\d+)?\\.java$");
-        assertFiltering(filter, new File("Test.java"), true);
-        assertFiltering(filter, new File("test-10.java"), true);
-        assertFiltering(filter, new File("test-.java"), false);
-
-        filter = new RegexFileFilter("^[Tt]est.java$");
-        assertFiltering(filter, new File("Test.java"), true);
-        assertFiltering(filter, new File("test.java"), true);
-        assertFiltering(filter, new File("tEST.java"), false);
-
-        filter = new RegexFileFilter(Pattern.compile("^test.java$", 
Pattern.CASE_INSENSITIVE));
-        assertFiltering(filter, new File("Test.java"), true);
-        assertFiltering(filter, new File("test.java"), true);
-        assertFiltering(filter, new File("tEST.java"), true);
-
-        filter = new RegexFileFilter("^test.java$", Pattern.CASE_INSENSITIVE);
-        assertFiltering(filter, new File("Test.java"), true);
-        assertFiltering(filter, new File("test.java"), true);
-        assertFiltering(filter, new File("tEST.java"), true);
-
-        filter = new RegexFileFilter("^test.java$", IOCase.INSENSITIVE);
-        assertFiltering(filter, new File("Test.java"), true);
-        assertFiltering(filter, new File("test.java"), true);
-        assertFiltering(filter, new File("tEST.java"), true);
-
-        try {
-            new RegexFileFilter((String)null);
-            fail();
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
-
-        try {
-            new RegexFileFilter((String)null, Pattern.CASE_INSENSITIVE);
-            fail();
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
-
-        try {
-            new RegexFileFilter((String)null, IOCase.INSENSITIVE);
-            fail();
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
-
-        try {
-            new RegexFileFilter((java.util.regex.Pattern)null);
-            fail();
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
     }
 
     //-----------------------------------------------------------------------

Added: 
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java?rev=612686&view=auto
==============================================================================
--- 
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java
 (added)
+++ 
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java
 Wed Jan 16 18:56:18 2008
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.filefilter;
+
+import java.io.File;
+import java.util.regex.Pattern;
+
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOCase;
+import org.apache.commons.io.testtools.FileBasedTestCase;
+
+/**
+ * Used to test RegexFileFilterUtils.
+ */
+public class RegexFileFilterTestCase extends FileBasedTestCase {
+
+    public RegexFileFilterTestCase(String name) {
+        super(name);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public static TestSuite suite() {
+        return new TestSuite(RegexFileFilterTestCase.class);
+    }
+
+    public void setUp() {
+        getTestDirectory().mkdirs();
+    }
+
+    public void tearDown() throws Exception {
+        FileUtils.deleteDirectory(getTestDirectory());
+    }
+
+    public void assertFiltering(IOFileFilter filter, File file, boolean 
expected) throws Exception {
+        // Note. This only tests the (File, String) version if the parent of
+        //       the File passed in is not null
+        assertTrue(
+            "Filter(File) " + filter.getClass().getName() + " not " + expected 
+ " for " + file,
+            (filter.accept(file) == expected));
+
+        if (file != null && file.getParentFile() != null) {
+            assertTrue(
+                "Filter(File, String) " + filter.getClass().getName() + " not 
" + expected + " for " + file,
+                (filter.accept(file.getParentFile(), file.getName()) == 
expected));
+        } else if (file == null) {
+            assertTrue(
+                "Filter(File, String) " + filter.getClass().getName() + " not 
" + expected + " for null",
+                filter.accept(file) == expected);
+        }
+    }
+
+    public void testRegex() throws Exception {
+        IOFileFilter filter = new 
RegexFileFilter("^.*[tT]est(-\\d+)?\\.java$");
+        assertFiltering(filter, new File("Test.java"), true);
+        assertFiltering(filter, new File("test-10.java"), true);
+        assertFiltering(filter, new File("test-.java"), false);
+
+        filter = new RegexFileFilter("^[Tt]est.java$");
+        assertFiltering(filter, new File("Test.java"), true);
+        assertFiltering(filter, new File("test.java"), true);
+        assertFiltering(filter, new File("tEST.java"), false);
+
+        filter = new RegexFileFilter(Pattern.compile("^test.java$", 
Pattern.CASE_INSENSITIVE));
+        assertFiltering(filter, new File("Test.java"), true);
+        assertFiltering(filter, new File("test.java"), true);
+        assertFiltering(filter, new File("tEST.java"), true);
+
+        filter = new RegexFileFilter("^test.java$", Pattern.CASE_INSENSITIVE);
+        assertFiltering(filter, new File("Test.java"), true);
+        assertFiltering(filter, new File("test.java"), true);
+        assertFiltering(filter, new File("tEST.java"), true);
+
+        filter = new RegexFileFilter("^test.java$", IOCase.INSENSITIVE);
+        assertFiltering(filter, new File("Test.java"), true);
+        assertFiltering(filter, new File("test.java"), true);
+        assertFiltering(filter, new File("tEST.java"), true);
+
+        try {
+            new RegexFileFilter((String)null);
+            fail();
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            new RegexFileFilter((String)null, Pattern.CASE_INSENSITIVE);
+            fail();
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            new RegexFileFilter((String)null, IOCase.INSENSITIVE);
+            fail();
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        try {
+            new RegexFileFilter((java.util.regex.Pattern)null);
+            fail();
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+         
+}

Propchange: 
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: 
commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java?rev=612686&r1=612685&r2=612686&view=diff
==============================================================================
--- 
commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java
 (original)
+++ 
commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java
 Wed Jan 16 18:56:18 2008
@@ -34,7 +34,6 @@
     public static Test suite() {
         TestSuite suite = new TestSuite("IO Utilities - input");
         suite.addTest(new TestSuite(AutoCloseInputStreamTest.class));
-        suite.addTest(new TestSuite(CharSequenceReaderTest.class));
         suite.addTest(new TestSuite(ClassLoaderObjectInputStreamTest.class));
         suite.addTest(new TestSuite(ClosedInputStreamTest.class));
         suite.addTest(new TestSuite(CloseShieldInputStreamTest.class));

Modified: 
commons/proper/io/trunk/src/test/org/apache/commons/io/output/PackageTestSuite.java
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/output/PackageTestSuite.java?rev=612686&r1=612685&r2=612686&view=diff
==============================================================================
--- 
commons/proper/io/trunk/src/test/org/apache/commons/io/output/PackageTestSuite.java
 (original)
+++ 
commons/proper/io/trunk/src/test/org/apache/commons/io/output/PackageTestSuite.java
 Wed Jan 16 18:56:18 2008
@@ -38,7 +38,6 @@
         suite.addTest(new TestSuite(CloseShieldOutputStreamTest.class));
         suite.addTest(new TestSuite(CountingOutputStreamTest.class));
         suite.addTest(new TestSuite(DeferredFileOutputStreamTest.class));
-        suite.addTest(new TestSuite(FileWriterWithEncodingTest.class));
         suite.addTest(new TestSuite(LockableFileWriterTest.class));
         suite.addTest(new TestSuite(NullOutputStreamTest.class));
         suite.addTest(new TestSuite(NullWriterTest.class));

Modified: commons/proper/io/trunk/xdocs/building.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/xdocs/building.xml?rev=612686&r1=612685&r2=612686&view=diff
==============================================================================
--- commons/proper/io/trunk/xdocs/building.xml (original)
+++ commons/proper/io/trunk/xdocs/building.xml Wed Jan 16 18:56:18 2008
@@ -87,7 +87,7 @@
   </p>
   <ul>
     <li><code>ant clean</code> - clean up</li>
-    <li><code>ant test</code> - compile and run the unit tests (requires JDK 
1.4+)</li>
+    <li><code>ant test</code> - compile and run the unit tests</li>
     <li><code>ant javadoc</code> - create javadocs</li>
     <li><code>ant jar</code> - build the jar</li>
     <li><code>ant dist</code> - Create the source and binary distributions</li>


Reply via email to