Package ee.jakarta.tck.pages.common.util
Class ServletTestUtil
java.lang.Object
ee.jakarta.tck.pages.common.util.ServletTestUtil
A set of useful utility methods to help perform test functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkArrayList
(ArrayList al, String[] values, boolean enforceSizes, boolean allowDuplicates) 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.static boolean
checkEnumeration
(Enumeration e, String[] values) Compares the String values in an Enumeration against the provides String array of values.static boolean
compareString
(String expected, String actual) static int
findCookie
(jakarta.servlet.http.Cookie[] cookie, String name) static String[]
getAsArray
(String value) Returnes the provided string as an Array of Strings.static Object[]
Returnes the provides Enumeration as an Array of String Arguments.static String
getAsString
(Object[] sArray) Returns the provided String array in the following format: [n1,n2,n...]static String
Returns the provided Enumeration as a String in the following format: [n1,n2,n...]static String
getAsString
(List<String> al) static void
printFailureData
(PrintWriter pw, ArrayList result, Object[] expected) static void
printFailureData
(PrintWriter pw, Enumeration result, Object[] expected) static void
printResult
(jakarta.servlet.ServletOutputStream pw, boolean b) static void
printResult
(PrintWriter pw, boolean b) static void
printResult
(PrintWriter pw, String s)
-
Method Details
-
checkEnumeration
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 validatevalues
- - 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 validatevalues
- - the values expected to be found in the EnumerationenforceSizes
- - ensures that the number of elements in the Enumeration matches the number of elements in the array of valuesallowDuplicates
- - 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
-
compareString
-
getAsString
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
-
getAsString
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
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
Returnes the provided string as an Array of Strings.- Parameters:
value
- String- Returns:
- - the elements of the String as an array of Strings
-
printResult
-
printResult
-
printResult
public static void printResult(jakarta.servlet.ServletOutputStream pw, boolean b) throws IOException - Throws:
IOException
-
printFailureData
-
printFailureData
-
findCookie
-