Class TestUtil

java.lang.Object
ee.jakarta.tck.ws.rs.lib.util.TestUtil

public final class TestUtil extends Object
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 Details

    • traceflag

      public static boolean traceflag
    • sTestName

      public static String sTestName
    • EMPTY_STRING_ARRAY

      public static final String[] 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

      public static String 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

      public static void logHarnessDebug(String s)
      used by harness to log debug output to the standard output stream
      Parameters:
      s - the output string
    • logHarness

      public static void logHarness(String s, Throwable t)
      used by TSTestFinder and TSScript to log output to the standard output stream
      Parameters:
      s - the output string
      t - a Throwable whose stacktrace gets printed
    • logHarness

      public static void logHarness(String s)
    • getProperties

      public static Properties getProperties()
      This method returns the properties object
      Returns:
      the properties object
    • getProperty

      public static String getProperty(String s)
      This method returns the property value for the appropriate property key
      Parameters:
      s - the property name
      Returns:
      the property value
    • getProperty

      public static String getProperty(String s, String defaultValue)
      This method returns the property value for the appropriate property key
      Parameters:
      s - the property name
      Returns:
      the property value
    • getTransactionStatus

      public static String getTransactionStatus(int status)
      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

      public static void init(Properties p) throws RemoteLoggingInitException
      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

      public static void setAdditionalWriter(PrintWriter pw)
    • initNoLogging

      public static void initNoLogging(Properties p)
      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

      public static void initClient(Properties p)
      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

      public 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.
      Parameters:
      testName - the currently running testname as specified in the source code tags
      outStream - stream printed to by the logMsg and logTrace methods
      errStream - stream printed to by the logErr methods
    • logMsg

      public static void logMsg(String s)
      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

      public static void logMsg(String s, Throwable t)
      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 stream
      t - - 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 - If true, debugging is on. If false, debugging is turned off.
    • logTrace

      public static void logTrace(String s)
      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

      public static void logTrace(String s, Throwable t)
      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 stream
      t - - throwable whose stactrace gets printed
    • logErr

      public static void logErr(String s, Throwable e)
      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
      e - a Throwable whose stacktrace gets printed
    • logErr

      public static void logErr(String s)
      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

      public static void list(Properties p)
      prints the contents of a properties object to the logging stream
      Parameters:
      p - properties to print
    • printStackTrace

      public static void printStackTrace(Throwable e)
      prints the stacktrace of a Throwable to the logging stream
      Parameters:
      e - exception to print the stacktrace of
    • printStackTraceToString

      public static String printStackTraceToString(Throwable e)
      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

      public static String getResponse(URLConnection connection) throws IOException
      Convience method to handle sucking in the data from a connection.
      Throws:
      IOException
    • getResponseProperties

      public static Properties getResponseProperties(String string) throws IOException
      Loads any properties that might be in a given String.
      Throws:
      IOException
    • getResponseProperties

      public static Properties getResponseProperties(URLConnection connection) throws IOException
      One shot method to get Properties directly from a URLConnection.
      Throws:
      IOException
    • toEncodedString

      public static String toEncodedString(Properties args)
    • sendPostData

      public static URLConnection sendPostData(Properties p, URL url) throws IOException
      Throws:
      IOException
    • getTableName

      public static String getTableName(String value)
      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

      public static String srcToDist(String src)
    • replaceLastSrc

      public static String replaceLastSrc(String src, String replacement)
    • getDistString

      public static String getDistString()
    • getRelativePath

      public static String getRelativePath(String oldVal)
    • strToProps

      public static Properties strToProps(String strProps)
    • printProperties

      public static void printProperties(Properties props)