Task to automate running in-container unit test. It has the following
syntax when used in Ant :
is the URL that is used by this task to
ensure that the server is running. Indeed, the algorithm is as follow :
| Method from org.apache.cactus.integration.ant.RunServerTestsTask Detail: |
public final GenericContainer.Hook createStart() {
if (this.container.isStartUpSet())
{
throw new BuildException(
"This task supports only one nested [start] element");
}
return this.container.createStartUp();
}
Creates a nested start element. |
public final GenericContainer.Hook createStop() {
if (this.container.isShutDownSet())
{
throw new BuildException(
"This task supports only one nested [stop] element");
}
return this.container.createShutDown();
}
Creates a nested stop element. |
public final GenericContainer.Hook createTest() {
if (this.testHook != null)
{
throw new BuildException(
"This task supports only one nested [test] element");
}
this.testHook = container.new Hook();
return this.testHook;
}
Creates a nested test element. |
public void execute() throws BuildException {
// Task Implementation -----------------------------------------------------
if (!this.container.isStartUpSet())
{
throw new BuildException("You must specify either a nested [start] "
+ "element or the [starttarget] attribute");
}
if (!this.container.isShutDownSet())
{
throw new BuildException("You must specify either a nested [stop] "
+ "element or the [stoptarget] attribute");
}
if (this.testHook == null)
{
throw new BuildException("You must specify either a nested [test] "
+ "element or the [testtarget] attribute");
}
// Verify that a test URL has been specified
if (this.testURL == null)
{
throw new BuildException(
"The [testurl] attribute must be specified");
}
this.container.setAntTaskFactory(new DefaultAntTaskFactory(
getProject(), getTaskName(),
getLocation(), getOwningTarget()));
ContainerRunner runner = new ContainerRunner(this.container);
runner.setLogger(new AntLogger(getProject()));
runner.setURL(this.testURL);
runner.setTimeout(this.timeout);
runner.startUpContainer();
try
{
this.testHook.execute();
}
finally
{
runner.shutDownContainer();
}
}
|
public void setStartTarget(String theStartTarget) {
if (this.container.isStartUpSet())
{
throw new BuildException("Either specify the [starttarget] "
+ "attribute or the nested [start] element, but not both");
}
this.container.setStartUpTarget(theStartTarget);
}
Sets the target to call to start the server. |
public void setStopTarget(String theStopTarget) {
if (this.container.isShutDownSet())
{
throw new BuildException("Either specify the [stoptarget] "
+ "attribute or the nested [stop] element, but not both");
}
this.container.setShutDownTarget(theStopTarget);
}
Sets the target to call to stop the server. |
public void setTestTarget(String theTestTarget) {
if (this.testHook != null)
{
throw new BuildException("Either specify the [testtarget] "
+ "attribute or the nested [test] element, but not both");
}
this.testHook = container.new Hook();
this.testHook.setTarget(theTestTarget);
}
Sets the target to call to run the tests. |
public void setTestURL(URL theTestURL) {
this.testURL = theTestURL;
}
Sets the URL to call for testing if the server is running. |
public void setTimeout(long theTimeout) {
this.timeout = theTimeout;
}
|