abbot.script
Class Launch

java.lang.Object
  extended byabbot.script.Step
      extended byabbot.script.Call
          extended byabbot.script.Launch
All Implemented Interfaces:
Serializable, XMLConstants, XMLifiable
Direct Known Subclasses:
Appletviewer

public class Launch
extends Call

Provides scripted static method invocation. Usage:

<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.

See Also:
Serialized Form

Nested Class Summary
static interface Launch.ThreadedLaunchListener
           
 
Field Summary
 
Fields inherited from interface abbot.script.XMLConstants
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_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 Summary
Launch(Resolver resolver, Map attributes)
           
Launch(Resolver resolver, String description, String className, String methodName, String[] args)
           
Launch(Resolver resolver, String description, String className, String methodName, String[] args, String classpath, boolean threaded)
           
 
Method Summary
protected  AppClassLoader createClassLoader()
           
 Map getAttributes()
          Attributes to save in script.
 ClassLoader getClassLoader()
          Return the class loader that uses the classpath defined in this step.
 String getClasspath()
           
 String getDefaultDescription()
          Return a reasonable default description for this script step.
 Method getMethod()
          Return the method to be used for invocation.
protected  Object getTarget(Method m)
          Return the target for the method invocation.
 Class getTargetClass()
          Get the class of the target of the method invocation.
 String getUsage()
          Provide a usage String for this step.
 String getXMLTag()
          Define the XML tag to use for this script step.
 void installContext()
          Install the class loader context for the code being launched.
 boolean isThreaded()
           
protected  void launch()
           
 Class resolveClass(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(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 terminate()
          The default termination disposes of all extant windows in the current Hierarchy.
 void uninstallContext()
          Remove the class loader context.
 
Methods inherited from class abbot.script.Call
disambiguateMethod, evaluateParameter, evaluateParameters, getArgs, getArguments, getArgumentsDescription, getEncodedArguments, getMethodName, getMethods, getTargetClassName, invoke, resolveMethod, resolveMethods, setArguments, setArguments, setMethodName, setTargetClassName
 
Methods inherited from class abbot.script.Step
addAttributes, addContent, createAttributeMap, createStep, createStep, getDescription, getResolver, parseStepAttributes, resolveTester, run, setDescription, setScriptError, simpleClassName, toEditableString, toString, toXML, toXMLString, usage, usage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Launch

public Launch(Resolver resolver,
              Map attributes)

Launch

public Launch(Resolver resolver,
              String description,
              String className,
              String methodName,
              String[] args)

Launch

public Launch(Resolver resolver,
              String description,
              String className,
              String methodName,
              String[] args,
              String classpath,
              boolean threaded)
Method Detail

getClasspath

public String getClasspath()

setClasspath

public void setClasspath(String cp)

isThreaded

public boolean isThreaded()

setThreaded

public void setThreaded(boolean thread)

createClassLoader

protected AppClassLoader createClassLoader()

installContext

public void installContext()
Install the class loader context for the code being launched. The context class loader for the current thread is modified.


launch

protected void launch()
               throws Throwable
Throws:
Throwable

terminate

protected void terminate()
The default termination disposes of all extant windows in the current Hierarchy.


runStep

public void runStep()
             throws Throwable
Description copied from class: Step
Implement the step's behavior here.

Overrides:
runStep in class Call
Throws:
Throwable

resolveClass

public Class resolveClass(String className)
                   throws ClassNotFoundException
Overrides the default implementation to always use the class loader defined by this step. This works in cases where the Launch step has not yet been added to a Script; otherwise the Script will provide an implementation equivalent to this one.

Overrides:
resolveClass in class Step
Throws:
ClassNotFoundException

getClassLoader

public ClassLoader getClassLoader()
Return the class loader that uses the classpath defined in this step.


uninstallContext

public void uninstallContext()
Remove the class loader context. May be invoked from any thread.


getTargetClass

public Class getTargetClass()
                     throws ClassNotFoundException
Description copied from class: Call
Get the class of the target of the method invocation. This is public to provide editors access to the class being used (for example, providing a menu of all available methods).

Overrides:
getTargetClass in class Call
Throws:
ClassNotFoundException

getTarget

protected Object getTarget(Method m)
Return the target for the method invocation. All launch invocations must be static, so this always returns null.

Overrides:
getTarget in class Call

getMethod

public Method getMethod()
                 throws ClassNotFoundException,
                        NoSuchMethodException
Return the method to be used for invocation.

Overrides:
getMethod in class Call
Throws:
ClassNotFoundException
NoSuchMethodException

getAttributes

public Map getAttributes()
Description copied from class: Call
Attributes to save in script.

Overrides:
getAttributes in class Call

getDefaultDescription

public String getDefaultDescription()
Description copied from class: Step
Return a reasonable default description for this script step. This value is used in the absence of an explicit description.

Overrides:
getDefaultDescription in class Call

getUsage

public String getUsage()
Description copied from class: Step
Provide a usage String for this step.

Overrides:
getUsage in class Call

getXMLTag

public String getXMLTag()
Description copied from class: Step
Define the XML tag to use for this script step.

Overrides:
getXMLTag in class Call

setThreadedLaunchListener

public void setThreadedLaunchListener(Launch.ThreadedLaunchListener l)
Set a listener to respond to events when the launch step is threaded.



Copyright © 2002-2004 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge