|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.team.fvt.tests.scenario.ScenarioUtils
public class ScenarioUtils
Utils for Scenario tests execution.
The first utility is to read Scenario parameters.
They can be defined either in a properties files specified by the System
property PARAM_FILE_PATH_ID
or directly by System properties
specified in the VM arguments tab of the launch configuration.
The second utility is to provide debug function allowing to dump debug
information either in the console or in a file if the System property
DEBUG_DIRECTORY
is set.
This class also provides following utilities:
createDir(String)
, createDir(String, String)
Directory creation
elapsedTimeString(long)
Returns a string to display the elasped time since the given start point.
Field Summary | |
---|---|
static java.text.SimpleDateFormat |
COMPACT_DATE_FORMAT
|
static java.lang.String |
COMPACT_DATE_STRING
|
static boolean |
DEBUG
Global flag whether to print debug information on console or not. |
static java.lang.String |
DEBUG_DIRECTORY
Returns the directory to use to store debug file. |
static java.lang.String |
EMPTY_STRING
|
static java.lang.String |
LINE_SEPARATOR
|
static java.lang.String |
LOG_FILE_NAME
Parameter telling which directory to use to put debug file. |
static int |
MAX_RECOVERY_TRIES
|
static long |
ONE_HOUR
|
static int |
ONE_MINUTE
|
static boolean |
PRINT
Global flag whether to print output on console or not. |
static java.lang.String |
SPACE_STRING
|
static java.text.SimpleDateFormat |
TIME_FORMAT
|
static java.lang.String |
USER_DIR_ID
|
Constructor Summary | |
---|---|
ScenarioUtils()
|
Method Summary | |
---|---|
static java.io.File |
createDir(java.lang.String dirPath)
Return the File corresponding to the given path. |
static java.io.File |
createDir(java.lang.String dirPath,
java.lang.String subdirName)
Return the File corresponding to the given path and the sub-directory. |
static void |
debugClose()
Close the debug stream. |
static void |
debugOpen()
Open debug stream. |
static void |
debugPrint(java.lang.String text)
Print a text in the debug stream. |
static void |
debugPrintException(java.lang.Throwable t)
Print only meaningful element of an exception statck trace |
static void |
debugPrintExpectedStrings(java.lang.String kind,
java.lang.String status,
java.lang.String... strings)
Debug method to print expected strings of a given kind of HTML element. |
static void |
debugPrintln()
Print a new line in the debug stream. |
static void |
debugPrintln(java.lang.String... text)
Print a line in the debug stream. |
static void |
debugPrintln(java.lang.String text)
Print a line in the debug stream. |
static void |
debugPrintln(java.lang.String text,
int indent)
Print an indented line in the debug stream. |
static void |
debugPrintStackTrace(int tabs)
Print only meaningful element of the given stack trace for the caller |
static void |
debugPrintStackTrace(java.lang.StackTraceElement[] elements)
Print only meaningful element of the given stack trace |
static void |
debugPrintStackTrace(java.lang.StackTraceElement[] elements,
int tabs)
Print only meaningful element of the given stack trace |
static java.lang.String |
elapsedTimeString(long start)
Returns a string to display the elasped time since the given start point. |
static java.lang.String |
getClassSimpleName(java.lang.Class<?> clazz)
Return the class name without package prefix. |
static boolean |
getParameterBooleanValue(java.lang.String name)
Return the boolean value from the System property value set in the launch config. |
static boolean |
getParameterBooleanValue(java.lang.String name,
boolean defaultValue)
Return the boolean value from the System property value set in the launch config. |
static double |
getParameterDoubleValue(java.lang.String name)
Return the double value from the System property value set in the launch config. |
static double |
getParameterDoubleValue(java.lang.String name,
double defaultValue)
Return the double value from the System property value set in the launch config. |
static int |
getParameterIntValue(java.lang.String name)
Return the integer value from the System property value set in the launch config. |
static int |
getParameterIntValue(java.lang.String name,
int defaultValue)
Return the integer value from the System property value set in the launch config. |
static java.lang.String |
getParameterValue(java.lang.String... names)
Return the string value from the first defined System property from the list set in the launch config. |
static java.lang.String |
getParameterValue(java.lang.String name)
Return the parameter string value from the System property set in the launch config. |
static java.lang.String |
getParameterValue(java.lang.String name,
java.lang.String defaultValue)
Return the parameter string value from the System property set in the launch config. |
static java.lang.String |
getTextFromList(java.util.List<java.lang.String> strings)
Return the given strings list as a flat text separated with comma. |
static java.lang.String |
getTextFromList(java.util.List<java.lang.String> strings,
java.lang.String separator)
Return the given strings list as a flat text separated with the given separator. |
static java.lang.String |
getTextFromList(java.lang.String[] strings)
Return the given strings list as a flat text separated with comma. |
static java.lang.String |
getTextFromList(java.lang.String[] strings,
java.lang.String separator)
Return the given strings list as a flat text separated with the given separator. |
static void |
pause(int millisecs)
Pause during the given milli-seconds time. |
static void |
print(java.lang.Object text)
Print a text to the console. |
static void |
printException(java.lang.Throwable t)
Print only meaningful element of an exception statck trace |
static void |
println()
Print a empty line to the console. |
static void |
println(java.lang.Object text)
Print a text with a new line at the end to the console. |
static void |
printStackTrace(int tabs)
Print only meaningful element of the given stack trace for the caller |
static void |
printStackTrace(java.lang.StackTraceElement[] elements,
int tabs)
Print only meaningful element of the given stack trace |
static void |
printStepStart(ScenarioStep step)
Print the starting point for the given test case. |
static void |
setDebugWriter()
|
static void |
sleep(int seconds)
Sleep during the given seconds time. |
static java.lang.String |
timeString(long time)
Returns a string to display the given time as a duration formatted as: "XXXms" if the duration is less than 0.1s (e.g. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String USER_DIR_ID
public static final java.lang.String EMPTY_STRING
public static final java.lang.String SPACE_STRING
public static final java.lang.String LINE_SEPARATOR
public static final int ONE_MINUTE
public static final long ONE_HOUR
public static final java.text.SimpleDateFormat COMPACT_DATE_FORMAT
public static final java.lang.String COMPACT_DATE_STRING
public static final java.text.SimpleDateFormat TIME_FORMAT
public static final int MAX_RECOVERY_TRIES
public static final boolean DEBUG
Default is true
.
public static final java.lang.String DEBUG_DIRECTORY
To specify it, then use the following parameter:
debug.dir
String
, a valid directory name matching
the OS on which you're running the scenariodebug.dir=C:\tmp\selenium\failures
in the properties file-Ddebug.dir=C:\tmp\selenium\failures
in the VM Arguments
field of the launch configuration.
Note that this parameter is ignored even if specified when DEBUG
parameter is set to false
.
public static final java.lang.String LOG_FILE_NAME
Name: "log.file.name"
Value: String
, a valid file name matching the OS on which you're running the BVT test
Default value: debug.log
Usage: -Dlog.file.name=my_debug_file.log
in the VM Arguments
field of the launch configuration.
DEBUG
parameter
is set to false
.
public static final boolean PRINT
true
.
Constructor Detail |
---|
public ScenarioUtils()
Method Detail |
---|
public static java.io.File createDir(java.lang.String dirPath)
File
corresponding to the given path.
If the directory does not exist, then it creates it.
dirPath
- The path of the directory
File
corresponding to the directory or null
if it didn't exist and that was not possible to create it.public static java.io.File createDir(java.lang.String dirPath, java.lang.String subdirName)
File
corresponding to the given path and the sub-directory.
If the directories do not exist, then it creates them.
dirPath
- The path of the directorysubdirName
- The sub-directory name
File
corresponding to the directory or null
if it didn't exist and that was not possible to create it.public static void debugClose()
public static void debugOpen()
public static void debugPrint(java.lang.String text)
text
- The line to print in the stream.public static void debugPrintException(java.lang.Throwable t)
t
- The exceptionpublic static void debugPrintExpectedStrings(java.lang.String kind, java.lang.String status, java.lang.String... strings)
public static void debugPrintln()
public static void debugPrintln(java.lang.String text)
text
- The line to print to the stream.public static void debugPrintln(java.lang.String... text)
text
- The line to print in the stream.public static void debugPrintln(java.lang.String text, int indent)
text
- The line to print in the stream.public static void debugPrintStackTrace(int tabs)
tabs
- The number of tabs to indent each elementpublic static void debugPrintStackTrace(java.lang.StackTraceElement[] elements)
elements
- The full stack trace elementspublic static void debugPrintStackTrace(java.lang.StackTraceElement[] elements, int tabs)
elements
- The full stack trace elementstabs
- The number of tabs to indent each elementpublic static java.lang.String elapsedTimeString(long start)
start
- The start of the time measure.
String
.public static java.lang.String getClassSimpleName(java.lang.Class<?> clazz)
public static boolean getParameterBooleanValue(java.lang.String name)
name
- The parameter name
boolean
corresponding to the system
property or false
if it is not defined.public static boolean getParameterBooleanValue(java.lang.String name, boolean defaultValue)
name
- The parameter namedefaultValue
- The value returned if the system property is not defined.
boolean
corresponding to the system
property or the default value if it is not defined.public static double getParameterDoubleValue(java.lang.String name)
name
- The parameter name
double
corresponding to the system
property or the default value if it is not defined or if the corresponding system
property does not define a valid double.public static double getParameterDoubleValue(java.lang.String name, double defaultValue)
name
- The parameter namedefaultValue
- The value returned if the system property is not defined.
double
corresponding to the system
property or the default value if it is not defined or if the corresponding system
property does not define a valid double.public static int getParameterIntValue(java.lang.String name)
name
- The parameter name
int
corresponding to the system
property or 0
if it is not defined.
java.lang.NumberFormatException
- If the corresponding system property
does not define a valid integer.public static int getParameterIntValue(java.lang.String name, int defaultValue)
name
- The parameter namedefaultValue
- The value returned if the system property is not defined.
int
corresponding to the system
property or the default value if it is not defined or if the corresponding system
property does not define a valid integer.public static java.lang.String getParameterValue(java.lang.String name)
name
- The parameter name
String
corresponding to the system prorty
or null
if the system property is not defined.public static java.lang.String getParameterValue(java.lang.String... names)
names
- A list of possible parameter names
String
corresponding to the first defined
system property defined or null
if none was found.public static java.lang.String getParameterValue(java.lang.String name, java.lang.String defaultValue)
name
- The parameter namedefaultValue
- The value returned if the parameter is not defined.
String
corresponding to the system property
or defaultValue
if the system property is not defined.public static java.lang.String getTextFromList(java.util.List<java.lang.String> strings)
String
public static java.lang.String getTextFromList(java.util.List<java.lang.String> strings, java.lang.String separator)
strings
- The list of stringsseparator
- String to use to separate strings
String
public static java.lang.String getTextFromList(java.lang.String[] strings)
String
public static java.lang.String getTextFromList(java.lang.String[] strings, java.lang.String separator)
strings
- The list of stringsseparator
- String to use to separate strings
String
public static void pause(int millisecs)
millisecs
- public static void print(java.lang.Object text)
PRINT
flag
is set.
text
- The text to print to the console.public static void printException(java.lang.Throwable t)
t
- The exceptionpublic static void println()
PRINT
flag is set.
public static void println(java.lang.Object text)
PRINT
flag is set.
text
- The text to print to the console.public static void printStackTrace(int tabs)
tabs
- The number of tabs to indent each elementpublic static void printStackTrace(java.lang.StackTraceElement[] elements, int tabs)
elements
- The full stack trace elementstabs
- The number of tabs to indent each elementpublic static void printStepStart(ScenarioStep step)
step
- The scenario steppublic static void setDebugWriter()
public static void sleep(int seconds)
seconds
- The number of seconds to sleep.public static java.lang.String timeString(long time)
time
- The time to format as a long.
String
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |