|
T-Plan Robot Enterprise 2.2.1 Build No. 2.2.1-20101123.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface AutomatedRunnable
Declaration of automated runnable methods.
An automated runnable typically performs one automated task usually defined by a test script or a Java class. Life cycle of such a runnable is:
The tool is designed as a multithreaded application and it can run multiple
automated testing threads. Each such a thread contains its own desktop client
(RemoteDesktopClient instance) and a script manager
(ScriptManager instance). Each thread is typically able to
handle an independent automated task, e.g. running of a script on
one server instance. This class implements such a functionality and it
can be executed as a thread through the Runnable interface.
Each runnable can be initiated with different CLI options. See the
ApplicationSupport.APPLICATION_CLI_OPTIONS array. Thread behavior
strongly depends on whether it runs in CLI (invoked with the -n option)
or GUI mode. See the Runnable.run() method for more info.
While there's no limitation on threads running on CLI mode,
there can be just one thread running in GUI mode within one Java Virtual Machine (JVM)
because the current GUI design is not capable to handle multiple frames.
The application is by default started in a single thread mode. It means that only one thread is created regardless of the CLI/GUI mode flag. The ability of running multiple threads in CLI mode can be exploited only through custom Java programs where the application JAR file and it's APIs serve as a library.
To execute an automated process instantiate the ApplicationSupport class and call one of its
createAutomatedRunnable() methods. Then execute the run() method of the returned runnable.
To run multiple threads encapsulate the runnable with a Thread
and start it instead.
The following example starts two automated threads. The first one connects to VNC server at localhost:1 and
executes script /root/thread1.txt. The other one connects to VNC server localhost:2 and executes
another script /root/thread2.txt. Note that both the threads will be executed simultaneously and
the program exits when the last thread finishes.
import com.tplan.robot.ApplicationSupport;
import com.tplan.robot.AutomatedRunnable;
public class TwoTasks {
public static void main(String[] argv) {
ApplicationSupport robot = new ApplicationSupport();
String args1[] = { "-c", "localhost:1", "-p", "welcome", "-n", "-r", "/root/thread1.txt" };
AutomatedRunnable runnable1 = robot.createAutomatedRunnable("cli-1", args1, System.out, false);
Thread t1 = new Thread(runnable1);
t1.start();
String args2[] = { "-c", "localhost:2", "-p", "welcome", "-n", "-r", "/root/thread2.txt" };
AutomatedRunnable runnable2 = robot.createAutomatedRunnable("cli-2", args2, System.out, false);
Thread t2 = new Thread(runnable2);
t2.start();
}
}
IMPORTANT NOTE: This is version has one major limitation:
-n or --nodisplay among the thread parameters.
T-Plan Robot Enterprise, (C) 2009-2010 T-Plan Limited. All rights reserved.
| Method Summary | |
|---|---|
int |
getExitCode()
Get the thread exit code which should reflect result of the script execution. |
String |
getId()
Get the thread ID assigned during the thread creation. |
boolean |
isConnected()
Returns true if the thread is connected to a server/desktop. |
boolean |
isConsoleMode()
Returns true if the thread is running in console/CLI mode (i.e. |
void |
stop()
Stop the thread. |
| Methods inherited from interface java.lang.Runnable |
|---|
run |
| Method Detail |
|---|
boolean isConsoleMode()
boolean isConnected()
void stop()
int getExitCode()
Get the thread exit code which should reflect result of the script execution. Value of zero usually indicates
successful execution, non-zero values mean failures. See the Exit command in the Scripting Language
Specification document for more info on exit codes.
Threads stopped by the stop() method always return zero unless an internal error occurs.
String getId()
|
T-Plan Robot Enterprise 2.2.1 Build No. 2.2.1-20101123.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||