ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r601404 - in /ant/antlibs/antunit/trunk: changes.xml docs/assertions.html src/etc/testcases/assert.xml src/main/org/apache/ant/antunit/antlib.xml src/tests/junit/org/apache/ant/antunit/AssertTest.java
Date Wed, 05 Dec 2007 16:41:43 GMT
Author: bodewig
Date: Wed Dec  5 08:41:42 2007
New Revision: 601404

URL: http://svn.apache.org/viewvc?rev=601404&view=rev
Log:
new assertDoesntMatch assertion, bugzilla issue 43639, submitted by David Jackman

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

Modified: ant/antlibs/antunit/trunk/changes.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/changes.xml?rev=601404&r1=601403&r2=601404&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/changes.xml (original)
+++ ant/antlibs/antunit/trunk/changes.xml Wed Dec  5 08:41:42 2007
@@ -32,6 +32,9 @@
       assertMatches' casesensitive attribute didn't default to true as
       documented
     </action>
+    <action type="add" issue="43639">
+      added a new assertDoesntMatch assertion
+    </action>
   </release>
 
 </document>

Modified: ant/antlibs/antunit/trunk/docs/assertions.html
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/docs/assertions.html?rev=601404&r1=601403&r2=601404&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/docs/assertions.html (original)
+++ ant/antlibs/antunit/trunk/docs/assertions.html Wed Dec  5 08:41:42 2007
@@ -522,6 +522,65 @@
       &lt;assertMatches string="${abc}" pattern="abc" 
                      casesensitive="false"/></pre>
 
+
+    <h2><a name="assertDoesntMatch">assertDoesntMatch</a></h2>
+
+    <p>Asserts that a string doesn't match a given regular expression.</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">string</td>
+          <td valign="top">The string to test.</td>
+          <td valign="top" align="center">Yes</td>
+        </tr>
+        <tr>
+          <td valign="top">pattern</td>
+          <td valign="top">The pattern to test the string against.</td>
+          <td valign="top" align="center">Yes</td>
+        </tr>
+        <tr>
+          <td valign="top">casesensitive</td>
+          <td valign="top">
+            Perform a case sensitive match.
+            Default is true.
+          </td>
+          <td align="center">No.</td>
+        </tr>
+        <tr>
+          <td valign="top">multiline</td>
+          <td valign="top">
+          Perform a multi line match.
+          Default is false.
+          </td>
+          <td align="center">No.</td>
+        </tr>
+        <tr>
+          <td valign="top">singleline</td>
+          <td valign="top">
+            This allows '.' to match new lines.
+            SingleLine is not to be confused with multiline,
+            SingleLine is a perl
+            regex term, it corresponds to dotall in java regex.
+            Default is false.
+          </td>
+          <td align="center">No.</td>
+        </tr>
+    </table>
+
+    <h3>Examples</h3>
+
+    <p>Make the build fail if the property abc contains
+      "abc" regardless of case:
+    </p>
+    <pre>
+      &lt;assertDoesntMatch string="${abc}" pattern="abc" 
+                     casesensitive="false"/></pre>
+
     <h2><a name="assertLogContains">assertLogContains</a></h2>
 
     <p>Asserts that the build log contains a given message.</p>

Modified: ant/antlibs/antunit/trunk/src/etc/testcases/assert.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/etc/testcases/assert.xml?rev=601404&r1=601403&r2=601404&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/etc/testcases/assert.xml (original)
+++ ant/antlibs/antunit/trunk/src/etc/testcases/assert.xml Wed Dec  5 08:41:42 2007
@@ -197,4 +197,10 @@
                         pattern="abc"/>
     </au:expectfailure>
   </target>
+
+  <target name="assertDoesntMatch">
+    <au:assertDoesntMatch string="this is AbC"
+                          pattern="abcd"
+                          casesensitive="false"/>
+  </target>
 </project>

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml?rev=601404&r1=601403&r2=601404&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml (original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/antlib.xml Wed Dec  5 08:41:42
2007
@@ -258,4 +258,24 @@
     </sequential>
   </macrodef>
 
+  <macrodef name="assertDoesntMatch" backtrace="false">
+    <attribute name="string"/>
+    <attribute name="pattern"/>
+    <attribute name="casesensitive" default="true"/>
+    <attribute name="singleline" default="false"/>
+    <attribute name="multiline" default="false"/>
+    <attribute name="message"
+      default="Expected '@{string}' to not match pattern '@{pattern}'"/>
+    <sequential>
+      <au:assertTrue message="@{message}">
+        <not>
+          <matches string="@{string}" pattern="@{pattern}"
+                   casesensitive="@{casesensitive}"
+                   singleline="@{singleline}"
+                   multiline="@{multiline}"/>
+        </not>
+      </au:assertTrue>
+    </sequential>
+  </macrodef>
+
 </antlib>

Modified: ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AssertTest.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AssertTest.java?rev=601404&r1=601403&r2=601404&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AssertTest.java (original)
+++ ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AssertTest.java Wed Dec
 5 08:41:42 2007
@@ -141,6 +141,10 @@
         executeTarget("assertMatches");
     }
 
+    public void testDoesntMatch() {
+        executeTarget("assertDoesntMatch");
+    }
+
     public void testMatchesDefaultCaseSensitivity() {
         executeTarget("assertMatchesDefaultCaseSensitivity");
     }



Mime
View raw message