de.jdemo.capture.anttasks
Class AbstractDemoCaptureTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by de.jdemo.capture.anttasks.AbstractDemoCaptureTask
Direct Known Subclasses:
FileDemoCaptureTask, GuiDemoCaptureTask, StreamDemoCaptureTask, TextDemoCaptureTask

public abstract class AbstractDemoCaptureTask
extends org.apache.tools.ant.Task

Author:
Markus Gebhard

Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
protected AbstractDemoCaptureTask()
           
 
Method Summary
protected  void addClasspathEntry(java.lang.String resource)
          Search for the given resource and add the directory or archive that contains it to the classpath.
protected  void addCommandLineArguments(org.apache.tools.ant.types.CommandlineJava cmd)
           
 void addEnv(org.apache.tools.ant.types.Environment.Variable var)
          Adds an environment variable; used when forking.
 void addSysproperty(org.apache.tools.ant.types.Environment.Variable sysp)
          Adds a system property that tests can access.
protected  void checkParameters()
           
 org.apache.tools.ant.types.Path createClasspath()
          Adds path to classpath used for tests.
protected abstract  AbstractDemoAntRunner createDemoAntRunner(DemoIdentifier demo, org.apache.tools.ant.AntClassLoader cl)
           
 org.apache.tools.ant.types.Commandline.Argument createJvmarg()
          Adds a JVM argument; ignored if not forking.
protected  org.apache.tools.ant.taskdefs.ExecuteWatchdog createWatchdog()
           
 void execute()
          Runs the testcase.
protected  void execute(DemoIdentifier demoId)
          Run the tests.
 java.lang.String getDemoId()
           
 java.io.File getOutputFile()
           
protected abstract  java.lang.String getRunnerClassName()
           
 void init()
          Adds the jars or directories containing Ant, this task and JUnit to the classpath - this should make the forked JVM work without having to specify them directly.
 void setDemoId(java.lang.String string)
           
 void setDir(java.io.File dir)
          The directory to invoke the VM in.
 void setFork(boolean value)
          If true, JVM should be forked for each test.
 void setIncludeantruntime(boolean b)
          If true, include ant.jar, optional.jar and junit.jar in the forked VM.
 void setJvm(java.lang.String value)
          The command used to invoke the Java Virtual Machine, default is 'java'.
 void setMaxmemory(java.lang.String max)
          Set the maximum memory to be used by all forked JVMs.
 void setNewenvironment(boolean newenv)
          If true, use a new environment when forked.
 void setOutputFile(java.io.File file)
           
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDemoCaptureTask

protected AbstractDemoCaptureTask()
Method Detail

getDemoId

public final java.lang.String getDemoId()

setDemoId

public final void setDemoId(java.lang.String string)

getOutputFile

public final java.io.File getOutputFile()

setOutputFile

public final void setOutputFile(java.io.File file)

checkParameters

protected void checkParameters()

setFork

public void setFork(boolean value)
If true, JVM should be forked for each test.

It avoids interference between testcases and possibly avoids hanging the build. this property is applied on all BatchTest (batchtest) and JUnitTest (test) however it can possibly be overridden by their own properties.

Parameters:
value - true if a JVM should be forked, otherwise false
Since:
Ant 1.2

setMaxmemory

public void setMaxmemory(java.lang.String max)
Set the maximum memory to be used by all forked JVMs.

Parameters:
max - the value as defined by -mx or -Xmx in the java command line options.
Since:
Ant 1.2

setJvm

public void setJvm(java.lang.String value)
The command used to invoke the Java Virtual Machine, default is 'java'. The command is resolved by java.lang.Runtime.exec(). Ignored if fork is disabled.

Parameters:
value - the new VM to use instead of java
Since:
Ant 1.2
See Also:
setFork(boolean)

createJvmarg

public org.apache.tools.ant.types.Commandline.Argument createJvmarg()
Adds a JVM argument; ignored if not forking.

Returns:
create a new JVM argument so that any argument can be passed to the JVM.
Since:
Ant 1.2
See Also:
setFork(boolean)

setDir

public void setDir(java.io.File dir)
The directory to invoke the VM in. Ignored if no JVM is forked.

Parameters:
dir - the directory to invoke the JVM from.
Since:
Ant 1.2
See Also:
setFork(boolean)

addSysproperty

public void addSysproperty(org.apache.tools.ant.types.Environment.Variable sysp)
Adds a system property that tests can access. This might be useful to tranfer Ant properties to the testcases when JVM forking is not enabled.

Since:
Ant 1.3

createClasspath

public org.apache.tools.ant.types.Path createClasspath()
Adds path to classpath used for tests.

Since:
Ant 1.2

addEnv

public void addEnv(org.apache.tools.ant.types.Environment.Variable var)
Adds an environment variable; used when forking.

Will be ignored if we are not forking a new VM.

Since:
Ant 1.5

setNewenvironment

public void setNewenvironment(boolean newenv)
If true, use a new environment when forked.

Will be ignored if we are not forking a new VM.

Since:
Ant 1.5

setIncludeantruntime

public void setIncludeantruntime(boolean b)
If true, include ant.jar, optional.jar and junit.jar in the forked VM.

Since:
Ant 1.5

init

public void init()
Adds the jars or directories containing Ant, this task and JUnit to the classpath - this should make the forked JVM work without having to specify them directly.

Overrides:
init in class org.apache.tools.ant.Task
Since:
Ant 1.4

execute

public final void execute()
                   throws org.apache.tools.ant.BuildException
Runs the testcase.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException
Since:
Ant 1.2

execute

protected void execute(DemoIdentifier demoId)
                throws org.apache.tools.ant.BuildException
Run the tests.

Throws:
org.apache.tools.ant.BuildException

addCommandLineArguments

protected void addCommandLineArguments(org.apache.tools.ant.types.CommandlineJava cmd)

getRunnerClassName

protected abstract java.lang.String getRunnerClassName()

createDemoAntRunner

protected abstract AbstractDemoAntRunner createDemoAntRunner(DemoIdentifier demo,
                                                             org.apache.tools.ant.AntClassLoader cl)

createWatchdog

protected org.apache.tools.ant.taskdefs.ExecuteWatchdog createWatchdog()
                                                                throws org.apache.tools.ant.BuildException
Returns:
null if there is a timeout value, otherwise the watchdog instance.
Throws:
org.apache.tools.ant.BuildException
Since:
Ant 1.2

addClasspathEntry

protected void addClasspathEntry(java.lang.String resource)
Search for the given resource and add the directory or archive that contains it to the classpath.

Doesn't work for archives in JDK 1.1 as the URL returned by getResource doesn't contain the name of the archive.

Since:
Ant 1.4


JDemo homepage: http://www.jdemo.de
Copyright © 2003-2008 Markus Gebhard. All Rights Reserved.