Revision: 96
http://svn.sourceforge.net/ant-contrib/?rev=96&view=rev
Author: mattinger
Date: 2007-03-07 07:11:35 -0800 (Wed, 07 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/ant-contrib/docs/manual/tasks/assert_task.html
trunk/ant-contrib/test/src/net/sf/antcontrib/logic/AssertTest.java
Modified: trunk/ant-contrib/docs/manual/tasks/assert_task.html
===================================================================
--- trunk/ant-contrib/docs/manual/tasks/assert_task.html 2007-03-06 18:46:22 UTC (rev 95)
+++ trunk/ant-contrib/docs/manual/tasks/assert_task.html 2007-03-07 15:11:35 UTC (rev 96)
@@ -25,27 +25,25 @@
</div>
<p>
-The Assert task adds an assertion capability to Ant projects. This task works in a manner very similar to the Java <tt class="computeroutput">
-assert</tt>
- keyword, and provides a limited "design by contract" facility to Ant. This is very useful for testing build scripts prior to putting them into production.
+The Assert task adds an assertion capability to Ant projects. This task works in a manner
+very similar to the Java <tt class="computeroutput">assert</tt> keyword, and provides a
+limited "design by contract" facility to Ant. This is very useful for testing build
+scripts prior to putting them into production.
</p>
<p>
-The Assert task verifies that a given property has a
-given value and throws a BuildException if the property value is not as expected
-or the property does not exist.
+The Assert task verifies that a particular boolean condition is met, and throws a BuildException
+if it is not.
</p>
<p>
-Also like Java's <tt class="computeroutput">
-assert</tt>
- keyword, the Assert task must be 'turned on' using the property <tt class="computeroutput">
-ant.enable.asserts</tt>
-. If not set, or is set to <tt class="computeroutput">
-false</tt>
+Also like Java's <tt class="computeroutput">assert</tt> keyword, the Assert task must be
+'turned on' using the property <tt class="computeroutput">ant.enable.asserts</tt>
+. If not set, or is set to <tt class="computeroutput"> false</tt>
, the Assert task works exactly like the Sequential task. If the <a href="variable_task.html" title="Variable Task">
Variable task</a>
- is used to define this property, then it can be turned on and off as needed throughout a build.
+is used to define this property, then it can be turned on and off as needed throughout a
+build.
</p>
<p>
@@ -53,7 +51,10 @@
</p>
<p>
-The Assert task may contain one 'bool' element. The 'bool' element is identical to the ConditionTask, but unlike the ConditionTask, is actually a Task. The 'bool' element can contain all the conditions permitted by the ConditionTask, plus the <a href="bk03ch05s02.html" title="More Conditions">
+Thie assert task may contain a single conditional element known by ANT, or one of
+the following additional conditions:
+
+<a href="more_conditions.html" title="More Conditions">
IsPropertyTrue</a>
, <a href="more_conditions.html" title="More Conditions">
IsPropertyFalse</a>
@@ -106,31 +107,23 @@
<td>
name</td>
<td>
-The name of the property to test for.</td>
+The name of the property to test for. This is a shortcut for specifying an <equals>
+condition.</td>
<td>
none</td>
<td>
-Yes</td>
+No. However, if specified, the 'value' attribute must also be present</td>
</tr>
<tr>
<td>
-exists</td>
-<td>
-Test for existence or non-existence of the property.</td>
-<td>
-True</td>
-<td>
-No</td>
-</tr>
-<tr>
-<td>
value</td>
<td>
-The value to test for, implies 'exists=true'. If the value in the project is different than this value, a BuildException will be thrown and the build will stop.</td>
+The value to test for, implies . If the value in the project is different than this value,
+a BuildException will be thrown and the build will stop.</td>
<td>
none</td>
<td>
-No</td>
+No, unless the 'name' attribute is specified.</td>
</tr>
<tr>
<td>
@@ -158,15 +151,11 @@
</p>
+<h2>
+Examples
+</h2>
<p>
-As stated above, the Assert task may contain a nested "bool" task, otherwise,
-the Assert task does not support any nested
-elements apart from Ant tasks. Any valid Ant task may be embedded within the
-assert task.
-</p>
-<p>
-
In the following example, the first <tt class="computeroutput">
assert</tt>
task checks that the <tt class="computeroutput">
@@ -192,15 +181,20 @@
<property name="wait" value="2"/>
- <assert name="wait" execute="false">
+ <assert execute="false">
+ <isset property="wait" />
+ <sequential>
<echo>
Waiting ${wait} seconds...
Click the red button to stop waiting.
- </echo>
- <sleep seconds="${wait}"/>
+ </echo>
+ <sleep seconds="${wait}"/>
+ </sequential>
</assert>
<assert name="wait" value="2" execute="true">
- <echo>done waiting!</echo>
+ <sequential>
+ <echo>done waiting!</echo>
+ </sequential>
</assert>
</pre>
@@ -228,9 +222,7 @@
</limit>
<stopwatch name="timer" action="total"/>
<assert message="Too much time.">
- <bool>
- <islessthan arg1="${timer}" arg2="2"/>
- </bool>
+ <islessthan arg1="${timer}" arg2="2"/>
</assert>
</target>
Modified: trunk/ant-contrib/test/src/net/sf/antcontrib/logic/AssertTest.java
===================================================================
--- trunk/ant-contrib/test/src/net/sf/antcontrib/logic/AssertTest.java 2007-03-06 18:46:22 UTC (rev 95)
+++ trunk/ant-contrib/test/src/net/sf/antcontrib/logic/AssertTest.java 2007-03-07 15:11:35 UTC (rev 96)
@@ -49,12 +49,8 @@
executeTarget( "test1" );
}
- public void test2() {
- expectBuildExceptionStackTraceContaining( "test2", "testing assert failure", "Property 'testprop' doesn't exist in this project." );
- }
-
public void test3() {
- expectBuildExceptionStackTraceContaining( "test3", "testing assert failure", "Expected 'false', but was 'true'." );
+ expectBuildException("test3");
}
public void test4() {
@@ -70,7 +66,7 @@
}
public void test7(){
- expectBuildExceptionStackTraceContaining( "test7", "testing conditions", "Assertion failed boolean test." );
+ expectBuildException("test7");
}
public void test8() {
@@ -78,7 +74,7 @@
}
public void test9() {
- expectBuildExceptionStackTraceContaining( "test9", "testing conditions", "Assertion failed boolean test." );
+ expectBuildException("test9");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.