Class ServletTestUtil

java.lang.Object
ee.jakarta.tck.pages.common.util.ServletTestUtil

public class ServletTestUtil extends Object
A set of useful utility methods to help perform test functions.
  • Method Details

    • checkEnumeration

      public static boolean checkEnumeration(Enumeration e, String[] values)
      Compares the String values in an Enumeration against the provides String array of values. The number of elements in the enumeration must be the same as the size of the array, or false will be returned. False will also be returned if the provided Enumeration or String array is null. If all values are found, true will be returned. Note: This method isn't concerned with the presence of duplicate values contained in the enumeration. The comparison is performed in a case sensitive manner.
      Parameters:
      e - - Enumeration to validate
      values - - the values expected to be found in the Enumeration
      Returns:
      true if all the expected values are found, otherwise false.
    • checkEnumeration

      public static boolean checkEnumeration(Enumeration<?> e, String[] values, boolean enforceSizes, boolean allowDuplicates)
      Compares the String values in an Enumeration against the provides String array of values. The number of elements in the enumeration must be the same as the size of the array, or false will be returned. False will also be returned if the provided Enumeration or String array is null. If all values are found, true will be returned. Note: This method isn't concerned with the presence of duplicate values contained in the enumeration. The comparison is performed in a case sensitive manner.
      Parameters:
      e - - Enumeration to validate
      values - - the values expected to be found in the Enumeration
      enforceSizes - - ensures that the number of elements in the Enumeration matches the number of elements in the array of values
      allowDuplicates - - If true, the method will true if duplicate elements are found in the Enumeration, if false, then false will be return if duplicate elements have been found.
      Returns:
      true if all the expected values are found, otherwise false.
    • checkArrayList

      public static boolean checkArrayList(ArrayList al, String[] values, boolean enforceSizes, boolean allowDuplicates)
    • compareString

      public static boolean compareString(String expected, String actual)
    • getAsString

      public static String getAsString(Object[] sArray)
      Returns the provided String array in the following format: [n1,n2,n...]
      Parameters:
      sArray - - an array of Objects
      Returns:
      - a String based off the values in the array
    • getAsString

      public static String getAsString(List<String> al)
    • getAsString

      public static String getAsString(Enumeration e)
      Returns the provided Enumeration as a String in the following format: [n1,n2,n...]
      Parameters:
      e - - an Enumeration
      Returns:
      - a printable version of the contents of the Enumeration
    • getAsArray

      public static Object[] getAsArray(Enumeration<Object> e)
      Returnes the provides Enumeration as an Array of String Arguments.
      Parameters:
      e - - an Enumeration
      Returns:
      - the elements of the Enumeration as an array of Objects
    • getAsArray

      public static String[] getAsArray(String value)
      Returnes the provided string as an Array of Strings.
      Parameters:
      value - String
      Returns:
      - the elements of the String as an array of Strings
    • printResult

      public static void printResult(PrintWriter pw, String s)
    • printResult

      public static void printResult(PrintWriter pw, boolean b)
    • printResult

      public static void printResult(jakarta.servlet.ServletOutputStream pw, boolean b) throws IOException
      Throws:
      IOException
    • printFailureData

      public static void printFailureData(PrintWriter pw, ArrayList result, Object[] expected)
    • printFailureData

      public static void printFailureData(PrintWriter pw, Enumeration result, Object[] expected)
    • findCookie

      public static int findCookie(jakarta.servlet.http.Cookie[] cookie, String name)