public class XSLReportProvider extends Object implements Plugin, ReportProvider, Configurable, ScriptListener, ActionListener, CommandListener, ConfigurationChangeListener, ExtendedParamsObject, PropertyChangeListener, LocalizedPlugin
Enterprise Report Provider. It is a highly customizable report generator capable of creating reports in XML and HTML formats.
The class works on top of another internal enterprise feature - test result XML generator. It is an object able to create an XML with test results and output objects created by the test script, sucFh as test suites declarations, scripts (test cases), test steps, screenshots, warnings, image comparisons etc.
The report provider takes an advantage of the test result XML to produce a report through an XSL transformation:
.xml
extension), the provider
just inserts a link to the XSL file into the test result XML, making it
displayable by any XSL-compliant web browser. As most recent web browsers
support the XML/XSL transformation, the XML report may be then viewed by any
web browser the same way as HTML or parsed by any other third party tool. See
an online Sample
XML Report example.
.htm
or .html
), the provider performs
transformation of the test result XML using the given XSL file to produce an
HTML report.There is a default XSL file bundled with the code which transforms the test result data to the same visual report format as the default HTML provider distributed with the free T-Plan Robot Enterprise version. The file delivers exactly the same functionality and it even uses the same preference values. The added value of the Enterprise Report Provider is that it allows to customize the report through a custom XSL file. This way the report appearance may be radically changed to comply with individual needs.
For example, to change the logo image in the test report perform the following steps:
That's it! The next time you execute a test script with the Report command, it will use your custom XSL template to create the report with your logo. It will also copy the logo image file to the output folder to make it accessible by the report.
The XSL template allows to customize the report in any way. Should you want to learn more about XSL format and transformations, we suggest you to review the following resources:
wikipedia.org
,w3schools.com
,Be however aware that XSL transformations are resource intensive. As the report gets refreshed every time the status changes or a new output object is created, it may decrease performance of the whole tool, especially in test scripts with a large number of output objects. Should you experience any delays or low performance, consider one of the following steps:
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static DateFormat |
DURATION_DATE_TIME_FORMAT |
static String |
INTERNAL_XSL_FILE
Name of the internal XSL file.
|
static String |
PARAM_ONEXIT |
static int |
STATUS_CODE_FAIL |
static int |
STATUS_CODE_PAUSED |
static int |
STATUS_CODE_RUNNING |
static int |
STATUS_CODE_STOPPED |
static int |
STATUS_CODE_SUCCESS |
static int |
STATUS_CODE_UNKNOWN |
static String |
XSL_CONFIG_ATTACH_SCRIPTS
XSL property - attach script configuration flag.
|
static String |
XSL_CONFIG_ATTACH_TEMPLATES
XSL property - attach template images configuration flag.
|
static String |
XSL_CONFIG_CREATE_COMMENT_TABLE
XSL property - create warning table configuration flag.
|
static String |
XSL_CONFIG_CREATE_COMPARISON_TABLE
XSL property - create image comparison table configuration flag.
|
static String |
XSL_CONFIG_CREATE_WARNING_TABLE
XSL property - create warning table configuration flag.
|
static String |
XSL_CONFIG_DISPLAY_FAILED_COMPARISONS_ONLY
XSL property - create image comparison table configuration flag.
|
static String |
XSL_CONFIG_DISPLAY_WARNINGS
XSL property - display warnings in the HTML body configuration flag.
|
static String |
XSL_CONFIG_INCLUDE_STEPS_IN_BODY
XSL property - create warning table configuration flag.
|
static String |
XSL_PARAM_DURATION_SECONDS
XSL property - number of seconds.
|
static String |
XSL_PARAM_DURATION_STRING
XSL property - a string expressing start and end date and duration of
automation.
|
static String |
XSL_PARAM_END_TIME |
static String |
XSL_PARAM_LOG_FILE
XSL property - log file.
|
static String |
XSL_PARAM_PAUSE_REASON
XSL property - pause reason.
|
static String |
XSL_PARAM_SCRIPT_UID |
static String |
XSL_PARAM_START_TIME |
static String |
XSL_PARAM_STATUS
XSL property - status code.
|
Constructor and Description |
---|
XSLReportProvider() |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Implementation of the ActionListener interface.
|
void |
checkDependencies(PluginManager manager)
Check whether the current product installation contains all dependencies
(other plugins) required to install this plugin.
|
void |
commandEvent(CommandEvent e)
This method is called when a command handler fires an event.
|
void |
configurationChanged(ConfigurationChangeEvent evt)
This method gets called when a configuration parameter is changed.
|
int |
create(ScriptingContext context,
Map params)
Create a report.
|
String |
getCode()
Get plugin code.
|
Date |
getDate()
Get plugin release date.
|
String |
getDescription()
Get plugin description to be displayed in the GUI.
|
String |
getDisplayName()
Get short plugin name to be displayed in the GUI.
|
String |
getDisplayNameKey()
Get the key to the plugin name in the resource bundle.
|
Class |
getImplementedInterface()
Get Class of the exposed functional interface that this plugin implements.
|
String |
getLongDescription()
Get long description of the object - purpose, usage, parameter syntax etc.
|
int[] |
getLowestSupportedVersion()
Get the lowest required version of T-Plan Robot Enterprise.
|
String |
getMessageAfterInstall()
Get text of a message to be displayed after installation of this plugin.
|
String |
getMessageBeforeInstall()
Get text of a message to be displayed before installation of this plugin.
|
List<String> |
getParameters()
Get the list of parameter names supported by the object implementing this
interface.
|
List |
getParameterValues(String parameterName)
Get the list of acceptable values of a particular parameter (if known).
|
List<Preference> |
getPreferences()
Get metadata of displayable/editable configurable parameters.
|
String |
getShortDescription()
Get short description which describes in a few words purpose and role of
the object.
|
String |
getSupportContact()
Get support contact.
|
String[] |
getSupportedFormats()
Get formats supported by this particular provider.
|
String |
getUniqueId()
Get unique ID associated with the plugin.
|
String |
getVendorHomePage()
Get the vendor home page.
|
String |
getVendorName()
Get vendor (provider) name to be displayed in the GUI.
|
int[] |
getVersion()
Get plugin version in form of an integer array.
|
List<Preference> |
getVisualParameters()
Get the list of supported parameters encapsulated in
Preference
instances. |
boolean |
isOfflineMode() |
void |
propertyChange(PropertyChangeEvent evt) |
boolean |
requiresRestart()
Indicate whether installation of this plugin requires application restart.
|
void |
scriptEvent(ScriptEvent event)
Gets called when a script event is available.
|
void |
setConfiguration(UserConfiguration cfg)
If an object implementing this interface is a plugin (i.e.
|
void |
setOfflineMode(boolean offlineMode) |
void |
setParameters(Map<String,String> paramsAndValues)
Set parameters and their values in the object.
|
public static String INTERNAL_XSL_FILE
public static final String XSL_PARAM_DURATION_STRING
public static final String XSL_PARAM_DURATION_SECONDS
public static final String XSL_PARAM_STATUS
public static final String XSL_PARAM_PAUSE_REASON
public static final String XSL_PARAM_LOG_FILE
public static final String XSL_CONFIG_ATTACH_SCRIPTS
public static final String XSL_CONFIG_CREATE_WARNING_TABLE
public static final String XSL_CONFIG_CREATE_COMMENT_TABLE
public static final String XSL_CONFIG_INCLUDE_STEPS_IN_BODY
public static final String XSL_CONFIG_DISPLAY_WARNINGS
public static final String XSL_CONFIG_ATTACH_TEMPLATES
public static final String XSL_CONFIG_CREATE_COMPARISON_TABLE
public static final String XSL_CONFIG_DISPLAY_FAILED_COMPARISONS_ONLY
public static final int STATUS_CODE_RUNNING
public static final int STATUS_CODE_PAUSED
public static final int STATUS_CODE_STOPPED
public static final int STATUS_CODE_FAIL
public static final int STATUS_CODE_SUCCESS
public static final int STATUS_CODE_UNKNOWN
public static final DateFormat DURATION_DATE_TIME_FORMAT
public static final String XSL_PARAM_START_TIME
public static final String XSL_PARAM_END_TIME
public static final String XSL_PARAM_SCRIPT_UID
public static final String PARAM_ONEXIT
public String[] getSupportedFormats()
ReportProvider
Get formats supported by this particular provider. The formats are not
case sensitive and they must correspond to the supported file extensions.
For example, a provider able to generate XML, HTML and Excel formats should
return new String[] {"xml", "html", "htm", "xls"}
.
The method is used by the calling Report instance to validate file name provided by the script command. If the file doesn't have one of the extensions supported by the selected provider, a syntax error is reported.
getSupportedFormats
in interface ReportProvider
public int create(ScriptingContext context, Map params)
create
in interface ReportProvider
context
- an execution context.params
- Report command argument map.public void actionPerformed(ActionEvent e)
Implementation of the ActionListener interface.
This method is at present used just by the state update timer which invokes this method at regular intervals. The method then creates a screenshot of the RFB buffer and saves it into a so called state image. A link to this image is then elaborated into the report as a view of the current state.
This class uses its own instance of the ScreenshotCommand class because we don't want the default ScreenshotCommand class to fire all the listeners which would make the report command to re-create the HTML report and even include the state image into the report body.
actionPerformed
in interface ActionListener
e
- an action event.public void scriptEvent(ScriptEvent event)
ScriptListener
scriptEvent
in interface ScriptListener
event
- a script event.public void commandEvent(CommandEvent e)
CommandListener
commandEvent
in interface CommandListener
e
- a command event.public void configurationChanged(ConfigurationChangeEvent evt)
ConfigurationChangeListener
configurationChanged
in interface ConfigurationChangeListener
evt
- A ConfigurationChangeEvent object describing the event source
and the parameter that has changed.public List<Preference> getPreferences()
Configurable
getPreferences
in interface Configurable
public String getCode()
Plugin
Get plugin code. This string serves as an identifier of the functionality delivered by the plugin. For example, desktop client plugins return protocol name like "RFB" or "RDP" as their code.
Plugin code is used by pluggable instance factories to identify
a particular plugin. It may be used to replace internal plugins with
third party code. For
example if you develop a class which implements this and the
com.tplan.robot.remoteclient.RemoteDesktop
interfaces and the
getCode()
method returns "RFB", it will replace the internal
implementation of the RFB (VNC) client.
getCode
in interface Plugin
getCode
in interface ReportProvider
public String getDisplayName()
Plugin
getDisplayName
in interface Plugin
public String getDisplayNameKey()
LocalizedPlugin
getDisplayNameKey
in interface LocalizedPlugin
public String getDescription()
Plugin
getDescription
in interface Plugin
public String getVendorName()
Plugin
getVendorName
in interface Plugin
public String getSupportContact()
Plugin
getSupportContact
in interface Plugin
public int[] getVersion()
Plugin
new int[] { 1, 2, 3 }
.getVersion
in interface Plugin
public Class getImplementedInterface()
Plugin
com.tplan.robot.remoteclient.RemoteDesktopClient.class
.getImplementedInterface
in interface Plugin
public boolean requiresRestart()
Plugin
requiresRestart
in interface Plugin
public String getVendorHomePage()
Plugin
getVendorHomePage
in interface Plugin
public String getUniqueId()
Plugin
Get unique ID associated with the plugin. The plugin manager uses the ID together with the version string to identify whether a plugin is already installed and whether a newer version of the same plugin is available.
The unique ID in fact identifies a particular plugin delivered by a particular vendor. Plugin developers are recommended to choose an ID and keep it constant for all versions of one particular plugin. The ID is never displayed in the GUI so it doesn't have to be a readable text. To avoid conflicts with other vendors it is recommended to elaborate vendor or author name and feature description into the ID, for example "custom RFB client implemented by John Doe".
getUniqueId
in interface Plugin
public int[] getLowestSupportedVersion()
Plugin
getLowestSupportedVersion
in interface Plugin
public String getMessageBeforeInstall()
Plugin
getMessageBeforeInstall
in interface Plugin
public String getMessageAfterInstall()
Plugin
getMessageAfterInstall
in interface Plugin
public void checkDependencies(PluginManager manager) throws DependencyMissingException
Plugin
DependencyMissingException
if one or more dependencies are missing.checkDependencies
in interface Plugin
manager
- shared instance of the plugin manager.DependencyMissingException
- when one or more dependencies requested by this plugin is missing.public void setConfiguration(UserConfiguration cfg)
Configurable
If an object implementing this interface is a plugin (i.e. implements also the Plugin interface) and is instantiated through a supported plugin factory, the Plugin Manager calls this method right after an instance of this object is created.
Custom objects which do not already have their configuration parameters in
the default configuration file should take advantage of this method
to store their configuration into the shared User Configuration instance.
It is recommended to call the UserConfiguration.saveConfiguration()
method in the end to save the configuration to the hard drive.
Objects wishing to be notified of changes of configuration parameters
should implement the ConfigurationChangeListener interface and register
with the UserConfiguration instance through the
addConfigurationChangeListener()
method.
setConfiguration
in interface Configurable
cfg
- global shared instance of user configuration preloaded with
parameters from the default and user configuration files.public boolean isOfflineMode()
public void setOfflineMode(boolean offlineMode)
offlineMode
- the offlineMode to setpublic List<String> getParameters()
ExtendedParamsObject
getParameters
in interface ExtendedParamsObject
public List getParameterValues(String parameterName)
ExtendedParamsObject
getParameterValues
in interface ExtendedParamsObject
parameterName
- parameter namepublic void setParameters(Map<String,String> paramsAndValues)
ExtendedParamsObject
CaseTolerantHashMap
class);setParameters
in interface ExtendedParamsObject
paramsAndValues
- map of parameters and their values.public List<Preference> getVisualParameters()
ExtendedParamsObject
Preference
instances. It allows to specify a larger set of parameter properties such as
parameter name ("configuration key" in the Preferences object), label (short description),
description, expected value type and optional value limits and relationships with other
parameters. This allows the GUI to build and display the parameters in form of GUI components
in command property dialogs and validate the values entered by users..getVisualParameters
in interface ExtendedParamsObject
Preference
instances.public String getShortDescription()
ExtendedParamsObject
getShortDescription
in interface ExtendedParamsObject
public String getLongDescription()
ExtendedParamsObject
CustomHyperlinkListener
. This is optional
and the method may return null. The long description is typically
displayed by the GUI when user selects to view details of the object.getLongDescription
in interface ExtendedParamsObject
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener