ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r1585935 - in /ant/core/trunk/src: etc/testcases/types/ main/org/apache/tools/ant/types/selectors/modifiedselector/ tests/junit/org/apache/tools/ant/types/selectors/
Date Wed, 09 Apr 2014 11:21:25 GMT
Author: antoine
Date: Wed Apr  9 11:21:25 2014
New Revision: 1585935

URL: http://svn.apache.org/r1585935
Log:
changing tests to adopt unique temporary directories

Modified:
    ant/core/trunk/src/etc/testcases/types/selectors.xml
    ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/DependSelectorTest.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java

Modified: ant/core/trunk/src/etc/testcases/types/selectors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/types/selectors.xml?rev=1585935&r1=1585934&r2=1585935&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/types/selectors.xml (original)
+++ ant/core/trunk/src/etc/testcases/types/selectors.xml Wed Apr  9 11:21:25 2014
@@ -18,15 +18,20 @@
 
 <project name="selectors-test" basedir="." default="setupfiles">
 
+  <import file="../buildfiletest-base.xml"/>
+
+  <target name="setUp">
+    <mkdir dir="${output}"/>
+  </target>
   <property name="etc.dir" value=".."/>
   <property name="test.dir"
-          value="selectortest"/>
+          value="${output}/selectortest"/>
   <property name="testregexpsrc.dir"
-          value="regexpseltestsrc"/>
+          value="${output}/regexpseltestsrc"/>
   <property name="testregexpdest.dir"
-          value="regexpseltestdest"/>
+          value="${output}/regexpseltestdest"/>
   <property name="mirror.dir"
-          value="selectortest2"/>
+          value="${output}/selectortest2"/>
 
   <target name="setupfiles">
     <mkdir dir="${test.dir}" />
@@ -75,10 +80,6 @@
             datetime="05/10/2002 2:29 AM"/>
   </target>
 
-  <target name="cleanup">
-    <delete dir="${test.dir}" />
-  </target>
-
   <target name="mirrorfiles">
     <mkdir dir="${mirror.dir}" />
     <mkdir dir="${mirror.dir}/zip" />
@@ -98,15 +99,6 @@
     <touch file="${mirror.dir}/tar/bz2/asf-logo-huge.tar.bz2"/>
   </target>
 
-  <target name="cleanup.mirrorfiles">
-    <delete dir="${mirror.dir}" />
-  </target>
-
-  <target name="cleanupregexp">
-    <delete dir="${testregexpsrc.dir}" />
-    <delete dir="${testregexpdest.dir}" />
-  </target>
-
   <target name="containsregexp">
     <mkdir dir="${testregexpsrc.dir}" />
     <mkdir dir="${testregexpdest.dir}" />

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java?rev=1585935&r1=1585934&r2=1585935&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
Wed Apr  9 11:21:25 2014
@@ -407,12 +407,12 @@ public class ModifiedSelector extends Ba
                 clazz = Class.forName(classname);
             }
 
-            T rv = clazz.asSubclass(type).newInstance();
+            Object rv = clazz.newInstance();
 
             if (!type.isInstance(rv)) {
                 throw new BuildException("Specified class (" + classname + ") " + msg);
             }
