blob: 094c64748fb1ea97630182914e0395aba60b8f92 [file] [log] [blame]
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
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 name="loadproperties-test"
basedir="."
default="testPrefixedProperties">
<target name="init">
</target>
<target name="testPrefixedProperties" depends="init">
<property name="server" value="localhost"/>
<echo file="properties.tmp">
#http.@PORT@ = 90
http.@PORT@ = 80
http.@SERVER@ = ${server}
</echo>
<loadproperties srcFile="properties.tmp">
<filterchain>
<striplinecomments>
<comment value="#"/>
</striplinecomments>
<prefixlines prefix="server1."/>
<replacetokens>
<token key="PORT" value="port"/>
<token key="SERVER" value="server"/>
</replacetokens>
<expandproperties/>
</filterchain>
</loadproperties>
<property name="server1.http.url"
value="http://${server1.http.server}:${server1.http.port}"/>
</target>
<target name="write properties.tmp" depends="init">
<echo file="properties.tmp">
#tpfr.a=a
tpfr.a=A
tpfr.b=b\
e
tpfr.c=@C@
</echo>
</target>
<target name="testPropertiesFromResource" depends="write properties.tmp">
<loadproperties resource="properties.tmp" classpath="${basedir}">
<filterchain>
<replacetokens>
<token key="C" value="sea"/>
</replacetokens>
</filterchain>
</loadproperties>
</target>
<target name="testPropertiesFromFileSet" depends="write properties.tmp">
<loadproperties>
<fileset dir="${basedir}">
<include name="properties.tmp"/>
</fileset>
<filterchain>
<replacetokens>
<token key="C" value="sea"/>
</replacetokens>
</filterchain>
</loadproperties>
</target>
<target name="loadPropertiesCheck">
<condition property="testPropertiesFromResource.ok">
<equals arg1="Abesea" arg2="${tpfr.a}${tpfr.b}${tpfr.c}" />
</condition>
<fail unless="testPropertiesFromResource.ok">
$${tpfr.a}$${tpfr.b}$${tpfr.c}=&quot;${tpfr.a}${tpfr.b}${tpfr.c}&quot;
</fail>
</target>
<target name="cleanup">
<delete file="properties.tmp"/>
</target>
</project>