T-Plan Robot Enterprise 2.3.5
Build No. 2.3.5-20120711.1

com.tplan.robot
Class ApplicationSupport

java.lang.Object
  extended by com.tplan.robot.ApplicationSupport
All Implemented Interfaces:
ConfigurationChangeListener, EventListener

public final class ApplicationSupport
extends Object
implements ConfigurationChangeListener

Main class and entry point of the application. It is responsible for initialization of global objects, localization and multithreading support, parsing of the input CLI options and startup of the program.

When an instance of this class is created, the following tasks are carried out:

The class is also owner of global objects and services which are used widely across all project classes. They are:


T-Plan Robot Enterprise, (C) 2009-2012 T-Plan Limited. All rights reserved.


Field Summary
static String APPLICATION_BASE_PACKAGE
          Base Java package name ("com.tplan.robot").
static String APPLICATION_BUILD
          Build identifier (value: "2.3.5-20120711.1").
static String[][] APPLICATION_CLI_OPTIONS
          Array of application CLI options.
static String APPLICATION_CONFIG_FILE
          Configuration file path.
static String APPLICATION_DOC_DIR_NAME
          Name of the online docs/ subdirectory containing this product documentation.
static String APPLICATION_HELP_SET_DIR
          Root folder of the installed help files.
static String APPLICATION_HELP_SET_FILE
          Name of the application JavaHelp help set file (*.hs).
static String APPLICATION_HOME_PAGE
          Application home page URL (value: "http://www.t-plan.com/robot").
static String APPLICATION_LEGACY_CONFIG_FILE
          Legacy v1.x configuration file path.
static String APPLICATION_LICENSE_FILE
          Application license file name.
static String APPLICATION_LOG_FILE_PREFIX
          Log file name prefix (value: "tplan_robot").
static String APPLICATION_NAME
          Product name (value: "T-Plan Robot Enterprise").
static String APPLICATION_RESOURCE_BUNDLE_PREFIX
          Prefix of resource bundle names (property files with software messages, value: "Messages").
static String APPLICATION_RESOURCE_ENTERPRISE_BUNDLE_PREFIX
          Prefix of enterprise resource bundle names (property files with software messages, value: "EntMessages").
static String APPLICATION_SUPPORT_CONTACT
          Application support page URL (value: "http://www.t-plan.com/support.html").
static String APPLICATION_VERSION
          Version identifier (value: "2.3.5").
static Object lc
           
 
Constructor Summary
ApplicationSupport()
          Constructor.
 
Method Summary
 void addLicenseListener(LicenseListener listener)
          Add a listener interested in license usage notifications.
 void configurationChanged(ConfigurationChangeEvent evt)
          Implementation of the ConfigurationChangeListener interface.
 AutomatedRunnable createAutomatedRunnable(JavaTestScript testScript, String threadId, String[] argv, PrintStream logStream, boolean exitOnFinish)
          Create an automated runnable prepared to execute a compiled Java test script.
 AutomatedRunnable createAutomatedRunnable(String threadId, String[] argv, PrintStream logStream, boolean exitOnFinish)
          Create an automated testing thread.
static InputStream getImageAsStream(String name)
          Get input stream of an image from the image repository.
static ImageIcon getImageIcon(String name)
          Get an icon from the image repository.
static String[] getInputArguments()
          Get the input CLI arguments.
static Locale getLocale()
          Get the locale that this program was originally started in.
static CustomPropertyResourceBundle getResourceBundle()
          Get the resource bundle.
static String getString(String key)
          Get a string from the resource bundle.
static void loadConfiguration()
           
static void logFine(String msg)
          Log a message into the log stream, level "FINE".
static void logInfo(String msg)
          Log a message into the log stream, level "INFO".
static void logSevere(String msg)
          Log a message into the log stream, level "SEVERE".
static void main(String[] argv)
          Main application method.
 void removeLicenseListener(LicenseListener listener)
          Remove an object from the list of license listeners.
static void setResourceBundle(CustomPropertyResourceBundle r)
          Set the resource bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_NAME

public static final String APPLICATION_NAME
Product name (value: "T-Plan Robot Enterprise").

See Also:
Constant Field Values

APPLICATION_VERSION

public static final String APPLICATION_VERSION

Version identifier (value: "2.3.5"). See the T-Plan Robot Enterprise roadmap for information on builds, releases and versioning.

The variable is manually updated before each release. Please avoid changing the variable name or moving it to another class because it's value is parsed by the building scripts.

See Also:
Constant Field Values

APPLICATION_BUILD

public static final String APPLICATION_BUILD

Build identifier (value: "2.3.5-20120711.1"). See the T-Plan Robot Enterprise roadmap for information on builds, releases and versioning.

The variable is manually updated before each release. Please avoid changing the variable name or moving it to another class because it's value is parsed by the building scripts.

See Also:
Constant Field Values

APPLICATION_HOME_PAGE

public static final String APPLICATION_HOME_PAGE
Application home page URL (value: "http://www.t-plan.com/robot"). It gets displayed in several places throughout the application. It is also used as home page link by all internal plugins.

