Class Funtest
- java.lang.Object
- 
- org.apache.tools.ant.ProjectComponent
- 
- org.apache.tools.ant.Task
- 
- org.apache.tools.ant.taskdefs.optional.testing.Funtest
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable
 
 public class Funtest extends Task Task to provide functional testing under Ant, with a fairly complex workflow of:- Conditional execution
- Application to start
- A probe to "waitfor" before running tests
- A tests sequence
- A reporting sequence that runs after the tests have finished
- A "teardown" clause that runs after the rest.
- Automated termination of the program it executes, if a timeout is not met
- Checking of a failure property and automatic raising of a fault (with the text in failureText) if test shutdown and reporting succeeded
 - Since:
- Ant 1.8
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringAPPLICATION_EXCEPTIONApplication exception : "Application Exception"static java.lang.StringAPPLICATION_FORCIBLY_SHUT_DOWN"Application forcibly shut down"static java.lang.StringSHUTDOWN_INTERRUPTED"Shutdown interrupted"static java.lang.StringSKIPPING_TESTS"Condition failed -skipping tests"static java.lang.StringTEARDOWN_EXCEPTIONTeardown exception : "Teardown Exception"static java.lang.StringWARN_OVERRIDING"Overriding previous definition of "- 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description Funtest()
 - 
Method SummaryModifier and Type Method Description voidaddApplication(Sequential sequence)Add an application.voidaddBlock(BlockFor sequence)Add a block.voidaddReporting(Sequential sequence)set reporting sequence of tasks.voidaddSetup(Sequential sequence)Add a setup sequence.voidaddTeardown(Sequential sequence)set teardown sequence of tasks.voidaddTests(Sequential sequence)add tests.ConditionBasecreateCondition()Add a condition element.voidexecute()Run the functional test sequence.BuildExceptiongetApplicationException()Get the application exception.BuildExceptiongetTaskException()Get the task exception.BuildExceptiongetTeardownException()Get the teardown exception.BuildExceptiongetTestException()Get the test exception.protected voidignoringThrowable(java.lang.String type, java.lang.Throwable thrown)log that we are ignoring something rather than rethrowing it.protected voidprocessExceptions()Now faults are analysed.voidsetFailOnTeardownErrors(boolean failOnTeardownErrors)Set the failOnTeardownErrors attribute.voidsetFailureMessage(java.lang.String failureMessage)Set the failureMessage attribute.voidsetFailureProperty(java.lang.String failureProperty)Set the failureProperty attribute.voidsetShutdownTime(long shutdownTime)Set the shutdownTime attribute.voidsetShutdownUnit(WaitFor.Unit unit)Set the shutdownunit attribute.voidsetTimeout(long timeout)Set the timeout attribute.voidsetTimeoutUnit(WaitFor.Unit unit)Set the timeoutunit attribute.- 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
- 
 
- 
- 
- 
Field Detail- 
WARN_OVERRIDINGpublic static final java.lang.String WARN_OVERRIDING "Overriding previous definition of "- See Also:
- Constant Field Values
 
 - 
APPLICATION_FORCIBLY_SHUT_DOWNpublic static final java.lang.String APPLICATION_FORCIBLY_SHUT_DOWN "Application forcibly shut down"- See Also:
- Constant Field Values
 
 - 
SHUTDOWN_INTERRUPTEDpublic static final java.lang.String SHUTDOWN_INTERRUPTED "Shutdown interrupted"- See Also:
- Constant Field Values
 
 - 
SKIPPING_TESTSpublic static final java.lang.String SKIPPING_TESTS "Condition failed -skipping tests"- See Also:
- Constant Field Values
 
 - 
APPLICATION_EXCEPTIONpublic static final java.lang.String APPLICATION_EXCEPTION Application exception : "Application Exception"- See Also:
- Constant Field Values
 
 - 
TEARDOWN_EXCEPTIONpublic static final java.lang.String TEARDOWN_EXCEPTION Teardown exception : "Teardown Exception"- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
createConditionpublic ConditionBase createCondition() Add a condition element.- Returns:
- ConditionBase.
- Since:
- Ant 1.6.2
 
 - 
addApplicationpublic void addApplication(Sequential sequence) Add an application.- Parameters:
- sequence- the application to add.
 
 - 
addSetuppublic void addSetup(Sequential sequence) Add a setup sequence.- Parameters:
- sequence- the setup sequence to add.
 
 - 
addBlockpublic void addBlock(BlockFor sequence) Add a block.- Parameters:
- sequence- the block for to add.
 
 - 
addTestspublic void addTests(Sequential sequence) add tests.- Parameters:
- sequence- a sequence to add.
 
 - 
addReportingpublic void addReporting(Sequential sequence) set reporting sequence of tasks.- Parameters:
- sequence- a reporting sequence to use.
 
 - 
addTeardownpublic void addTeardown(Sequential sequence) set teardown sequence of tasks.- Parameters:
- sequence- a teardown sequence to use.
 
 - 
setFailOnTeardownErrorspublic void setFailOnTeardownErrors(boolean failOnTeardownErrors) Set the failOnTeardownErrors attribute.- Parameters:
- failOnTeardownErrors- the value to use.
 
 - 
setFailureMessagepublic void setFailureMessage(java.lang.String failureMessage) Set the failureMessage attribute.- Parameters:
- failureMessage- the value to use.
 
 - 
setFailurePropertypublic void setFailureProperty(java.lang.String failureProperty) Set the failureProperty attribute.- Parameters:
- failureProperty- the value to use.
 
 - 
setShutdownTimepublic void setShutdownTime(long shutdownTime) Set the shutdownTime attribute.- Parameters:
- shutdownTime- the value to use.
 
 - 
setTimeoutpublic void setTimeout(long timeout) Set the timeout attribute.- Parameters:
- timeout- the value to use.
 
 - 
setTimeoutUnitpublic void setTimeoutUnit(WaitFor.Unit unit) Set the timeoutunit attribute.- Parameters:
- unit- the value to use.
 
 - 
setShutdownUnitpublic void setShutdownUnit(WaitFor.Unit unit) Set the shutdownunit attribute.- Parameters:
- unit- the value to use.
 
 - 
getApplicationExceptionpublic BuildException getApplicationException() Get the application exception.- Returns:
- the application exception.
 
 - 
getTeardownExceptionpublic BuildException getTeardownException() Get the teardown exception.- Returns:
- the teardown exception.
 
 - 
getTestExceptionpublic BuildException getTestException() Get the test exception.- Returns:
- the test exception.
 
 - 
getTaskExceptionpublic BuildException getTaskException() Get the task exception.- Returns:
- the task exception.
 
 - 
executepublic void execute() throws BuildExceptionRun the functional test sequence.This is a fairly complex workflow -what is going on is that we try to clean up no matter how the run ended, and to retain the innermost exception that got thrown during cleanup. That is, if teardown fails after the tests themselves failed, it is the test failing that is more important. - Overrides:
- executein class- Task
- Throws:
- BuildException- if something was caught during the run or teardown.
 
 - 
processExceptionsprotected void processExceptions() Now faults are analysed.The priority is - testexceptions, except those indicating a build timeout when the application itself failed. (Because often it is the application fault that is more interesting than the probe failure, which is usually triggered by the application not starting.)
- Application exceptions (above test timeout exceptions)
- Teardown exceptions -except when they are being ignored
- Test failures as indicated by the failure property
 
 - 
ignoringThrowableprotected void ignoringThrowable(java.lang.String type, java.lang.Throwable thrown)log that we are ignoring something rather than rethrowing it.- Parameters:
- type- name of exception
- thrown- what was thrown
 
 
- 
 
-