blob: 0b7e06d25ee323a324b133d2a959691464804dd9 [file] [log] [blame]
<?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"
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="foo" location="${output}/foo.jar"/>
<property name="bar" location="${output}/bar.jar"/>
<jar destfile="${foo}">
<file file="${ant.file}"/>
</jar>
</target>
<target name="testSrcfileIsRequired">
<au:expectfailure expectedMessage="is required">
<cmp:pack200normalize/>
</au:expectfailure>
</target>
<target name="testSrcfileMustExist">
<au:expectfailure expectedMessage="bar.jar doesn't exist">
<cmp:pack200normalize srcfile="${bar}"/>
</au:expectfailure>
</target>
<target name="testSrcfileMustNotBeADirectory">
<au:expectfailure expectedMessage="testoutput must be a file">
<cmp:pack200normalize srcfile="${output}"/>
</au:expectfailure>
</target>
<target name="testDestfileMustNotBeADirectory">
<au:expectfailure expectedMessage="testoutput must be a file">
<cmp:pack200normalize srcfile="${foo}" destfile="${output}"/>
</au:expectfailure>
</target>
<target name="testNormalizeSelfWithoutForceDoesntDoAnything">
<cmp:pack200normalize srcfile="${foo}"/>
<au:assertLogContains
text=" not normalized as force attribute is false."
level="verbose"/>
</target>
<target name="testNormalizeDoesntDoAnythingWhenTargetIsUpToDate" depends="setUp">
<touch file="${bar}"/>
<cmp:pack200normalize srcfile="${foo}"
destfile="${bar}"/>
<au:assertLogContains
text=" not normalized as "
level="verbose"/>
<au:assertLogContains
text="bar.jar is up-to-date."
level="verbose"/>
</target>
<target name="testNormalizeSelfWithForce">
<touch file="${bar}"/>
<sleep seconds="2"/>
<cmp:pack200normalize srcfile="${foo}" force="true"/>
<au:assertDestIsOutofdate src="${foo}" dest="${bar}"/>
</target>
<target name="testNormalizeNonExistantTarget">
<sleep seconds="2"/>
<cmp:pack200normalize srcfile="${foo}" destfile="${bar}"/>
<au:assertDestIsOutofdate dest="${foo}" src="${bar}"/>
</target>
<target name="testNormalizesOutOfDateTarget">
<touch file="${bar}"/>
<sleep seconds="2"/>
<touch file="${foo}"/>
<sleep seconds="2"/>
<cmp:pack200normalize srcfile="${foo}" destfile="${bar}"/>
<au:assertDestIsOutofdate dest="${foo}" src="${bar}"/>
</target>
</project>