You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/11/28 15:46:33 UTC
svn commit: r721510 - in /ant/core/trunk/src:
main/org/apache/tools/ant/types/resources/Archives.java
tests/antunit/types/resources/archives-test.xml
Author: bodewig
Date: Fri Nov 28 06:46:32 2008
New Revision: 721510
URL: http://svn.apache.org/viewvc?rev=721510&view=rev
Log:
Add a few more tests - and fix the bugs found by them.
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java
ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java?rev=721510&r1=721509&r2=721510&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java Fri Nov 28 06:46:32 2008
@@ -25,6 +25,7 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.ArchiveFileSet;
import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.types.TarFileSet;
@@ -51,6 +52,7 @@
if (isReference()) {
throw noChildrenAllowed();
}
+ setChecked(false);
return zips;
}
@@ -62,6 +64,7 @@
if (isReference()) {
throw noChildrenAllowed();
}
+ setChecked(false);
return tars;
}
@@ -72,6 +75,7 @@
if (isReference()) {
return ((Archives) getCheckedRef()).size();
}
+ dieOnCircularReference();
int total = 0;
for (Iterator i = grabArchives(); i.hasNext(); ) {
total += ((ResourceCollection) i.next()).size();
@@ -86,6 +90,7 @@
if (isReference()) {
return ((Archives) getCheckedRef()).iterator();
}
+ dieOnCircularReference();
List l = new LinkedList();
for (Iterator i = grabArchives(); i.hasNext(); ) {
l.addAll(CollectionUtils
@@ -99,13 +104,25 @@
*/
public boolean isFilesystemOnly() {
if (isReference()) {
- return ((MappedResourceCollection) getCheckedRef())
- .isFilesystemOnly();
+ return ((Archives) getCheckedRef()).isFilesystemOnly();
}
+ dieOnCircularReference();
return false;
}
/**
+ * Overrides the base version.
+ * @param r the Reference to set.
+ */
+ public void setRefid(Reference r) {
+ if (zips.getResourceCollections().size() > 0
+ || tars.getResourceCollections().size() > 0) {
+ throw tooManyAttributes();
+ }
+ super.setRefid(r);
+ }
+
+ /**
* Implement clone. The nested resource collections are cloned as
* well.
* @return a cloned instance.
Modified: ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml?rev=721510&r1=721509&r2=721510&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml Fri Nov 28 06:46:32 2008
@@ -34,4 +34,63 @@
<au:assertFileExists
file="${output}/org/apache/tools/ant/BuildFileTest.class"/>
</target>
+
+ <target name="testMixingZipsAndTars">
+ <mkdir dir="${output}"/>
+ <tar destfile="${output}/test.tar.gz" compression="gzip">
+ <fileset file="${ant.file}"/>
+ </tar>
+ <copy todir="${output}">
+ <archives>
+ <zips>
+ <fileset dir="../../../../../build/lib"
+ includes="ant-launcher.jar"/>
+ </zips>
+ <tars>
+ <gzipresource>
+ <file file="${output}/test.tar.gz"/>
+ </gzipresource>
+ </tars>
+ </archives>
+ </copy>
+ <au:assertFileExists
+ file="${output}/org/apache/tools/ant/launch/Launcher.class"/>
+ <basename property="filename" file="${ant.file}"/>
+ <au:assertFileExists file="${output}/${filename}"/>
+ </target>
+
+ <target name="testReference">
+ <mkdir dir="${output}"/>
+ <archives id="ref">
+ <zips>
+ <fileset dir="../../../../../build/lib"
+ includes="ant-launcher.jar"/>
+ </zips>
+ </archives>
+ <copy todir="${output}">
+ <archives refid="ref"/>
+ </copy>
+ <au:assertFileExists
+ file="${output}/org/apache/tools/ant/launch/Launcher.class"/>
+ </target>
+
+ <target name="testCircularReference">
+ <au:expectfailure
+ message="This data type contains a circular reference.">
+ <copy todir="${output}">
+ <archives id="ref">
+ <zips>
+ <archives refid="ref"/>
+ </zips>
+ </archives>
+ </copy>
+ </au:expectfailure>
+ <au:expectfailure
+ message="This data type contains a circular reference.">
+ <copy todir="${output}">
+ <archives refid="ref"/>
+ </copy>
+ </au:expectfailure>
+ </target>
+
</project>