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 voidassertEquals(URL source, String text) static booleanAttempt to verify the contents of text against the contents of the URL specified.static Stringnormalizes a string so that strings generated on different platforms can be compared.static Stringstatic StringreadContent(URL url) static StringreadContent(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
-