diff --git a/changes.xml b/changes.xml index 089e73c..4802441 100644 --- a/changes.xml +++ b/changes.xml @@ -32,6 +32,9 @@ assertMatches' casesensitive attribute didn't default to true as documented + + added a new assertDoesntMatch assertion + diff --git a/docs/assertions.html b/docs/assertions.html index 8d8d94a..acf66ec 100644 --- a/docs/assertions.html +++ b/docs/assertions.html @@ -522,6 +522,65 @@ <assertMatches string="${abc}" pattern="abc" casesensitive="false"/> + +

assertDoesntMatch

+ +

Asserts that a string doesn't match a given regular expression.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
stringThe string to test.Yes
patternThe pattern to test the string against.Yes
casesensitive + Perform a case sensitive match. + Default is true. + No.
multiline + Perform a multi line match. + Default is false. + No.
singleline + 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. + No.
+ +

Examples

+ +

Make the build fail if the property abc contains + "abc" regardless of case: +

+
+      <assertDoesntMatch string="${abc}" pattern="abc" 
+                     casesensitive="false"/>
+

assertLogContains

Asserts that the build log contains a given message.

diff --git a/src/etc/testcases/assert.xml b/src/etc/testcases/assert.xml index 020230d..adac596 100644 --- a/src/etc/testcases/assert.xml +++ b/src/etc/testcases/assert.xml @@ -197,4 +197,10 @@ under the License. pattern="abc"/> + + + + diff --git a/src/main/org/apache/ant/antunit/antlib.xml b/src/main/org/apache/ant/antunit/antlib.xml index fca2bbd..0dfc15c 100644 --- a/src/main/org/apache/ant/antunit/antlib.xml +++ b/src/main/org/apache/ant/antunit/antlib.xml @@ -258,4 +258,24 @@ under the License. + + + + + + + + + + + + + + + + diff --git a/src/tests/junit/org/apache/ant/antunit/AssertTest.java b/src/tests/junit/org/apache/ant/antunit/AssertTest.java index fbc6938..3a78a62 100644 --- a/src/tests/junit/org/apache/ant/antunit/AssertTest.java +++ b/src/tests/junit/org/apache/ant/antunit/AssertTest.java @@ -141,6 +141,10 @@ public class AssertTest extends BuildFileTest { executeTarget("assertMatches"); } + public void testDoesntMatch() { + executeTarget("assertDoesntMatch"); + } + public void testMatchesDefaultCaseSensitivity() { executeTarget("assertMatchesDefaultCaseSensitivity"); }