public class Launch extends Call implements UIContext
<launch class="package.class" method="methodName" args="..."
classpath="..." [threaded=true]>
The args attribute is a comma-separated list of arguments to pass to the class method, and may use square brackets to denote an array, e.g. "[one,two,three]" will be interpreted as an array length 3 of String. The square brackets may be escaped ('\[' or '\]') to include them literally in an argument.
The class path attribute may use either colon or semicolon as a path separator, but should preferably use relative paths to avoid making the containing script platform- and location-dependent.
In most cases, the classes under test will only be found under the custom class path, and so the parent class loader will fail to find them. If this is the case then the classes under test will be properly discarded on each launch when a new class loader is created.
The 'threaded' attribute is provided in case your code under test requires GUI event processing prior to returning from its invoked method. An example might be a main method which invokes dialog and waits for the response before continuing. In general, it's better to refactor the code if possible so that the main method turns over control to the event dispatch thread as soon as possible. Otherwise, if the application under test is background threaded by the Launch step, any runtime exceptions thrown from the launch code will cause errors in the launch step out of sequence with the other script steps. While this won't cause any problems for the Abbot framework, it can be very confusing for the user.
Note that if the "reload" attribute is set true (i.e. Abbot's class loader is used to reload code under test), ComponentTester extensions must also be loaded by that class loader, so the path to extensions should be included in the Launch class path.
Modifier and Type | Class and Description |
---|---|
static interface |
Launch.ThreadedLaunchListener |
TAG_ACTION, TAG_APPLETVIEWER, TAG_ARCHIVE, TAG_ARGS, TAG_ASSERT, TAG_AWT, TAG_AWTTESTSCRIPT, TAG_BORDER_TITLE, TAG_CALL, TAG_CLASS, TAG_CLASSPATH, TAG_CODE, TAG_CODEBASE, TAG_COMMENT, TAG_COMPONENT, TAG_COUNT, TAG_DELEGATE, TAG_DESC, TAG_DOCBASE, TAG_EVENT, TAG_EXPR, TAG_FILENAME, TAG_FIXTURE, TAG_FORKED, TAG_HEIGHT, TAG_HORDER, TAG_ICON, TAG_ID, TAG_INDEX, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LABEL, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARAMS, TAG_PARENT, TAG_POLL_INTERVAL, TAG_PROPERTY, TAG_ROOT, TAG_SAMPLE, TAG_SCRIPT, TAG_SEQUENCE, TAG_SLOW, TAG_STOP_ON_ERROR, TAG_STOP_ON_FAILURE, TAG_TAG, TAG_TERMINATE, TAG_TEXT, TAG_THREADED, TAG_TIMEOUT, TAG_TITLE, TAG_TRIGGER, TAG_TYPE, TAG_VALUE, TAG_VMARGS, TAG_VORDER, TAG_WAIT, TAG_WEIGHTED, TAG_WIDTH, TAG_WINDOW, TAG_X, TAG_Y
Constructor and Description |
---|
Launch(Resolver resolver,
java.util.Map attributes) |
Launch(Resolver resolver,
java.lang.String description,
java.lang.String className,
java.lang.String methodName,
java.lang.String[] args) |
Launch(Resolver resolver,
java.lang.String description,
java.lang.String className,
java.lang.String methodName,
java.lang.String[] args,
java.lang.String classpath,
boolean threaded) |
Modifier and Type | Method and Description |
---|---|
protected AppClassLoader |
createClassLoader() |
boolean |
equivalent(UIContext context)
No two launches are ever considered equivalent.
|
java.util.Map |
getAttributes()
Attributes to save in script.
|
java.lang.String |
getClasspath() |
java.lang.ClassLoader |
getContextClassLoader()
Return the class loader that uses the classpath defined in this
step.
|
java.lang.String |
getDefaultDescription()
Return a reasonable default description for this script step.
|
Hierarchy |
getHierarchy()
A context must maintain the same
Hierarchy for the lifetime of
the fixture. |
java.lang.reflect.Method |
getMethod()
Return the method to be used for invocation.
|
protected java.lang.Object |
getTarget(java.lang.reflect.Method m)
Return the target for the method invocation.
|
java.lang.Class |
getTargetClass()
Get the class of the target of the method invocation.
|
java.lang.String |
getUsage()
Provide a usage String for this step.
|
java.lang.String |
getXMLTag()
Define the XML tag to use for this script step.
|
protected void |
install()
Install the class loader context for the code being launched.
|
boolean |
isLaunched() |
boolean |
isThreaded() |
void |
launch(StepRunner runner)
Launches the UI described by this
Launch step,
using the given runner as controller/monitor. |
java.lang.Class |
resolveClass(java.lang.String className)
Overrides the default implementation to always use the class loader
defined by this step.
|
void |
runStep()
Implement the step's behavior here.
|
void |
setClasspath(java.lang.String cp) |
void |
setThreaded(boolean thread) |
void |
setThreadedLaunchListener(Launch.ThreadedLaunchListener l)
Set a listener to respond to events when the launch step is
threaded.
|
protected void |
synchronizedRunStep() |
void |
terminate()
Perform steps necessary to remove any setup performed by
this
Launch step. |
disambiguateMethod, evaluateParameter, evaluateParameters, getArgs, getArguments, getArgumentsDescription, getEncodedArguments, getMethodName, getMethods, getTargetClassName, invoke, resolveMethod, resolveMethods, setArguments, setArguments, setMethodName, setTargetClassName
addAttributes, addContent, createAttributeMap, createStep, createStep, getDescription, getResolver, parseAttributes, resolveTester, run, setDescription, setScriptError, simpleClassName, toEditableString, toString, toXML, toXMLString, usage, usage
public Launch(Resolver resolver, java.util.Map attributes)
public Launch(Resolver resolver, java.lang.String description, java.lang.String className, java.lang.String methodName, java.lang.String[] args)
public Launch(Resolver resolver, java.lang.String description, java.lang.String className, java.lang.String methodName, java.lang.String[] args, java.lang.String classpath, boolean threaded)
public java.lang.String getClasspath()
public void setClasspath(java.lang.String cp)
public boolean isThreaded()
public void setThreaded(boolean thread)
protected AppClassLoader createClassLoader()
protected void install()
protected void synchronizedRunStep() throws java.lang.Throwable
java.lang.Throwable
public void terminate()
Launch
step.public void launch(StepRunner runner) throws java.lang.Throwable
Launch
step,
using the given runner as controller/monitor.public boolean isLaunched()
isLaunched
in interface UIContext
public Hierarchy getHierarchy()
UIContext
Hierarchy
for the lifetime of
the fixture.getHierarchy
in interface UIContext
public void runStep() throws java.lang.Throwable
Step
public java.lang.Class resolveClass(java.lang.String className) throws java.lang.ClassNotFoundException
resolveClass
in class Step
java.lang.ClassNotFoundException
public java.lang.ClassLoader getContextClassLoader()
getContextClassLoader
in interface UIContext
ClassLoader
providing access to classes in this
context.public java.lang.Class getTargetClass() throws java.lang.ClassNotFoundException
Call
getTargetClass
in class Call
java.lang.ClassNotFoundException
protected java.lang.Object getTarget(java.lang.reflect.Method m)
public java.lang.reflect.Method getMethod() throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException
public java.util.Map getAttributes()
Call
getAttributes
in class Call
public java.lang.String getDefaultDescription()
Step
getDefaultDescription
in class Call
public java.lang.String getUsage()
Step
public java.lang.String getXMLTag()
Step
public void setThreadedLaunchListener(Launch.ThreadedLaunchListener l)
public boolean equivalent(UIContext context)
equivalent
in interface UIContext
UIContext
is equivalent to another.UIContext.equivalent(abbot.script.UIContext)
,
StepRunner.run(Step)
Abbot is hosted on