You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2001/12/12 15:52:35 UTC
cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs ManifestTest.java
bodewig 01/12/12 06:52:35
Modified: . build.xml
src/etc/testcases/taskdefs manifest.xml
src/main/org/apache/tools/ant/taskdefs Manifest.java
src/testcases/org/apache/tools/ant/taskdefs
ManifestTest.java
Log:
Add some tests for manifest task - realized that empty manifest aren't
that empty.
Revision Changes Path
1.217 +3 -1 jakarta-ant/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/build.xml,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -r1.216 -r1.217
--- build.xml 2001/12/11 15:45:41 1.216
+++ build.xml 2001/12/12 14:52:35 1.217
@@ -842,6 +842,7 @@
<junit printsummary="no" haltonfailure="yes"
+ filtertrace="off"
fork="${junit.fork}">
<!-- <jvmarg value="-classic"/> -->
<classpath refid="tests-classpath"/>
@@ -922,7 +923,8 @@
<target name="run-single-test" if="testcase" depends="compile-tests">
- <junit printsummary="no" haltonfailure="yes" fork="${junit.fork}">
+ <junit printsummary="no" haltonfailure="yes" fork="${junit.fork}"
+ filtertrace="off">
<!-- <jvmarg value="-classic"/> -->
<sysproperty key="build.tests" value="${build.tests}"/>
<classpath location="${java.home}/lib/classes.zip" />
1.3 +17 -1 jakarta-ant/src/etc/testcases/taskdefs/manifest.xml
Index: manifest.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/manifest.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- manifest.xml 2001/11/15 13:33:25 1.2
+++ manifest.xml 2001/12/12 14:52:35 1.3
@@ -100,9 +100,25 @@
</jar>
</target>
+ <target name="testNoFile">
+ <manifest />
+ </target>
+
+ <target name="testReplace">
+ <copy file="manifests/test2.mf" toFile="mftest.mf" />
+ <manifest file="mftest.mf" />
+ </target>
+
+ <target name="testUpdate">
+ <copy file="manifests/test2.mf" toFile="mftest.mf" />
+ <manifest file="mftest.mf" mode="update">
+ <attribute name="Foo" value="Bar" />
+ </manifest>
+ </target>
+
<target name="clean">
<delete>
- <fileset dir="." includes="mftest*.jar"/>
+ <fileset dir="." includes="mftest*"/>
</delete>
</target>
</project>
1.14 +4 -1 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java
Index: Manifest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Manifest.java 2001/12/12 10:54:08 1.13
+++ Manifest.java 2001/12/12 14:52:35 1.14
@@ -544,6 +544,7 @@
public Manifest() {
mode = new Mode();
mode.setValue("replace");
+ manifestVersion = null;
}
/**
@@ -613,7 +614,9 @@
* to the Manifest spec.
*/
public void merge(Manifest other) throws ManifestException {
- manifestVersion = other.manifestVersion;
+ if (other.manifestVersion != null) {
+ manifestVersion = other.manifestVersion;
+ }
mainSection.merge(other.mainSection);
for (Enumeration e = other.sections.keys(); e.hasMoreElements();) {
String sectionName = (String)e.nextElement();
1.3 +43 -0 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java
Index: ManifestTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ManifestTest.java 2001/11/15 13:33:26 1.2
+++ ManifestTest.java 2001/12/12 14:52:35 1.3
@@ -55,6 +55,8 @@
package org.apache.tools.ant.taskdefs;
import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.Date;
import org.apache.tools.ant.BuildFileTest;
@@ -192,5 +194,46 @@
executeTarget("test14");
}
+ /**
+ * file attribute for manifest task is required.
+ */
+ public void testNoFile() {
+ expectBuildException("testNoFile", "file is required");
+ }
+ /**
+ * replace changes Manifest-Version from 2.0 to 1.0
+ */
+ public void testReplace() throws IOException, ManifestException {
+ executeTarget("testReplace");
+ Manifest mf = getManifest();
+ assertNotNull(mf);
+ assertEquals(Manifest.getDefaultManifest(), mf);
+ }
+
+ /**
+ * update keeps the Manifest-Version and adds a new attribute Foo
+ */
+ public void testUpdate() throws IOException, ManifestException {
+ executeTarget("testUpdate");
+ Manifest mf = getManifest();
+ assertNotNull(mf);
+ assertTrue(!Manifest.getDefaultManifest().equals(mf));
+ String mfAsString = mf.toString();
+ assertNotNull(mfAsString);
+ assertTrue(mfAsString.startsWith("Manifest-Version: 2.0"));
+ assertTrue(mfAsString.indexOf("Foo: Bar") > -1);
+ }
+
+ /**
+ * Reads mftest.mf.
+ */
+ private Manifest getManifest() throws IOException, ManifestException {
+ FileReader r = new FileReader("src/etc/testcases/taskdefs/mftest.mf");
+ try {
+ return new Manifest(r);
+ } finally {
+ r.close();
+ }
+ }
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>