Package org.apache.struts2.junit.util
Class TestUtils
java.lang.Object
org.apache.struts2.junit.util.TestUtils
Utility methods for test classes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertEquals
(URL source, String text) static boolean
Attempt to verify the contents of text against the contents of the URL specified.static String
normalizes a string so that strings generated on different platforms can be compared.static String
static String
readContent
(URL url) static String
readContent
(URL url, Charset encoding)
-
Constructor Details
-
TestUtils
public TestUtils()
-
-
Method Details
-
normalize
normalizes a string so that strings generated on different platforms can be compared. any group of one or more space, tab, \r, and \n characters are converted to a single space character- Parameters:
json
- the JSON to be normalized. normalize will trim before startingremoveSpaces
- removes white spaces from the JSON or not- Returns:
- the normalized string
-
normalize
- Throws:
Exception
-
compare
Attempt to verify the contents of text against the contents of the URL specified. Performs a trim on both ends- Parameters:
url
- the HTML snippet that we want to validate against- Throws:
Exception
- if the validation failed
-
assertEquals
- Throws:
Exception
-
readContent
- Throws:
Exception
-
readContent
- Throws:
Exception
-