See Also:
Constant Field Values

APPLICATION_SUPPORT_CONTACT

public static final String APPLICATION_SUPPORT_CONTACT
Application support page URL (value: "http://www.t-plan.com/support.html"). It gets displayed in several places throughout the application. It is also used as support contact by all internal plugins.

See Also:
Constant Field Values

APPLICATION_DOC_DIR_NAME

public static final String APPLICATION_DOC_DIR_NAME
Name of the online docs/ subdirectory containing this product documentation.

See Also:
Constant Field Values

APPLICATION_LICENSE_FILE

public static final String APPLICATION_LICENSE_FILE
Application license file name. It must be bundled with the code in the same folder as this class.

See Also:
Constant Field Values

APPLICATION_RESOURCE_BUNDLE_PREFIX

public static final String APPLICATION_RESOURCE_BUNDLE_PREFIX
Prefix of resource bundle names (property files with software messages, value: "Messages"). Default value is "Messages". When the application starts, it looks for all property files starting with this prefix, for example Messages_en.properties or Messages_de_DE.properties. A valid name of resource bundle is [prefix]_[lang]_[country].properties or [prefix]_[lang].properties.

See Also:
Constant Field Values

APPLICATION_RESOURCE_ENTERPRISE_BUNDLE_PREFIX

public static final String APPLICATION_RESOURCE_ENTERPRISE_BUNDLE_PREFIX
Prefix of enterprise resource bundle names (property files with software messages, value: "EntMessages"). Default value is "Messages". When the application starts, it looks for all property files starting with this prefix, for example Messages_en.properties or Messages_de_DE.properties. A valid name of resource bundle is [prefix]_[lang]_[country].properties or [prefix]_[lang].properties.

See Also:
Constant Field Values

APPLICATION_CONFIG_FILE

public static final String APPLICATION_CONFIG_FILE
Configuration file path. The application looks for the file upon startup. When it exists, all valid configuration values defined in this file will override the default ones.


APPLICATION_LEGACY_CONFIG_FILE

public static final String APPLICATION_LEGACY_CONFIG_FILE
Legacy v1.x configuration file path. We parse it if it exists and map int onto the new configuration keys.


APPLICATION_LOG_FILE_PREFIX

public static final String APPLICATION_LOG_FILE_PREFIX
Log file name prefix (value: "tplan_robot").

See Also:
Constant Field Values

APPLICATION_BASE_PACKAGE

public static final String APPLICATION_BASE_PACKAGE
Base Java package name ("com.tplan.robot"). This variable is parsed by the build scripts and used as a path prefix. If the code gets refactored and the base package name is changed, update value of this variable and rebuild the documentation to update the content.

See Also:
Constant Field Values

APPLICATION_HELP_SET_FILE

public static final String APPLICATION_HELP_SET_FILE
Name of the application JavaHelp help set file (*.hs).

See Also:
Constant Field Values

APPLICATION_HELP_SET_DIR

public static final String APPLICATION_HELP_SET_DIR
Root folder of the installed help files.

See Also:
Constant Field Values

APPLICATION_CLI_OPTIONS

public static final String[][] APPLICATION_CLI_OPTIONS

Array of application CLI options. These are the public options described in the documentation.

These options are processed by the private method parseParameters() of this class.

Apart from the official options there's a smaller list of debug flags which can be passed through CLI using the -D parameter of the java command. Each such a flag switches on one hidden feature, typically a debugging output of certain module. To obtain a list of these hidden flags run the application with the --hidden CLI option.


lc

public static Object lc
Constructor Detail

ApplicationSupport

public ApplicationSupport()
Constructor.

Method Detail

main

public static void main(String[] argv)
                 throws Exception
Main application method. It creates an instance of this class, an automation thread (a AutomatedRunnable instance) and starts it.

Parameters:
argv - array of application parameters
Throws:
Exception
See Also:
AutomatedRunnable

addLicenseListener

public void addLicenseListener(LicenseListener listener)
Add a listener interested in license usage notifications. See the LicenseListener interface for details.

Parameters:
listener - a license listener. If the listener is already registered, it is not added again to avoid duplicate registrations of the same object.

removeLicenseListener

public void removeLicenseListener(LicenseListener listener)
Remove an object from the list of license listeners. If the argument object is not registered in the list, the method should do nothing.

Parameters:
listener - an object implementing the LicenseListener interface.

getLocale

public static Locale getLocale()
Get the locale that this program was originally started in.

Returns:
program locale.

getInputArguments

public static String[] getInputArguments()
Get the input CLI arguments.

Returns:
CLI arguments.

createAutomatedRunnable

public AutomatedRunnable createAutomatedRunnable(JavaTestScript testScript,
                                                 String threadId,
                                                 String[] argv,
                                                 PrintStream logStream,
                                                 boolean exitOnFinish)

Create an automated runnable prepared to execute a compiled Java test script. The method can be also used to display the product GUI.

