blob: 63f2d2fb1d8295471405503b7d1475daf81b0beb [file] [log] [blame]
<?xml version="1.0"?>
<!--
Copyright 2002,2004 The Apache Software Foundation.
Licensed 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.
-->
<test:suite
xmlns:j="jelly:core"
xmlns:test="jelly:junit"
xmlns:util="jelly:util"
xmlns="jelly:ant">
<j:set var="dir" value="target/test-classes/org/apache/commons/jelly/ant"/>
<test:case name="write">
<property name="foo2" value="bar2"/>
<test:assertEquals
expected="bar2"
actual="${foo2}"
/>
</test:case>
<test:case name="readWrite">
<j:set var="foo1" value="bar1"/>
<property name="foo1.1" value="${foo1}"/>
<test:assertEquals
expected="bar1"
actual="${foo1.1}"
/>
</test:case>
<test:case name="writeIn">
<ant
dir="${dir}"
target="writeFoo3Bar3"
/>
<property file="${dir}/test.properties"/>
<test:assertEquals
expected="bar3"
actual="${foo3}"
/>
</test:case>
<test:case name="readWriteIn">
<j:set var="foo4" value="bar4"/>
<ant
dir="${dir}"
target="readWriteFoo4.1Foo4"
/>
<property file="${dir}/test.properties"/>
<test:assertEquals
expected="bar4"
actual="${foo4.1}"
/>
</test:case>
<test:case name="startUpReadWrite">
<j:set var="foo5" value="bar5"/>
<ant
dir="${dir}"
target="readWriteFoo5.1Foo5InStart"
/>
<property file="${dir}/test.properties"/>
<test:assertEquals
expected="bar5"
actual="${foo5.1}"
/>
</test:case>
<test:case name="copy">
<mkdir dir="${basedir}/target/tmp/ant-tests"/>
<copy
overwrite="true"
file="${basedir}/src/test/org/apache/commons/jelly/ant/sample.txt"
tofile="${basedir}/target/tmp/ant-tests/output.txt">
<filterset>
<filter token="foo" value="bar"/>
</filterset>
</copy>
<util:loadText var="text" file="${basedir}/target/tmp/ant-tests/output.txt"/>
<delete file="${basedir}/target/tmp/ant-tests/output.txt"/>
<test:assertEquals expected="hello bar how are you?" actual="${text.trim()}"/>
</test:case>
<test:case name="copyWithReference">
<mkdir dir="${basedir}/target/tmp/ant-tests"/>
<filterset id="myFilter">
<filter token="foo" value="bar"/>
</filterset>
<copy
overwrite="true"
file="${basedir}/src/test/org/apache/commons/jelly/ant/sample.txt"
tofile="${basedir}/target/tmp/ant-tests/output.txt">
<filterset refid="myFilter"/>
</copy>
<util:loadText var="text" file="${basedir}/target/tmp/ant-tests/output.txt"/>
<delete file="${basedir}/target/tmp/ant-tests/output.txt"/>
<test:assertEquals expected="hello bar how are you?" actual="${text.trim()}"/>
</test:case>
<test:case name="parallelCopy">
<mkdir dir="${basedir}/target/tmp/ant-tests"/>
<parallel>
<copy
overwrite="true"
file="${basedir}/src/test/org/apache/commons/jelly/ant/sample.txt"
tofile="${basedir}/target/tmp/ant-tests/output.txt">
<filterset>
<filter token="foo" value="bar"/>
</filterset>
</copy>
<echo>Performing copy in parallel</echo>
</parallel>
<util:loadText var="text" file="${basedir}/target/tmp/ant-tests/output.txt"/>
<delete file="${basedir}/target/tmp/ant-tests/output.txt"/>
<test:assertEquals expected="hello bar how are you?" actual="${text.trim()}"/>
</test:case>
<test:case name="parallelCopyWithReference">
<mkdir dir="${basedir}/target/tmp/ant-tests"/>
<filterset id="myFilter">
<filter token="foo" value="bar"/>
</filterset>
<parallel>
<copy
overwrite="true"
file="${basedir}/src/test/org/apache/commons/jelly/ant/sample.txt"
tofile="${basedir}/target/tmp/ant-tests/output.txt">
<filterset refid="myFilter"/>
</copy>
<echo>Performing copy in parallel</echo>
</parallel>
<util:loadText var="text" file="${basedir}/target/tmp/ant-tests/output.txt"/>
<delete file="${basedir}/target/tmp/ant-tests/output.txt"/>
<test:assertEquals expected="hello bar how are you?" actual="${text.trim()}"/>
</test:case>
<test:case name="startUpReadWrite">
<j:set var="foo" value="setting the message worked!"/>
<echo>
<setProperty name="message" value="${foo}"/>
</echo>
<echo>
<setProperty name="message" value="${bar}" default="the default also worked"/>
</echo>
<!-- haven't thought of a neat way to test this yet... -->
</test:case>
<test:case name="nestedTask">
<j:include uri="task/example.jelly"/>
</test:case>
<test:case name="setProperty">
<taskdef
name="nested"
classname="org.apache.commons.jelly.ant.task.DummyTask">
</taskdef>
<nested>
<setProperty name="force" value="true"/>
</nested>
<j:catch var="ex">
<nested>
<setProperty name="force" value="false"/>
</nested>
</j:catch>
<test:assert test="${ex != null}">We should have created an exception</test:assert>
</test:case>
</test:suite>