You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2005/07/01 11:39:55 UTC

svn commit: r208739 - in /ant/sandbox/antlibs/antunit/trunk: docs/assertions.html src/etc/testcases/assert.xml src/main/org/apache/ant/antunit/antlib.xml src/testcases/org/apache/ant/antunit/AssertTest.java

Author: bodewig
Date: Fri Jul  1 02:39:53 2005
New Revision: 208739

URL: http://svn.apache.org/viewcvs?rev=208739&view=rev
Log:
Add two new assertions

Modified:
    ant/sandbox/antlibs/antunit/trunk/docs/assertions.html
    ant/sandbox/antlibs/antunit/trunk/src/etc/testcases/assert.xml
    ant/sandbox/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml
    ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/AssertTest.java

Modified: ant/sandbox/antlibs/antunit/trunk/docs/assertions.html
URL: http://svn.apache.org/viewcvs/ant/sandbox/antlibs/antunit/trunk/docs/assertions.html?rev=208739&r1=208738&r2=208739&view=diff
==============================================================================
--- ant/sandbox/antlibs/antunit/trunk/docs/assertions.html (original)
+++ ant/sandbox/antlibs/antunit/trunk/docs/assertions.html Fri Jul  1 02:39:53 2005
@@ -299,6 +299,82 @@
       <assertDestIsOutofdate dest="${ant.file}" src="${ant.home}/lib/ant.jar"/>
     </pre>
 
+    <h2><a name="assertFilesMatch">assertFilesMatch</a></h2>
+
+    <p>Asserts that two files have the same content.</p>
+
+    <table border="1" cellpadding="2" cellspacing="0">
+        <tr>
+          <td valign="top"><b>Attribute</b></td>
+          <td valign="top"><b>Description</b></td>
+          <td align="center" valign="top"><b>Required</b></td>
+        </tr>
+        <tr>
+          <td valign="top">expected</td>
+          <td valign="top">first file.</td>
+          <td valign="top" align="center">Yes</td>
+        </tr>
+        <tr>
+          <td valign="top">actual</td>
+          <td valign="top">second file.</td>
+          <td valign="top" align="center">Yes</td>
+        </tr>
+        <tr>
+          <td valign="top">message</td>
+          <td valign="top">Message for the exception if the condition
+            doesn't hold true.  Defaults to "Expected files '<em>expected</em>'
+            and '<em>actual</em>' to match".</td>
+          <td align="center">No.</td>
+        </tr>
+    </table>
+    
+    <h3>Example</h3>
+
+    <p>Make the build fail if the file build.xml and backups/build.xml
+    differ.</p>
+
+    <pre>
+      &lt;assertFilesMatch expected="backups/build.xml" actual="build.xml"/&gt;
+    </pre>
+
+    <h2><a name="assertFilesDiffer">assertFilesDiffer</a></h2>
+
+    <p>Asserts that two files have different content.</p>
+
+    <table border="1" cellpadding="2" cellspacing="0">
+        <tr>
+          <td valign="top"><b>Attribute</b></td>
+          <td valign="top"><b>Description</b></td>
+          <td align="center" valign="top"><b>Required</b></td>
+        </tr>
+        <tr>
+          <td valign="top">expected</td>
+          <td valign="top">first file.</td>
+          <td valign="top" align="center">Yes</td>
+        </tr>
+        <tr>
+          <td valign="top">actual</td>
+          <td valign="top">second file.</td>
+          <td valign="top" align="center">Yes</td>
+        </tr>
+        <tr>
+          <td valign="top">message</td>
+          <td valign="top">Message for the exception if the condition
+            doesn't hold true.  Defaults to "Expected files '<em>expected</em>'
+            and '<em>actual</em>' to differ".</td>
+          <td align="center">No.</td>
+        </tr>
+    </table>
+    
+    <h3>Example</h3>
+
+    <p>Make the build fail if the file build.xml and backups/build.xml
+    match.</p>
+
+    <pre>
+      &lt;assertFilesDiffer expected="backups/build.xml" actual="build.xml"/&gt;
+    </pre>
+
     <hr/>
       <p align="center">Copyright &copy; 2005 The Apache Software Foundation. All rights Reserved.</p>
   </body>