-            return rv;
+            return (T) rv;
         } catch (ClassNotFoundException e) {
             throw new BuildException("Specified class (" + classname + ") not found.");
         } catch (Exception e) {

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java?rev=1585935&r1=1585934&r2=1585935&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java
Wed Apr  9 11:21:25 2014
@@ -32,16 +32,13 @@ import org.apache.tools.ant.Project;
  * whether selections are correct.
  *
  */
-public abstract class BaseSelectorTest extends TestCase {
+public abstract class BaseSelectorTest extends BuildFileTest {
 
     private Project project;
     private TaskdefForMakingBed tbed = null;
-    protected String basedirname = "src/etc/testcases/types";
-    protected String beddirname = basedirname + "/selectortest";
-    protected String mirrordirname = basedirname + "/selectortest2";
-    protected File basedir = new File(System.getProperty("root"), basedirname);
-    protected File beddir = new File(System.getProperty("root"), beddirname);
-    protected File mirrordir = new File(System.getProperty("root"), mirrordirname);
+    protected File basedir;
+    protected File beddir;
+    protected File mirrordir;
     protected String[] filenames = {".","asf-logo.gif.md5","asf-logo.gif.bz2",
             "asf-logo.gif.gz","copy.filterset.filtered","zip/asf-logo.gif.zip",
             "tar/asf-logo.gif.tar","tar/asf-logo-huge.tar.gz",
@@ -55,6 +52,11 @@ public abstract class BaseSelectorTest e
     }
 
     public void setUp() {
+        configureProject("src/etc/testcases/types/selectors.xml");
+        executeTarget("setUp");
+        beddir = new File(super.getProject().getProperty("test.dir"));
+        mirrordir = new File(super.getProject().getProperty("mirror.dir"));
+        basedir = getProjectDir();
         project = new Project();
         project.init();
         project.setBaseDir(basedir);
@@ -227,7 +229,7 @@ public abstract class BaseSelectorTest e
      */
     protected void cleanupBed() {
         if (tbed != null) {
-            tbed.tearDown();
+           tbed.tearDown();
             tbed = null;
         }
     }
@@ -268,7 +270,11 @@ public abstract class BaseSelectorTest e
         }
 
         public void tearDown() {
-            executeTarget("cleanup");
+            try {
+                super.tearDown();
+            } catch (Exception exc) {
+                // ignore
+            }
         }
 
         public void makeTestbed() {
@@ -280,7 +286,7 @@ public abstract class BaseSelectorTest e
         }
 
         public void deleteMirror() {
-            executeTarget("cleanup.mirrorfiles");
+            executeTarget("tearDown");
         }
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java?rev=1585935&r1=1585934&r2=1585935&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java
Wed Apr  9 11:21:25 2014
@@ -60,7 +60,11 @@ public class ContainsRegexpTest extends 
         }
 
         public void tearDown() {
-            executeTarget("cleanupregexp");
+            try {
+                super.tearDown();
+            } catch (Exception exc) {
+                // ignore
+            }
         }
 
         public void test() {
@@ -70,7 +74,7 @@ public class ContainsRegexpTest extends 
 
             executeTarget("containsregexp");
 	
-            dir = new File(getProjectDir() + "/regexpseltestdest/");
+            dir = new File(getOutputDir(), "regexpseltestdest");
             files = dir.listFiles();
             filecount = files.length;
 	

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/DependSelectorTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/DependSelectorTest.java?rev=1585935&r1=1585934&r2=1585935&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/DependSelectorTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/DependSelectorTest.java
Wed Apr  9 11:21:25 2014
@@ -138,13 +138,13 @@ public class DependSelectorTest extends 
                 makeMirror();
 
                 s = (DependSelector)getInstance();
-                File testdir = getProject().resolveFile("selectortest2");
+                File testdir = new File(getOutputDir(), "selectortest2");
                 s.setTargetdir(testdir);
                 results = selectionString(s);
                 assertEquals("FFFTTFFFFFFF", results);
 
                 s = (DependSelector)getInstance();
-                testdir = getProject().resolveFile("selectortest2/tar/bz2");
+                testdir = new File(getOutputDir(), "selectortest2/tar/bz2");
                 s.setTargetdir(testdir);
                 m = s.createMapper();
                 m.setType(glob);

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java?rev=1585935&r1=1585934&r2=1585935&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
Wed Apr  9 11:21:25 2014
@@ -192,6 +192,9 @@ public class ModifiedSelectorTest extend
 
 
     public void testCustomClasses() {
+        if (getProject().getProperty("ant.home") == null) {
+            return;
+        }
         BFT bft = new BFT();
         bft.setUp();
         try {
@@ -287,6 +290,7 @@ public class ModifiedSelectorTest extend
      */
     private String getAlgoName(String classname) {
         ModifiedSelector sel = new ModifiedSelector();
+        sel.setProject(getProject());
         // add the test classes to its classpath
         sel.addClasspath(testclasses);
         sel.setAlgorithmClass(classname);
@@ -422,7 +426,7 @@ public class ModifiedSelectorTest extend
      * A cache must return a stored value and a valid iterator.
      * After calling the delete() the cache must be empty.
      *
-     * @param algo   configured test object
+     * @param cache   configured test object
      */
     protected void doTest(Cache cache) {
         assertTrue("Cache not proper configured.", cache.isValid());
@@ -609,6 +613,9 @@ public class ModifiedSelectorTest extend
         bft.deleteCachefile();
     }
     public void testResourceSelectorScenarioSimple() {
+        if (getProject().getProperty("ant.home") == null) {
+            return;
+        }
         BFT bft = new BFT("modifiedselector");
         bft.doTarget("modifiedselectortest-scenario-resourceSimple");
         bft.doTarget("modifiedselectortest-scenario-clean");
@@ -618,7 +625,7 @@ public class ModifiedSelectorTest extend
      * Test the interface semantic of Comparators.
      * This method does some common test for comparator implementations.
      *
-     * @param algo   configured test object
+     * @param comp   configured test object
      */
     protected void doTest(Comparator comp) {
         Object o1 = new String("string1");
@@ -827,16 +834,25 @@ public class ModifiedSelectorTest extend
 
 
     public void testScenarioCoreSelectorDefaults() {
+        if (getProject().getProperty("ant.home") == null) {
+            return;
+        }
         doScenarioTest("modifiedselectortest-scenario-coreselector-defaults", "cache.properties");
     }
 
 
     public void testScenarioCoreSelectorSettings() {
+        if (getProject().getProperty("ant.home") == null) {
+            return;
+        }
         doScenarioTest("modifiedselectortest-scenario-coreselector-settings", "core.cache.properties");
     }
 
 
     public void testScenarioCustomSelectorSettings() {
+        if (getProject().getProperty("ant.home") == null) {
+            return;
+        }
         doScenarioTest("modifiedselectortest-scenario-customselector-settings", "core.cache.properties");
     }
 
@@ -851,9 +867,9 @@ public class ModifiedSelectorTest extend
             bft.doTarget(target);
 
             // the directories to check
-            File to1 = new File(basedir, "selectortest/to-1");
-            File to2 = new File(basedir, "selectortest/to-2");
-            File to3 = new File(basedir, "selectortest/to-3");
+            File to1 = new File(getOutputDir(), "selectortest/to-1");
+            File to2 = new File(getOutputDir(), "selectortest/to-2");
+            File to3 = new File(getOutputDir(), "selectortest/to-3");
 
             // do the checks
             assertTrue("Cache file not created.", cachefile.exists());

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java?rev=1585935&r1=1585934&r2=1585935&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
Wed Apr  9 11:21:25 2014
@@ -128,7 +128,7 @@ public class PresentSelectorTest extends
                 makeMirror();
 
                 s = (PresentSelector)getInstance();
-                subdir = getProject().resolveFile("selectortest2");
+                subdir = new File(getOutputDir(), "selectortest2");
                 s.setTargetdir(subdir);
                 results = mirrorSelectionString(s);
                 assertEquals("TTTFFTTTTTTT", results);



Mime
View raw message