Package ise.antelope.tasks
Class Assert
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- ise.antelope.tasks.Assert
-
- All Implemented Interfaces:
java.lang.Cloneable,org.apache.tools.ant.TaskContainer
public class Assert extends org.apache.tools.ant.Task implements org.apache.tools.ant.TaskContainerBased on the Sequential task. Similar to Java's 'assert' keyword, verifies that a given property has a given value. Throws a BuildException if the property value is not as expected or the property does not exist.Also like Java's 'assert' keyword, the Assert task must be 'turned on' using the property "ant.enable.asserts". If not set, or is set to false, the Assert task works exactly like the Sequential task.
Can hold other tasks including Assert. Attributes:
- name - the name of a property. Required.
- exists - boolean, if true, throws BuildException if the property does not exist. Optional, default is true.
- value - the expected value of a property. Implies 'exists'. Throws BuildException if the actual value is not the same as this value. Optional.
- execute - boolean, if true, execute any contained tasks. Optional, default is true. Can also be set globally by setting the value of "assert.execute" to true or false. The local setting overrides the global setting.
The assert task supports a single nested BooleanCondition 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.
- Since:
- Ant 1.5
- Version:
- $Revision: 143 $
-
-
Constructor Summary
Constructors Constructor Description Assert()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBool(BooleanConditionTask boolTask)Adds a feature to the Bool attribute of the Assert objectvoidaddTask(org.apache.tools.ant.Task task)Add a nested task to execute.voidexecute()Execute this task and all nested Tasks.static voidmain(java.lang.String[] args)The main program for the Assert classvoidmaybeConfigure()OverridemaybeConfigurein a way that leaves the nested tasks unconfigured until they get executed.static intrunTests()Description of the MethodvoidsetExecute(java.lang.String execute)Ant boolean, if true, execute any contained tasks.voidsetExists(java.lang.String exists)Set the 'exists' attribute.voidsetFailonerror(boolean fail)Ant boolean, stop the build process if the assertion fails.voidsetLevel(AssertLevel assertlevel)Sets the assertion level.voidsetMessage(java.lang.String msg)Set a specific message to include in the output in the event this assert fails.voidsetName(java.lang.String name)Set the name of the property to test.voidsetValue(java.lang.String value)Set the expected value of the property.-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
-
-
-
-
Method Detail
-
setName
public void setName(java.lang.String name)
Set the name of the property to test. Required.- Parameters:
name- the name of the property to test.
-
setValue
public void setValue(java.lang.String value)
Set the expected value of the property. Implies 'exists'. Throws BuildException if the actual value is not the same as this value. Optional.- Parameters:
value- the expected value of the property.
-
setMessage
public void setMessage(java.lang.String msg)
Set a specific message to include in the output in the event this assert fails.- Parameters:
msg- the message to include
-
setExists
public void setExists(java.lang.String exists)
Set the 'exists' attribute. If true, throws BuildException if the property does not exist. Optional, default is true.- Parameters:
exists- Ant boolean, whether the value must exist.
-
setExecute
public void setExecute(java.lang.String execute)
Ant boolean, if true, execute any contained tasks. Optional, default is true. Can also be set globally by setting the value of "assert.execute" to true or false. The local setting overrides the global setting.- Parameters:
execute- Ant boolean, whether to execute contained tasks.
-
setFailonerror
public void setFailonerror(boolean fail)
Ant boolean, stop the build process if the assertion fails. Defaults to true. Setting this to false is contrary to the intented use of assertions, but may be useful in certain situations.- Parameters:
fail- Ant boolean, whether to stop the build on assertion error.
-
setLevel
public void setLevel(AssertLevel assertlevel)
Sets the assertion level. This is like message level or debug level, valid values are "error" (the default), "warning", "info", and "debug". Setting the level to "warning", "info", or "debug" will force the fail on error setting to false.- Parameters:
assertlevel- one of "error", "warning", "info", or "debug" levels.
-
maybeConfigure
public void maybeConfigure() throws org.apache.tools.ant.BuildExceptionOverridemaybeConfigurein a way that leaves the nested tasks unconfigured until they get executed.- Overrides:
maybeConfigurein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException- Description of Exception- Since:
- Ant 1.5
-
addTask
public void addTask(org.apache.tools.ant.Task task)
Add a nested task to execute.- Specified by:
addTaskin interfaceorg.apache.tools.ant.TaskContainer- Parameters:
task- Nested task to execute.
-
addBool
public void addBool(BooleanConditionTask boolTask)
Adds a feature to the Bool attribute of the Assert object- Parameters:
boolTask- The feature to be added to the Bool attribute
-
execute
public void execute() throws org.apache.tools.ant.BuildExceptionExecute this task and all nested Tasks.- Overrides:
executein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException- Description of Exception
-
runTests
public static int runTests()
Description of the Method- Returns:
- Description of the Returned Value
-
main
public static void main(java.lang.String[] args)
The main program for the Assert class- Parameters:
args- The command line arguments
-
-