| Method from org.apache.cactus.integration.ant.container.AbstractContainer Detail: |
protected void cleanTempDirectory(File theTmpDir) {
// Clean up stuff previously put in the temporary directory
Delete delete = (Delete) createAntTask("delete");
FileSet fileSet = new FileSet();
fileSet.setDir(theTmpDir);
fileSet.createInclude().setName("**/*");
delete.addFileset(fileSet);
delete.setIncludeEmptyDirs(true);
delete.setFailOnError(false);
delete.execute();
}
Clean the temporary directory. |
protected final Task createAntTask(String theName) {
return this.antTaskFactory.createTask(theName);
}
|
protected final File createDirectory(File theParentDir,
String theName) throws IOException {
File dir = new File(theParentDir, theName);
dir.mkdirs();
if (!dir.isDirectory())
{
throw new IOException(
"Couldn't create directory " + dir.getAbsolutePath());
}
return dir;
}
Convenience method for creating a new directory inside another one. |
public final PatternSet.NameEntry createExclude() {
return this.patternSet.createExclude();
}
Creates a nested exclude element that is added to the pattern set. |
protected final FilterChain createFilterChain() {
ReplaceTokens.Token token = null;
FilterChain filterChain = new FilterChain();
// Token for the cactus port
ReplaceTokens replacePort = new ReplaceTokens();
token = new ReplaceTokens.Token();
token.setKey("cactus.port");
token.setValue(String.valueOf(getPort()));
replacePort.addConfiguredToken(token);
filterChain.addReplaceTokens(replacePort);
// Token for the cactus webapp context.
if (getDeployableFile() != null)
{
ReplaceTokens replaceContext = new ReplaceTokens();
token = new ReplaceTokens.Token();
token.setKey("cactus.context");
token.setValue(getDeployableFile().getTestContext());
replaceContext.addConfiguredToken(token);
filterChain.addReplaceTokens(replaceContext);
}
return filterChain;
}
Creates the default filter chain that should be applied while copying
container configuration files to the temporary directory from which the
container is started. The default filter chain replaces all occurences
of @cactus.port@ with the TCP port of the container, and all occurences
of @cactus.context@ with the web-application's context path (if the
deployable file is a web-app). |
public final String getBaseURL() {
return this.getProtocol() + "://" + this.getServer() + ":"
+ this.getPort();
}
|
public Path getContainerClasspath() {
return this.containerClasspath;
}
|
protected final DeployableFile getDeployableFile() {
return this.deployableFile;
}
Returns the web-application archive that is to be deployed to the
container. |
public final String[] getExcludePatterns() {
return this.patternSet.getExcludePatterns(getProject());
}
Returns the exclude patterns. |
protected final Log getLog() {
return this.log;
}
|
public final String getProtocol() {
return this.protocol;
}
|
public final String getServer() {
return this.server;
}
|
public long getStartUpWait() {
return this.startUpWait;
}
|
public Variable[] getSystemProperties() {
return this.systemProperties;
}
|
public String getTestContext() {
// Public Methods ----------------------------------------------------------
return null;
}
|
public final File getToDir() {
return this.toDir;
}
|
public void init() {
// The default implementation doesn nothing
}
The default implementation does nothing. |
public final boolean isEnabled() {
return (testIfCondition() && testUnlessCondition());
}
|
public final boolean isExcluded(String theTestName) {
String[] excludePatterns =
this.patternSet.getExcludePatterns(getProject());
if (excludePatterns != null)
{
String testPath = theTestName.replace('.", '/");
for (int i = 0; i < excludePatterns.length; i++)
{
String excludePattern = excludePatterns[i];
if (excludePattern.endsWith(".java")
|| excludePattern.endsWith(".class"))
{
excludePattern = excludePattern.substring(
0, excludePattern.lastIndexOf('."));
}
if (SelectorUtils.matchPath(excludePattern, testPath))
{
return true;
}
}
}
return false;
}
|
public final void setAntTaskFactory(AntTaskFactory theFactory) {
this.antTaskFactory = theFactory;
}
|
public void setContainerClasspath(Path theClasspath) {
this.containerClasspath = theClasspath;
}
|
public final void setDeployableFile(DeployableFile theDeployableFile) {
this.deployableFile = theDeployableFile;
}
|
public final void setIf(String theIfCondition) {
this.ifCondition = theIfCondition;
}
Sets the name of a property that must exist in the project if tests are
to be run on the container. |
public final void setLog(Log theLog) {
this.log = theLog;
}
|
public final void setProtocol(String theProtocol) {
this.protocol = theProtocol;
}
Sets the protocol the container should use |
public final void setServer(String theServer) {
this.server = theServer;
}
Sets the server (name or ip) to which the container is living. |
public void setStartUpWait(long theStartUpWait) {
this.startUpWait = theStartUpWait;
}
Sets the time to wait after the container has been started up.
The default time is 1 second.
Note: This is a hack while waiting for container specific solutions
that tell exactly when the server is started or not. ATM, the only known
issue is with JBoss, where the servlet engine is started before the full
JBoss is started and thus it may happen that we try to shutdown JBoss
before it has finished starting, leading to an exception. |
public void setSystemProperties(Variable[] theProperties) {
this.systemProperties = theProperties;
}
|
public final void setToDir(File theToDir) {
this.toDir = theToDir;
}
Sets the directory to which the test reports should be written. |
public final void setUnless(String theUnlessCondition) {
this.unlessCondition = theUnlessCondition;
}
Sets the name of a property that must not exist in the project if tests
are to be run on the container. |
protected File setupTempDirectory(File theCustomTmpDir,
String theName) {
File tmpDir;
if (theCustomTmpDir == null)
{
tmpDir = new File(System.getProperty("java.io.tmpdir"), theName);
}
else
{
tmpDir = theCustomTmpDir;
}
if (!tmpDir.exists())
{
if (!tmpDir.mkdirs())
{
throw new BuildException("Could not create temporary "
+ "directory [" + tmpDir + "]");
}
}
// make sure we're returning a directory
if (!tmpDir.isDirectory())
{
throw new BuildException("[" + tmpDir + "] is not a directory");
}
return tmpDir;
}
Convenience method that creates a temporary directory or
prepares the one passed by the user. |