Only one runnable can be executed at one moment in GUI mode. There's no limitation in CLI mode and this method can be used in a Java program to create a larger number of independent automated testing threads. See the AutomatedRunnable interface documentation for an example.

Parameters:
testScript - a Java test script to execute in the runnable run() method. The argument may be null provided that the thread is set to run in GUI mode (i.e. the argv[] array doesn't contain the -n/--nodisplay parameter). When such a thread is started it just displays the product GUI.
threadId - a unique string (name) identifying the process, e.g. "my automated task #1". The name is currently not used in any way except to name the thread. Users may take advantage of the name to identify their threads in custom Java programs through methods of java.lang.Thread and java.lang.ThreadGroup.
argv - a string array with CLI options. The parameters are provided the same way as if the product is started from command line. To obtain a complete list of available options see the T-Plan Robot Enterprise CLI Options document and T-Plan Robot Enterprise documentation or run the application with the --help option. Options followed by a value should be specified as two strings in the array, for example new String[] { "--connect", "localhost:1", "--password", "welcome" }.
logStream - a stream for logs from the test script execution. All messages printed out into console in CLI mode will be written to the logStream. To print the logs into the console window use System.out as value. A null value of this argument will suppress all log messages.
exitOnFinish - indicates whether the process should terminate the Java process using System.exit(exitCode) after the automated task gets finished. Third party applications should use the value of false to prevent termination of their Java VM.
Returns:
a new automated testing thread ready to be started.

createAutomatedRunnable

public AutomatedRunnable createAutomatedRunnable(String threadId,
                                                 String[] argv,
                                                 PrintStream logStream,
                                                 boolean exitOnFinish)

Create an automated testing thread. If a test script in the proprietary scripting language is passed among the argv parameters through the -r/--run option, it will be executed.

Only one thread can be created in GUI mode. There's no limitation in CLI mode and this method can be used in a Java program to create a larger number of independent automated testing threads. See the AutomatedRunnable interface documentation for an example.

Parameters:
threadId - a unique string (name) identifying the process, e.g. "my automated task #1". The name is currently not used in any way except to name the thread. Users may take advantage of the name to identify their threads in custom Java programs through methods of java.lang.Thread and java.lang.ThreadGroup.
argv - a string array with CLI options. The parameters are provided the same way as if the product is started from command line. To obtain a complete list of available options see the T-Plan Robot Enterprise CLI Options document or run the application with the --help option. Options followed by a value should be specified as two strings in the array, for example new String[] { "--connect", "localhost:1", "--password", "welcome" }.
logStream - a stream for logs from the test script execution. All messages printed out into console in CLI mode will be written to the logStream. To print the logs into the console window use System.out as value. A null value of this argument will suppress all log messages.
exitOnFinish - indicates whether the process should terminate the Java process using System.exit(exitCode) after the automated task gets finished. Third party applications should use the value of false to prevent termination of their Java VM.
Returns:
a new automated testing thread ready to be started.

logSevere

public static void logSevere(String msg)
Log a message into the log stream, level "SEVERE".

Parameters:
msg - a log message.

logInfo

public static void logInfo(String msg)
Log a message into the log stream, level "INFO".

Parameters:
msg - a log message.

logFine

public static void logFine(String msg)
Log a message into the log stream, level "FINE".

Parameters:
msg - a log message.

configurationChanged

public void configurationChanged(ConfigurationChangeEvent evt)
Implementation of the ConfigurationChangeListener interface. Whenever the user configuration changes, the method reloads preferences used by this class.

Specified by:
configurationChanged in interface ConfigurationChangeListener
Parameters:
evt - a ConfigurationChangeEvent which describes the change of user configuration.

loadConfiguration

public static void loadConfiguration()
                              throws MissingResourceException
Throws:
MissingResourceException

getResourceBundle

public static CustomPropertyResourceBundle getResourceBundle()

Get the resource bundle. It is an object with all software messages. This class is exclusive owner of the bundle and all other classes are supposed to access it through this static method.

The method is null-safe meaning that it loads the resource bundle on the first call.

Returns:
application resource bundle with all software messages.

getString

public static String getString(String key)
Get a string from the resource bundle. This is just a convenience method calling getResourceBundle().getString(key).

Parameters:
key - a message key.
Returns:
message from the resource bundle associated with the given key.

setResourceBundle

public static void setResourceBundle(CustomPropertyResourceBundle r)
Set the resource bundle. It is an object with all software messages. This class is exclusive owner of the bundle and all other classes are supposed to access it through the getResourceBundle() static method.

Parameters:
r - a new resource bundle.

getImageIcon

public static ImageIcon getImageIcon(String name)
Get an icon from the image repository.

Parameters:
name - image file name, for example "ok15.gif".
Returns:
a new image icon.

getImageAsStream

public static InputStream getImageAsStream(String name)
Get input stream of an image from the image repository.

Parameters:
name - image file name, for example "ok15.gif".
Returns:
input file with the image data.

T-Plan Robot Enterprise 2.3.5
Build No. 2.3.5-20120711.1