use a Java5 compatible pack200 test resource
The pack200 format depends on the Java version that created it unless
it contains a class file (in which case the target version of the
class file determines the pack version).
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6712743
diff --git a/src/tests/antunit/pack200-base.xml b/src/tests/antunit/pack200-base.xml
new file mode 100644
index 0000000..4edbde6
--- /dev/null
+++ b/src/tests/antunit/pack200-base.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project default="antunit"
+ name="pack200-base"
+ xmlns:au="antlib:org.apache.ant.antunit"
+ xmlns:cmp="antlib:org.apache.ant.compress">
+
+ <import file="antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${output}"/>
+ <property name="java.dir" value="${input}/java"/>
+ <mkdir dir="${java.dir}"/>
+ <echo file="${java.dir}/Foo.java">public class Foo {}</echo>
+ <javac srcdir="${java.dir}" destdir="${java.dir}"/>
+ <jar destfile="${input}/test.jar" basedir="${java.dir}"/>
+ <cmp:pack200 destfile="${input}/test.pack"
+ src="${input}/test.jar"/>
+ <macrodef name="assertFooMatches">
+ <sequential>
+ <au:assertFileExists file="${output}/Foo.java"/>
+ <au:assertFilesMatch
+ actual="${output}/Foo.java"
+ expected="${java.dir}/Foo.java"
+ />
+ </sequential>
+ </macrodef>
+ </target>
+</project>
diff --git a/src/tests/antunit/pack200-test.xml b/src/tests/antunit/pack200-test.xml
index 2e8b906..a0533f0 100644
--- a/src/tests/antunit/pack200-test.xml
+++ b/src/tests/antunit/pack200-test.xml
@@ -20,48 +20,45 @@
xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
xmlns:cmp="antlib:org.apache.ant.compress">
- <import file="antunit-base.xml" />
-
- <target name="setUp">
- <mkdir dir="${output}" />
- </target>
+ <import file="pack200-base.xml" />
<target name="testRealTest" depends="setUp">
- <cmp:pack200 src="../resources/asf-logo.gif.zip"
- destfile="${output}/asf-logo.gif.pack" />
- <au:assertLogContains text="Building: asf-logo.gif.pack"/>
- <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
+ <cmp:pack200 destfile="${output}/test.pack"
+ src="${input}/test.jar"/>
+ <au:assertLogContains text="Building: test.pack"/>
+ <au:assertFileExists file="${output}/test.pack"/>
</target>
<target name="testRealTestWithResource" depends="setUp">
- <cmp:pack200 destfile="${output}/asf-logo.gif.pack">
- <file file="../resources/asf-logo.gif.zip"/>
+ <cmp:pack200 destfile="${output}/test.pack">
+ <file file="${input}/test.jar"/>
</cmp:pack200>
- <au:assertLogContains text="Building: asf-logo.gif.pack"/>
- <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
+ <au:assertLogContains text="Building: test.pack"/>
+ <au:assertFileExists file="${output}/test.pack"/>
</target>
<target name="testDateCheck" depends="setUp">
- <touch file="${output}/asf-logo.gif.pack"/>
- <cmp:pack200 src="../resources/asf-logo.gif.zip"
- destfile="${output}/asf-logo.gif.pack" />
- <au:assertLogContains text="Nothing to do: asf-logo.gif.pack is up to date."/>
+ <sleep seconds="2"/>
+ <touch file="${input}/test.pack"/>
+ <cmp:pack200 destfile="${input}/test.pack"
+ src="${input}/test.jar"/>
+ <au:assertLogContains text="Nothing to do: test.pack is up to date."/>
</target>
<target name="testNestedTask" depends="setUp">
- <cmp:pack200 destfile="${output}/asf-logo.zip.pack">
+ <cmp:pack200 destfile="${output}/test.pack">
<cmp:zip>
<cmp:cpiofileset src="../resources/asf-logo.gif.bin.cpio"
includes="asf-logo.gif"/>
</cmp:zip>
</cmp:pack200>
- <au:assertFileExists file="${output}/asf-logo.zip.pack"/>
+ <au:assertFileExists file="${output}/test.pack"/>
<au:assertTrue>
<cond:islastmodified datetime="2009-07-31-20:11:14 +0200"
pattern="yyyy-MM-dd-HH:mm:ss Z">
<cmp:zipentry name="asf-logo.gif">
<cmp:pack200resource>
- <file file="${output}/asf-logo.zip.pack"/>
+ <file file="${output}/test.pack"/>
</cmp:pack200resource>
</cmp:zipentry>
</cond:islastmodified>
@@ -69,28 +66,28 @@
</target>
<target name="testTempFileStrategy" depends="setUp">
- <cmp:pack200 src="../resources/asf-logo.gif.zip"
- destfile="${output}/asf-logo.gif.pack"
+ <cmp:pack200 src="${input}/test.jar"
+ destfile="${output}/test.pack"
pack200strategy="temp-file"/>
- <au:assertLogContains text="Building: asf-logo.gif.pack"/>
- <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
+ <au:assertLogContains text="Building: test.pack"/>
+ <au:assertFileExists file="${output}/test.pack"/>
</target>
<target name="testProperties" depends="setUp">
- <cmp:pack200 src="../resources/asf-logo.gif.zip"
- destfile="${output}/asf-logo.gif.pack">
+ <cmp:pack200 src="${input}/test.jar"
+ destfile="${output}/test.pack">
<property key="pack.effort" value="9"/>
</cmp:pack200>
- <au:assertLogContains text="Building: asf-logo.gif.pack"/>
- <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
+ <au:assertLogContains text="Building: test.pack"/>
+ <au:assertFileExists file="${output}/test.pack"/>
</target>
<target name="testNestingOfPackTasks" depends="setUp">
- <cmp:gzip destfile="${output}/asf-logo.gif.pack.gz">
+ <cmp:gzip destfile="${output}/test.pack.gz">
<cmp:pack200 src="../resources/asf-logo.gif.zip"/>
</cmp:gzip>
- <au:assertLogContains text="Building: asf-logo.gif.pack.gz"/>
- <au:assertFileExists file="${output}/asf-logo.gif.pack.gz"/>
+ <au:assertLogContains text="Building: test.pack.gz"/>
+ <au:assertFileExists file="${output}/test.pack.gz"/>
</target>
</project>
diff --git a/src/tests/antunit/pack200resource-test.xml b/src/tests/antunit/pack200resource-test.xml
index 53c53fa..da9025d 100644
--- a/src/tests/antunit/pack200resource-test.xml
+++ b/src/tests/antunit/pack200resource-test.xml
@@ -21,22 +21,18 @@
xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
xmlns:cmp="antlib:org.apache.ant.compress">
- <import file="antunit-base.xml" />
-
- <target name="setUp">
- <mkdir dir="${output}"/>
- </target>
+ <import file="pack200-base.xml" />
<target name="testNativePack200" depends="setUp">
<copy todir="${output}">
<cmp:zipfileset>
<cmp:pack200resource>
- <file file="../resources/asf-logo.gif.pack"/>
+ <file file="../resources/Foo.pack"/>
</cmp:pack200resource>
</cmp:zipfileset>
</copy>
- <au:assertFilesMatch expected="../resources/asf-logo.gif"
- actual="${output}/asf-logo.gif"/>
+ <au:assertFilesMatch expected="${java.dir}/Foo.java"
+ actual="${output}/Foo.java"/>
</target>
<target name="testDoesntSupportConcatenatedStreams">
@@ -44,7 +40,7 @@
<copy todir="${output}">
<cmp:zipfileset>
<cmp:pack200resource decompressconcatenated="true">
- <file file="../resources/asf-logo.gif.pack"/>
+ <file file="${input}/test.pack"/>
</cmp:pack200resource>
</cmp:zipfileset>
</copy>
diff --git a/src/tests/antunit/unpack200-test.xml b/src/tests/antunit/unpack200-test.xml
index 73a462a..7d8b434 100644
--- a/src/tests/antunit/unpack200-test.xml
+++ b/src/tests/antunit/unpack200-test.xml
@@ -19,67 +19,44 @@
xmlns:au="antlib:org.apache.ant.antunit"
xmlns:cmp="antlib:org.apache.ant.compress">
- <import file="antunit-base.xml" />
-
- <target name="setUp">
- <mkdir dir="${output}"/>
- <mkdir dir="${input}"/>
- </target>
+ <import file="pack200-base.xml" />
<target name="testAgainstPack200Task" depends="setUp">
- <cmp:pack200 destfile="${input}/test.pack">
- <cmp:zip>
- <fileset dir="."/>
- </cmp:zip>
- </cmp:pack200>
<cmp:unpack200 src="${input}/test.pack" dest="${input}/test.zip"/>
<cmp:unzip src="${input}/test.zip" dest="${output}"/>
- <au:assertFileExists file="${output}/untar-test.xml"/>
- <au:assertFilesMatch
- actual="${output}/untar-test.xml"
- expected="untar-test.xml"
- />
+ <assertFooMatches/>
</target>
<target name="testAgainstNativePack200" depends="setUp">
- <cmp:unpack200 src="../resources/asf-logo.gif.pack"
+ <cmp:unpack200 src="../resources/Foo.pack"
dest="${input}/test.zip" />
<cmp:unzip src="${input}/test.zip" dest="${output}" />
- <au:assertFileExists file="${output}/asf-logo.gif"/>
+ <au:assertFileExists file="${output}/Foo.java"/>
<au:assertFilesMatch
- actual="${output}/asf-logo.gif"
- expected="../resources/asf-logo.gif"
- />
+ actual="${output}/Foo.java"
+ expected="${java.dir}/Foo.java"/>
</target>
<target name="testTempFileStrategy" depends="setUp">
- <cmp:unpack200 src="../resources/asf-logo.gif.pack"
+ <cmp:unpack200 src="${input}/test.pack"
dest="${input}/test.zip"
pack200strategy="temp-file"/>
<cmp:unzip src="${input}/test.zip" dest="${output}" />
- <au:assertFileExists file="${output}/asf-logo.gif"/>
- <au:assertFilesMatch
- actual="${output}/asf-logo.gif"
- expected="../resources/asf-logo.gif"
- />
+ <assertFooMatches/>
</target>
<target name="testProperties" depends="setUp">
- <cmp:unpack200 src="../resources/asf-logo.gif.pack"
+ <cmp:unpack200 src="${input}/test.pack"
dest="${input}/test.zip">
<property key="unpack.deflate.hint" value="keep"/>
</cmp:unpack200>
<cmp:unzip src="${input}/test.zip" dest="${output}" />
- <au:assertFileExists file="${output}/asf-logo.gif"/>
- <au:assertFilesMatch
- actual="${output}/asf-logo.gif"
- expected="../resources/asf-logo.gif"
- />
+ <assertFooMatches/>
</target>
<target name="testDoesntSupportConcatenatedStreams">
<au:expectfailure>
- <cmp:unpack200 src="../resources/asf-logo.gif.pack"
+ <cmp:unpack200 src="${input}/test.pack"
dest="${input}/test.zip"
decompressconcatenated="true"/>
</au:expectfailure>
diff --git a/src/tests/resources/Foo.pack b/src/tests/resources/Foo.pack
new file mode 100644
index 0000000..c19fca9
--- /dev/null
+++ b/src/tests/resources/Foo.pack
Binary files differ
diff --git a/src/tests/resources/asf-logo.gif.pack b/src/tests/resources/asf-logo.gif.pack
deleted file mode 100644
index c09dd31..0000000
--- a/src/tests/resources/asf-logo.gif.pack
+++ /dev/null
Binary files differ