Modified: ant/sandbox/antlibs/antunit/trunk/src/etc/testcases/assert.xml
URL: http://svn.apache.org/viewcvs/ant/sandbox/antlibs/antunit/trunk/src/etc/testcases/assert.xml?rev=208739&r1=208738&r2=208739&view=diff
==============================================================================
--- ant/sandbox/antlibs/antunit/trunk/src/etc/testcases/assert.xml (original)
+++ ant/sandbox/antlibs/antunit/trunk/src/etc/testcases/assert.xml Fri Jul  1 02:39:53 2005
@@ -140,4 +140,20 @@
       dest="../../../build/classes/org/apache/ant/antunit/AssertTask.class"/>
   </target>
 
+  <target name="assertFilesMatchPass">
+    <au:assertFilesMatch expected="assert.xml" actual="assert.xml"/>
+  </target>
+
+  <target name="assertFilesMatchFail">
+    <au:assertFilesMatch expected="assert.xml" actual="antunit.xml"/>
+  </target>
+
+  <target name="assertFilesDifferFail">
+    <au:assertFilesDiffer expected="assert.xml" actual="assert.xml"/>
+  </target>
+
+  <target name="assertFilesDifferPass">
+    <au:assertFilesDiffer expected="assert.xml" actual="antunit.xml"/>
+  </target>
+
 </project>

Modified: ant/sandbox/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml
URL: http://svn.apache.org/viewcvs/ant/sandbox/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml?rev=208739&r1=208738&r2=208739&view=diff
==============================================================================
--- ant/sandbox/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml (original)
+++ ant/sandbox/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml Fri Jul  1 02:39:53 2005
@@ -120,4 +120,28 @@
     </sequential>
   </macrodef>
 
+  <macrodef name="assertFilesMatch">
+    <attribute name="expected"/>
+    <attribute name="actual"/>
+    <attribute name="message"
+      default="Expected files '@{expected}' and '@{actual}' to match"/>
+    <sequential>
+      <au:assertTrue message="@{message}">
+        <filesmatch file1="@{expected}" file2="@{actual}"/>
+      </au:assertTrue>
+    </sequential>
+  </macrodef>
+
+  <macrodef name="assertFilesDiffer">
+    <attribute name="expected"/>
+    <attribute name="actual"/>
+    <attribute name="message"
+      default="Expected files '@{expected}' and '@{actual}' to differ"/>
+    <sequential>
+      <au:assertFalse message="@{message}">
+        <filesmatch file1="@{expected}" file2="@{actual}"/>
+      </au:assertFalse>
+    </sequential>
+  </macrodef>
+
 </antlib>

Modified: ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/AssertTest.java
URL: http://svn.apache.org/viewcvs/ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/AssertTest.java?rev=208739&r1=208738&r2=208739&view=diff
==============================================================================
--- ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/AssertTest.java (original)
+++ ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/AssertTest.java Fri Jul  1 02:39:53 2005
@@ -62,6 +62,12 @@
     public void testDestIsOutofdatePass() {
         testPass("assertDestIsOutofdatePass");
     }
+    public void testFilesMatchPass() {
+        testPass("assertFilesMatchPass");
+    }
+    public void testFilesDifferPass() {
+        testPass("assertFilesDifferPass");
+    }
 
     public void testTrueFail() {
         testFail("assertTrueFail");
@@ -103,7 +109,14 @@
         testFail("assertDestIsOutofdateFail",
                  "Expected '../../main/org/apache/ant/antunit/AssertTask.java' to be more recent than '../../../build/classes/org/apache/ant/antunit/AssertTask.class'");
     }
-
+    public void testFilesMatchFail() {
+        testFail("assertFilesMatchFail",
+                 "Expected files 'assert.xml' and 'antunit.xml' to match");
+    }
+    public void testFilesDifferFail() {
+        testFail("assertFilesDifferFail",
+                 "Expected files 'assert.xml' and 'assert.xml' to differ");
+    }
 
     private void testPass(String target) {
         executeTarget(target);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org