Package ee.jakarta.tck.ws.rs.lib.util
Class TestUtil
java.lang.Object
ee.jakarta.tck.ws.rs.lib.util.TestUtil
TestUtil is a final utility class responsible for implementing logging across
multiple VMs. It also contains many convenience methods for logging property
object contents, stacktraces, and header lines.
- Author:
- Kyle Grucci
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
static String
static Properties
This method returns the properties objectstatic String
This method returns the property value for the appropriate property keystatic String
getProperty
(String s, String defaultValue) This method returns the property value for the appropriate property keystatic String
getRelativePath
(String oldVal) static String
getResponse
(URLConnection connection) Convience method to handle sucking in the data from a connection.static Properties
getResponseProperties
(String string) Loads any properties that might be in a given String.static Properties
getResponseProperties
(URLConnection connection) One shot method to get Properties directly from a URLConnection.static String
getTableName
(String value) Parse a the table name from the ddl string such as: "create table foo" or "delete from foo"static String
getTransactionStatus
(int status) returns the transaction status value as a String given its integer representationstatic void
init
(Properties p) This static method must be called once by each new remote VM.static void
This static method must be called once by the harness VM.static void
static void
This static method must be called once by a VM which does not rely upon any remote logging.static void
list
(Properties p) prints the contents of a properties object to the logging streamstatic void
prints an error string to the error stream.static void
prints an error string to the error stream.static void
logHarness
(String s) static void
logHarness
(String s, Throwable t) used by TSTestFinder and TSScript to log output to the standard output streamstatic void
used by harness to log debug output to the standard output streamstatic void
prints a string to the log stream.static void
prints a string as well as the provided Throwable's stacktrace to the log stream.static void
prints a debug string to the log stream.static void
Prints a debug string as well as the provided Throwable's stacktrace.static void
printProperties
(Properties props) static void
prints the stacktrace of a Throwable to the logging streamstatic String
prints the stacktrace of a Throwable to a stringstatic void
printTransactionStatus
(int status) prints the transaction status value as a String given its integer representationstatic String
replaceLastSrc
(String src, String replacement) static URLConnection
sendPostData
(Properties p, URL url) static void
prints a line of dashes to the logging streamstatic void
prints a line of asterisks to the logging streamstatic void
static void
setCurrentTest
(String testName, PrintWriter outStream, PrintWriter errStream) This static method must be called once by the harness VM in order to set the output and error streams and the name of the current test.static void
setTrace
(boolean b) turns on/off debugging.static void
sleep
(int s) pauses the calling thread for the specified number of millisecondsstatic void
sleepMsec
(int s) pauses the calling thread for the specified number of millisecondsstatic void
sleepSec
(int s) pauses the calling thread for the specified number of secondsstatic String
static Properties
strToProps
(String strProps) static String
toEncodedString
(Properties args) static void
writeObject
(ee.jakarta.tck.ws.rs.lib.util.TestReportInfo info)
-
Field Details
-
traceflag
public static boolean traceflag -
sTestName
-
EMPTY_STRING_ARRAY
-
VM_UNDER_TEST
public static final int VM_UNDER_TEST- See Also:
-
VM_HARNESS
public static final int VM_HARNESS- See Also:
-
VM_JAVATEST
public static final int VM_JAVATEST- See Also:
-
DEBUG_OUTPUT_LEVEL
public static final int DEBUG_OUTPUT_LEVEL- See Also:
-
NORMAL_OUTPUT_LEVEL
public static final int NORMAL_OUTPUT_LEVEL- See Also:
-
ERROR_STREAM
public static final int ERROR_STREAM- See Also:
-
OUTPUT_STREAM
public static final int OUTPUT_STREAM- See Also:
-
NEW_LINE
-
iWhereAreWe
public static int iWhereAreWe -
harnessDebug
public static boolean harnessDebug -
MILLI
public static final int MILLI- See Also:
-
-
Constructor Details
-
TestUtil
public TestUtil()
-
-
Method Details
-
logHarnessDebug
used by harness to log debug output to the standard output stream- Parameters:
s
- the output string
-
logHarness
used by TSTestFinder and TSScript to log output to the standard output stream- Parameters:
s
- the output stringt
- a Throwable whose stacktrace gets printed
-
logHarness
-
getProperties
This method returns the properties object- Returns:
- the properties object
-
getProperty
This method returns the property value for the appropriate property key- Parameters:
s
- the property name- Returns:
- the property value
-
getProperty
This method returns the property value for the appropriate property key- Parameters:
s
- the property name- Returns:
- the property value
-
getTransactionStatus
returns the transaction status value as a String given its integer representation- Parameters:
status
- integer representation of a transaction status- Returns:
- string representation of a transaction status
-
printTransactionStatus
public static void printTransactionStatus(int status) prints the transaction status value as a String given its integer representation- Parameters:
status
- integer representation of a transaction status
-
sleepSec
public static void sleepSec(int s) pauses the calling thread for the specified number of seconds- Parameters:
s
- number of seconds
-
sleep
public static void sleep(int s) pauses the calling thread for the specified number of milliseconds- Parameters:
s
- number of milliseconds
-
sleepMsec
public static void sleepMsec(int s) pauses the calling thread for the specified number of milliseconds- Parameters:
s
- number of milliseconds
-
flushStream
public static void flushStream() -
writeObject
public static void writeObject(ee.jakarta.tck.ws.rs.lib.util.TestReportInfo info) -
init
This static method must be called once by each new remote VM. Once called, a socket connection is created back to the host running the test harness. All calls to logMsg, logErr, and logTrace are immediately sent back to the harness host.- Parameters:
p
- properties containing harness host, port, and trace flag- Throws:
RemoteLoggingInitException
- if an exception occurs while the server side is setting up the socket connection back to the client host
-
initJavaTest
public static void initJavaTest() -
setAdditionalWriter
-
initNoLogging
This static method must be called once by a VM which does not rely upon any remote logging. param p properties containing harness trace flag -
initClient
This static method must be called once by the harness VM. Once called, a serversocket begins listening for Remote VMs to connect on the port specified by harness.log.port.- Parameters:
p
- properties containing harness trace flag
-
setCurrentTest
This static method must be called once by the harness VM in order to set the output and error streams and the name of the current test.- Parameters:
testName
- the currently running testname as specified in the source code tagsoutStream
- stream printed to by the logMsg and logTrace methodserrStream
- stream printed to by the logErr methods
-
logMsg
prints a string to the log stream. All tests should use this method for standard logging messages- Parameters:
s
- string to print to the log stream
-
logMsg
prints a string as well as the provided Throwable's stacktrace to the log stream. All tests should use this method for standard logging messages- Parameters:
s
- string to print to the log streamt
- - throwable whose stacktrace gets printed*
-
setTrace
public static void setTrace(boolean b) turns on/off debugging. Once on, all calls to the logTrace method result in messages being printed to the log stream. If off, all logTrace calls are not printed.- Parameters:
b
- Iftrue
, debugging is on. If false, debugging is turned off.
-
logTrace
prints a debug string to the log stream. All tests should use this method for verbose logging messages. Whether or not the string is printed is determined by the last call to the setTrace method.- Parameters:
s
- string to print to the log stream
-
logTrace
Prints a debug string as well as the provided Throwable's stacktrace. Use this if certain exceptions are only desired while tracing.- Parameters:
s
- - string to print to the log streamt
- - throwable whose stactrace gets printed
-
logErr
prints an error string to the error stream. All tests should use this method for error messages.- Parameters:
s
- string to print to the error streame
- a Throwable whose stacktrace gets printed
-
logErr
prints an error string to the error stream. All tests should use this method for error messages.- Parameters:
s
- string to print to the error stream
-
list
prints the contents of a properties object to the logging stream- Parameters:
p
- properties to print
-
printStackTrace
prints the stacktrace of a Throwable to the logging stream- Parameters:
e
- exception to print the stacktrace of
-
printStackTraceToString
prints the stacktrace of a Throwable to a string- Parameters:
e
- exception to print the stacktrace of
-
separator2
public static void separator2()prints a line of asterisks to the logging stream -
separator1
public static void separator1()prints a line of dashes to the logging stream -
getResponse
Convience method to handle sucking in the data from a connection.- Throws:
IOException
-
getResponseProperties
Loads any properties that might be in a given String.- Throws:
IOException
-
getResponseProperties
One shot method to get Properties directly from a URLConnection.- Throws:
IOException
-
toEncodedString
-
sendPostData
- Throws:
IOException
-
getTableName
Parse a the table name from the ddl string such as: "create table foo" or "delete from foo"- Parameters:
value
- buffer to parse- Returns:
- The name of the table
-
srcToDist
-
replaceLastSrc
-
getDistString
-
getRelativePath
-
strToProps
-
printProperties
-