// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesseMain.ant;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import fitnesse.FitNesse;
import fitnesse.FitNesseContext;
import fitnesse.testutil.FitNesseUtil;
/**
* Task to stop fitnesse.
* <p/>
* <pre>
* Usage:
* <taskdef name="stop-fitnesse" classname="fitnesse.ant.StopFitnesseTask" classpathref="classpath" />
* OR
* <taskdef classpathref="classpath" resource="tasks.properties" />
* <p/>
* <stop-fitnesse fitnesseport="8082" />
* </pre>
*/
public class StopFitnesseTask extends Task {
private int fitnessePort = 8082;
@Override
public void execute() throws BuildException {
FitNesseContext context = FitNesseUtil.makeTestContext(null, null, null, fitnessePort);
try {
new FitNesse(context).stop();
log("Sucessfully stoped Fitnesse on port " + fitnessePort);
}
catch (Exception e) {
throw new BuildException("Failed to stop FitNesse. Error Msg: " + e.getMessage(), e);
}
}
/**
* Port on which fitnesse would run. Defaults to <b>8082</b>.
*
* @param fitnessePort
*/
public void setFitnessePort(int fitnessePort) {
this.fitnessePort = fitnessePort;
}
}