Author: mbenson
Date: Wed Feb 24 23:46:24 2010
New Revision: 916043

URL: http://svn.apache.org/viewvc?rev=916043&view=rev
Log:
antunitize LoadProperties JUnit tests

Removed:
    ant/core/trunk/src/etc/testcases/taskdefs/loadproperties.xml
    
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/LoadPropertiesTest.java
Modified:
    ant/core/trunk/src/tests/antunit/taskdefs/loadproperties-test.xml

Modified: ant/core/trunk/src/tests/antunit/taskdefs/loadproperties-test.xml
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/loadproperties-test.xml?rev=916043&r1=916042&r2=916043&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/loadproperties-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/loadproperties-test.xml Wed Feb 
24 23:46:24 2010
@@ -15,10 +15,15 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+<project name="loadproperties-test" default="antunit" 
xmlns:au="antlib:org.apache.ant.antunit">
 
   <import file="../antunit-base.xml" />
 
+  <target name="setUp">
+    <mkdir dir="${input}" />
+    <property name="properties.tmp" location="${input}/properties.tmp" />
+  </target>
+
   <target name="test-basic">
     <loadproperties>
       <string>basic.foo=foo
@@ -68,4 +73,66 @@
     <au:assertPropertyEquals name="a" value="Hello world in EBCDIC"/>
   </target>
 
+  <target name="testPrefixedProperties" depends="setUp">
+    <property name="server" value="localhost"/>
+    <echo file="${properties.tmp}">
+#ht...@port@ = 90
+ht...@port@ = 80
+ht...@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="setUp">
+    <echo file="${properties.tmp}">
+#tpfr.a=a
+tpfr.a=A
+tpfr.b=b\
+       e
+tpfr...@c@
+    </echo>
+  </target>
+
+  <presetdef name="assertPropertiesFromResourceOkay">
+    <au:assertTrue>
+      <equals arg1="Abesea" arg2="${tpfr.a}${tpfr.b}${tpfr.c}" />
+    </au:assertTrue>
+  </presetdef>
+
+  <target name="testPropertiesFromResource" depends="write properties.tmp">
+    <loadproperties resource="properties.tmp" classpath="${input}">
+      <filterchain>
+        <replacetokens>
+          <token key="C" value="sea"/>
+        </replacetokens>
+      </filterchain>
+    </loadproperties>
+  </target>
+
+  <target name="testPropertiesFromFileSet" depends="write properties.tmp">
+    <loadproperties>
+      <fileset file="${properties.tmp}" />
+      <filterchain>
+        <replacetokens>
+          <token key="C" value="sea"/>
+        </replacetokens>
+      </filterchain>
+    </loadproperties>
+    <assertPropertiesFromResourceOkay />
+  </target>
+
 </project>


Reply via email to