Class ServletTestUtil
java.lang.Object
com.sun.ts.tests.servlet.common.util.ServletTestUtil
A set of useful utility methods to help perform test functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckArrayList(ArrayList al, String[] values, boolean enforceSizes, boolean allowDuplicates) static booleancheckEnumeration(Enumeration<?> e, String[] values, boolean enforceSizes, boolean allowDuplicates) Compares the String values in an Enumeration against the provides String array of values.static booleancheckEnumeration(Enumeration e, String[] values) Compares the String values in an Enumeration against the provides String array of values.static booleancompareString(String expected, String actual) static intfindCookie(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 StringgetAsString(Object[] sArray) Returns the provided String array in the following format:[n1,n2,n...]static StringReturns the provided Enumeration as a String in the following format:[n1,n2,n...]static StringgetAsString(List<String> al) static voidprintFailureData(PrintWriter pw, ArrayList result, Object[] expected) static voidprintFailureData(PrintWriter pw, Enumeration result, Object[] expected) static voidprintResult(jakarta.servlet.ServletOutputStream pw, boolean b) static voidprintResult(PrintWriter pw, boolean b) static voidprintResult(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
-