You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by an...@apache.org on 2014/04/09 04:40:01 UTC
svn commit: r1585881 - in /ant/core/trunk/src: etc/testcases/types/mapper.xml
tests/junit/org/apache/tools/ant/types/MapperTest.java
Author: antoine
Date: Wed Apr 9 02:40:01 2014
New Revision: 1585881
URL: http://svn.apache.org/r1585881
Log:
changing tests to adopt unique temporary directories
Modified:
ant/core/trunk/src/etc/testcases/types/mapper.xml
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/MapperTest.java
Modified: ant/core/trunk/src/etc/testcases/types/mapper.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/types/mapper.xml?rev=1585881&r1=1585880&r2=1585881&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/types/mapper.xml (original)
+++ ant/core/trunk/src/etc/testcases/types/mapper.xml Wed Apr 9 02:40:01 2014
@@ -18,21 +18,50 @@
<project name="copy-test" basedir="." default="test1">
- <target name="test1">
- <mkdir dir="copytest" />
- <copy todir="copytest">
+ <import file="../buildfiletest-base.xml"/>
+
+ <target name="setUp">
+ <mkdir dir="${output}" />
+ </target>
+
+ <target name="test1" depends="setUp">
+ <union id="source.resourcecollection">
<fileset dir="../../../main">
<include name="**/taskdefs/*.java" />
</fileset>
<fileset dir="../../../tests/junit">
<include name="**/taskdefs/*.java" />
</fileset>
+ </union>
+ <copy todir="${output}">
+ <union refid="source.resourcecollection"/>
<mapper type="flatten" />
</copy>
- </target>
-
- <target name="cleanup">
- <delete dir="copytest" />
+ <resourcecount property="sourcefiles.count">
+ <union refid="source.resourcecollection"/>
+ </resourcecount>
+ <resourcecount property="destfiles.count">
+ <fileset dir="${output}"/>
+ </resourcecount>
+ <resourcecount property="destdirs.count">
+ <dirset dir="${output}"/>
+ </resourcecount>
+ <fail message="different number of files in source and destination ${sourcefiles.count} ${destfiles.count}">
+ <condition>
+ <not>
+ <equals arg1="${sourcefiles.count}" arg2="${destfiles.count}"/>
+ </not>
+ </condition>
+ </fail>
+ <!-- one expects the output of resourcecount on a dirset which does not contain subdirectories to be 1 -->
+ <!-- it looks like the folder of the dirset itself is counted -->
+ <fail message="flatten mapper should not copy folders">
+ <condition>
+ <not>
+ <equals arg1="${destdirs.count}" arg2="1"/>
+ </not>
+ </condition>
+ </fail>
</target>
</project>
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/MapperTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/MapperTest.java?rev=1585881&r1=1585880&r2=1585881&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/MapperTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/MapperTest.java Wed Apr 9 02:40:01 2014
@@ -18,6 +18,8 @@
package org.apache.tools.ant.types;
+import java.io.File;
+import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.List;
@@ -34,7 +36,6 @@ import org.apache.tools.ant.util.Merging
/**
* JUnit 3 testcases for org.apache.tools.ant.types.Mapper.
- *
*/
public class MapperTest extends TestCase {
@@ -58,7 +59,7 @@ public class MapperTest extends TestCase
fail("Can add reference to Mapper with from attribute set");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute when using refid",
- be.getMessage());
+ be.getMessage());
}
m = new Mapper(project);
@@ -68,7 +69,7 @@ public class MapperTest extends TestCase
fail("Can set from in Mapper that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute when using refid",
- be.getMessage());
+ be.getMessage());
}
m = new Mapper(project);
@@ -78,7 +79,7 @@ public class MapperTest extends TestCase
fail("Can set to in Mapper that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute when using refid",
- be.getMessage());
+ be.getMessage());
}
try {
Mapper.MapperType mt = new Mapper.MapperType();
@@ -87,7 +88,7 @@ public class MapperTest extends TestCase
fail("Can set type in Mapper that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute when using refid",
- be.getMessage());
+ be.getMessage());
}
}
@@ -100,7 +101,7 @@ public class MapperTest extends TestCase
fail("Can make Mapper a Reference to itself.");
} catch (BuildException be) {
assertEquals("This data type contains a circular reference.",
- be.getMessage());
+ be.getMessage());
}
// dummy1 --> dummy2 --> dummy3 --> dummy1
@@ -118,7 +119,7 @@ public class MapperTest extends TestCase
fail("Can make circular reference.");
} catch (BuildException be) {
assertEquals("This data type contains a circular reference.",
- be.getMessage());
+ be.getMessage());
}
// dummy1 --> dummy2 --> dummy3
@@ -167,11 +168,11 @@ public class MapperTest extends TestCase
assertEquals("wrong number of filenames mapped", 3, targets.length);
List list = Arrays.asList(targets);
assertTrue("cannot find expected target \"tofilename\"",
- list.contains("tofilename"));
+ list.contains("tofilename"));
assertTrue("cannot find expected target \"fromfilename\"",
- list.contains("fromfilename"));
+ list.contains("fromfilename"));
assertTrue("cannot find expected target \"mergefile\"",
- list.contains("mergefile"));
+ list.contains("mergefile"));
}
public void testChained() {
@@ -236,7 +237,11 @@ public class MapperTest extends TestCase
}
public void tearDown() {
- executeTarget("cleanup");
+ try {
+ super.tearDown();
+ } catch (Exception exc) {
+ // ignore
+ }
}
public void test1() {