Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

abbot.script
Class Launch  view Launch download Launch.java

java.lang.Object
  extended byabbot.script.Step
      extended byabbot.script.Call
          extended byabbot.script.Launch
All Implemented Interfaces:
abbot.i18n.Resources, abbot.editor.i18n.Resources, Tags, XMLifiable

public class Launch
extends Call

Provides scripted static method invocation. Usage:

<launch class="package.class" method="methodName" args="..." [classpath="..."] [delegate=false] [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 escapted ('\[' 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 the class under test is in the JRE (appletviewer, for example), or if the testing class path contains duplicates of classes under test (different versions of xerces or gnu-regexp, for example), then the delegate flag needs to explicitly be set false to ensure the dynamic class loader always tries to load the classes under test before the parent class loader.

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.


Nested Class Summary
 
Nested classes inherited from class abbot.editor.i18n.Resources
abbot.editor.i18n.Resources.ResourceLoader
 
Field Summary
private  java.lang.ClassLoader classLoader
           
private  java.lang.String classpath
           
private  boolean delegate
           
private  boolean threaded
           
private static java.lang.String USAGE
           
 
Fields inherited from class abbot.script.Call
 
Fields inherited from class abbot.script.Step
 
Fields inherited from interface abbot.script.Tags
TAG_ACTION, TAG_ARGS, TAG_ASSERT, TAG_AWTTESTSCRIPT, TAG_CALL, TAG_CLASS, TAG_CLASSPATH, TAG_COMMENT, TAG_COMPONENT, TAG_COUNT, TAG_DELEGATE, TAG_DESC, TAG_EVENT, TAG_FILENAME, TAG_FORKED, TAG_ID, TAG_INDEX, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARENT, TAG_POLL_INTERVAL, TAG_SCRIPT, TAG_SEQUENCE, TAG_SLOW, TAG_STOP_ON_ERROR, TAG_STOP_ON_FAILURE, TAG_TAG, TAG_TERMINATE, TAG_THREADED, TAG_TIMEOUT, TAG_TITLE, TAG_TRIGGER, TAG_TYPE, TAG_VALUE, TAG_VMARGS, TAG_WAIT, TAG_WINDOW, TAG_X, TAG_Y
 
Fields inherited from interface abbot.editor.i18n.Resources
bundle, STRINGS_BUNDLE
 
Constructor Summary
Launch(abbot.Resolver resolver, java.util.HashMap attributes)
           
Launch(abbot.Resolver resolver, java.lang.String description, java.lang.String className, java.lang.String methodName, java.lang.String[] args)
           
Launch(abbot.Resolver resolver, java.lang.String description, java.lang.String className, java.lang.String methodName, java.lang.String[] args, java.lang.String classpath, boolean delegate, boolean threaded)
           
 
Method Summary
 boolean delegates()
           
 java.util.HashMap getAttributes()
          Attributes to save in script.
 java.lang.ClassLoader getClassLoader()
           
 java.lang.String getClasspath()
           
protected  java.lang.String getDefaultDescription()
          Return a reasonable default description for this script step.
protected  java.lang.reflect.Method getMethod()
          Return the method to be used for invocation.
protected  java.lang.Object getTarget()
          Return the target for the method invocation.
 java.lang.Class getTargetClass()
           
 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.
private  void installAppletSecurityManager(java.lang.ClassLoader cl)
          Install a security manager if there is none; this is a workaround to prevent sun's applet viewer's security manager from preventing any classes from being loaded.
 boolean isThreaded()
           
 void runStep()
          Augment the default run step.
 void setClasspath(java.lang.String cp)
           
 void setDelegates(boolean delegate)
           
 void setThreaded(boolean thread)
           
 
Methods inherited from class abbot.script.Call
getArgs, getArguments, getMethodName, getTargetClassName, invoke, resolveMethod, setArguments, setMethodName, setTargetClassName
 
Methods inherited from class abbot.script.Step
addAttributes, addContent, createAttributeMap, createStep, createStep, getDescription, getFinder, getResolver, parseStepAttributes, resolve, resolveClass, 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
 

Field Detail

classpath

private java.lang.String classpath

delegate

private boolean delegate

threaded

private boolean threaded

classLoader

private java.lang.ClassLoader classLoader

USAGE

private static final java.lang.String USAGE
See Also:
Constant Field Values
Constructor Detail

Launch

public Launch(abbot.Resolver resolver,
              java.util.HashMap attributes)

Launch

public Launch(abbot.Resolver resolver,
              java.lang.String description,
              java.lang.String className,
              java.lang.String methodName,
              java.lang.String[] args)

Launch

public Launch(abbot.Resolver resolver,
              java.lang.String description,
              java.lang.String className,
              java.lang.String methodName,
              java.lang.String[] args,
              java.lang.String classpath,
              boolean delegate,
              boolean threaded)
Method Detail

getClasspath

public java.lang.String getClasspath()

setClasspath

public void setClasspath(java.lang.String cp)

isThreaded

public boolean isThreaded()

setThreaded

public void setThreaded(boolean thread)

delegates

public boolean delegates()

setDelegates

public void setDelegates(boolean delegate)

installAppletSecurityManager

private void installAppletSecurityManager(java.lang.ClassLoader cl)
Install a security manager if there is none; this is a workaround to prevent sun's applet viewer's security manager from preventing any classes from being loaded.


runStep

public void runStep()
             throws java.lang.Throwable
Augment the default run step.

Overrides:
runStep in class Call

getClassLoader

public java.lang.ClassLoader getClassLoader()

getTargetClass

public java.lang.Class getTargetClass()
                               throws InvalidScriptException
Overrides:
getTargetClass in class Call

getTarget

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

Overrides:
getTarget in class Call

getMethod

protected java.lang.reflect.Method getMethod()
                                      throws InvalidScriptException
Return the method to be used for invocation.

Overrides:
getMethod in class Call

getAttributes

public java.util.HashMap getAttributes()
Description copied from class: Call
Attributes to save in script. FIXME use a hash table

Overrides:
getAttributes in class Call

getDefaultDescription

protected java.lang.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 java.lang.String getUsage()
Description copied from class: Step
Provide a usage String for this step.

Overrides:
getUsage in class Call

getXMLTag

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

Overrides:
getXMLTag in class Call