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:
UserConfiguration
).
It contains configurable program parameters. If user's home folder contains a
configuration file with name specified by the APPLICATION_CONFIG_FILE
,
the user configuration object is loaded with the parameters from the file.ImageLoader
).
It is a dummy class used to load icons and logo images bundled together with the product code.createAutomatedRunnable(com.tplan.robot.scripting.JavaTestScript, java.lang.String, java.lang.String[], java.io.PrintStream, boolean)
method
which parses and verifies the CLI options and creates the default automation
thread (a AutomatedRunnableImpl
instance). The thread is then executed
and it starts the GUI or executes just in CLI depending on the execution mode flag passed
through the CLI options (default mode is GUI).The class is also owner of global objects and services which are used widely across all project classes. They are:
getResourceBundle()
static method.getImageIcon(String)
method to get an ImageIcon instance directly
or the getImageAsStream(String)
method to get the image file as an InputStream
.logSevere(String)
,
logInfo(String)
and logFine(String)
.T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static String |
APPLICATION_BASE_PACKAGE
Base Java package name ("com.tplan.robot").
|
static String |
APPLICATION_BUILD
Build identifier (value: "7.0-20221014.1").
|
static String[][] |
APPLICATION_CLI_OPTIONS
Array of application CLI options.
|
static String |
APPLICATION_CONFIG_DIR |
static String |
APPLICATION_CONFIG_FILE
Configuration file path.
|
static String |
APPLICATION_DOC_DIR_NAME
Name of the online docs/ subdirectory containing this product documentation
(value: "v6.3ee").
|
static String |
APPLICATION_DOC_HOME_PAGE
Online document home page URL.
|
static boolean |
APPLICATION_ENABLE_TPP
Name for the log file directory in the system temporary path.
|
static String |
APPLICATION_HELP_HOME_PAGE
Root folder of the online product help.
|
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.
|
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_DIR_NAME
Name for the log file directory in the system temporary path.
|
static String |
APPLICATION_NAME
Product name.
|
static String |
APPLICATION_NAME_SHORT
Short product name (since 4.4.2).
|
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: "Bundle").
|
static String |
APPLICATION_SUPPORT_CONTACT
Application support page URL.
|
static String |
APPLICATION_SUPPORT_EMAIL
Application support E-mail.
|
static String |
APPLICATION_TUTORIAL_HOME_PAGE
Online tutorial home page URL.
|
static String |
APPLICATION_VERSION
Version identifier (value: "7.0").
|
static Object |
lc |
static String |
VENDOR_HOME_PAGE
Vendor home page.
|
static String |
VENDOR_NAME
Vendor name.
|
Constructor and Description |
---|
ApplicationSupport()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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(Schedule schedule,
String threadId,
String[] argv,
PrintStream logStream,
boolean exitOnFinish)
Create an automated runnable prepared to execute a
schedule (test suite) . |
AutomatedRunnable |
createAutomatedRunnable(String threadId,
String[] argv,
PrintStream logStream,
boolean exitOnFinish)
Create an automated testing thread.
|
static List<Locale> |
getAvailableLocales()
Get the list of supported locales (resource bundles aka language packs).
|
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 String |
getOnlineHelpHome()
Get URL of the online help home folder.
|
static String |
getOnlineHelpPage(String relativePath)
Get URL of an online help topic.
|
static String |
getProperty(String name)
Get a build property.
|
static com.tplan.robot.l10n.CustomPropertyResourceBundle |
getResourceBundle()
Get the resource bundle.
|
static ApplicationSupport |
getSharedInstance() |
static String |
getString(String key)
Get a string from the resource bundle.
|
static String |
getString(String key,
Object... messageFormatArgs)
Get a string from the resource bundle and populate its MessageFormat
parameters.
|
static boolean |
isGUIMode()
Test if the tool is running in the GUI mode.
|
static boolean |
isStartedAsService()
Indicate whether the process was started in the service mode, i.e.
|
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.It creates an instance of this class, an
automation thread (a
AutomatedRunnable instance) and starts
it. |
boolean |
parseParameters(String[] argv,
Map clientParams,
Map scriptVariables,
Map options,
Map guiParams,
Map scriptingParams,
boolean postValidate)
Parse CLI options which were used to start the application.
|
boolean |
parseParameters(String[] argv,
Map clientParams,
Map scriptVariables,
Map options,
Map guiParams,
Map scriptingParams,
boolean postValidate,
StringBuilder err) |
void |
removeLicenseListener(LicenseListener listener)
Remove an object from the list of license listeners.
|
static void |
setLocale(Locale locale)
Set the current locale.
|
static void |
setResourceBundle(com.tplan.robot.l10n.CustomPropertyResourceBundle r)
Set the resource bundle.
|
static void |
updateLookAndFeel() |
static void |
updateLookAndFeel(boolean saveToRecents) |
public static final String APPLICATION_VERSION
Version identifier (value: "7.0"). 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.
public static final String APPLICATION_BUILD
Build identifier (value: "7.0-20221014.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.
public static final String APPLICATION_DOC_DIR_NAME
public static final String APPLICATION_HELP_HOME_PAGE
public static final String APPLICATION_NAME
public static final String APPLICATION_NAME_SHORT
public static final String APPLICATION_HOME_PAGE
public static final String VENDOR_NAME
public static final String VENDOR_HOME_PAGE
public static final String APPLICATION_DOC_HOME_PAGE
public static final String APPLICATION_TUTORIAL_HOME_PAGE
public static final String APPLICATION_SUPPORT_CONTACT
public static final String APPLICATION_SUPPORT_EMAIL
public static final String APPLICATION_LOG_FILE_DIR_NAME
public static final boolean APPLICATION_ENABLE_TPP
public static final String APPLICATION_LICENSE_FILE
public static final String APPLICATION_RESOURCE_BUNDLE_PREFIX
public static final String APPLICATION_RESOURCE_ENTERPRISE_BUNDLE_PREFIX
public static String APPLICATION_CONFIG_FILE
Configuration file path. The application loads the file upon startup.
Since release 4.0 the field is not final to enable functionality of the
--cfg
CLI option. At the programmatic level it may be
customized prior to the first call of this class' constructor.
A subsequent change of this field will not cause the process to reload
the configuration but it will make it save the preferences to the new
location.
public static String APPLICATION_CONFIG_DIR
public static final String APPLICATION_LEGACY_CONFIG_FILE
public static final String APPLICATION_BASE_PACKAGE
public static final String APPLICATION_HELP_SET_FILE
public static final String APPLICATION_HELP_SET_DIR
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.
public static Object lc
public static boolean isGUIMode()
public static boolean isStartedAsService()
--service
CLI option.public static String getProperty(String name)
name
- property name.public static ApplicationSupport getSharedInstance()
public static void main(String[] argv) throws Exception
AutomatedRunnable
instance) and starts
it.argv
- array of application parametersException
- on a critical application start up error.AutomatedRunnable
public void addLicenseListener(LicenseListener listener)
LicenseListener
interface for details.listener
- a license listener. If the listener is already registered,
it is not added again to avoid duplicate registrations of the same object.public void removeLicenseListener(LicenseListener listener)
listener
- an object implementing the LicenseListener
interface.public static Locale getLocale()
public static String[] getInputArguments()
public static void updateLookAndFeel()
public static void updateLookAndFeel(boolean saveToRecents)
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.
IMPORTANT: The runnable is stateful and not thread safe. Do not use a single instance repeatedly or in multiple threads. Always create a new instance for each execution process.
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.public AutomatedRunnable createAutomatedRunnable(Schedule schedule, String threadId, String[] argv, PrintStream logStream, boolean exitOnFinish)
Create an automated runnable prepared to execute a schedule (test suite)
.
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.
IMPORTANT: The runnable is stateful and not thread safe. Do not use a single instance repeatedly or in multiple threads. Always create a new instance for each execution process.
schedule
- a schedule.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.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.
IMPORTANT: The runnable is stateful and not thread safe. Do not use a single instance repeatedly or in multiple threads. Always create a new instance for each execution process.
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.public static void logSevere(String msg)
msg
- a log message.public static void logInfo(String msg)
msg
- a log message.public static void logFine(String msg)
msg
- a log message.public boolean parseParameters(String[] argv, Map clientParams, Map scriptVariables, Map options, Map guiParams, Map scriptingParams, boolean postValidate)
argv
- a string array with CLI options. 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.clientParams
- a table to store client specific parameters resulting
from parsing of the options, e.g. host name, port, password etc.scriptVariables
- a table to store script variables passed through
the -v
CLI option.options
- a table to store overridden user options passed through
the -o
CLI option.guiParams
- a table to store GUI specific parameters resulting
from parsing of the options.scriptingParams
- a table to store scripting specific parameters resulting
from parsing of the options, e.g. disabling of output (option --nooutput
).postValidate
- whether to perform post validation of the parameters.public boolean parseParameters(String[] argv, Map clientParams, Map scriptVariables, Map options, Map guiParams, Map scriptingParams, boolean postValidate, StringBuilder err)
public void configurationChanged(ConfigurationChangeEvent evt)
configurationChanged
in interface ConfigurationChangeListener
evt
- a ConfigurationChangeEvent which describes the change of
user configuration.public static void loadConfiguration() throws MissingResourceException
MissingResourceException
public static com.tplan.robot.l10n.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.
public static String getString(String key)
getResourceBundle().getString(key)
.key
- a message key.public static String getString(String key, Object... messageFormatArgs)
key
- a message key.messageFormatArgs
- message format arguments.MessageFormat
.public static void setResourceBundle(com.tplan.robot.l10n.CustomPropertyResourceBundle r)
getResourceBundle()
static method.r
- a new resource bundle.public static void setLocale(Locale locale)
locale
- the new locale.public static ImageIcon getImageIcon(String name)
name
- image file name, for example "ok15.gif".public static InputStream getImageAsStream(String name)
name
- image file name, for example "ok15.gif".public static String getOnlineHelpHome()
APPLICATION_HELP_HOME_PAGE
variable.public static String getOnlineHelpPage(String relativePath)
getOnlineHelpHome()
.relativePath
- relative help path with regard to the help home, for
example "install/install.html" for the Release Notes document.