Package fr.paris.lutece.test
Class Utils
java.lang.Object
fr.paris.lutece.test.Utils
Utils for tests
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetFileContent(String strFilename) Gets the content of a file as a stringstatic StringGet a random name for use in testsstatic StringgetRandomName(String strPrefix) Get a random name for use in testsstatic StringgetRandomName(String strPrefix, int nRandomBits) Get a random name for use in testsstatic voidvalidateHtml(String html) Validate an html documentstatic voidvalidateHtml(String html, boolean failOnWarning) Validate an html documentstatic voidvalidateHtmlFragment(String html) Validate an html fragment, failing on warningstatic voidvalidateHtmlFragment(String html, boolean failOnWarning) Validate an html fragment
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
getFileContent
Gets the content of a file as a string- Parameters:
strFilename- The filename (ie: myfile.text for file stored in src/test/resources)- Returns:
- The file's content
- Throws:
IOException- If an IO error occurs
-
validateHtmlFragment
Validate an html fragment, failing on warning- Parameters:
html- the fragment to validate- Throws:
IOException- in case of errorSAXException- in case of errorAssertionError- if the fragment is invalid or produces warnings
-
validateHtmlFragment
public static void validateHtmlFragment(String html, boolean failOnWarning) throws IOException, SAXException Validate an html fragment- Parameters:
html- the fragment to validatefailOnWarning- whether to fail on warning- Throws:
IOException- in case of errorSAXException- in case of errorAssertionError- if the fragment is invalid or produces warnings
-
validateHtml
Validate an html document- Parameters:
html- the document to validate- Throws:
IOException- in case of errorSAXException- in case of errorAssertionError- if the document is invalid or produces warnings
-
validateHtml
public static void validateHtml(String html, boolean failOnWarning) throws IOException, SAXException Validate an html document- Parameters:
html- the document to validatefailOnWarning- whether to fail on warning- Throws:
IOException- in case of errorSAXException- in case of errorAssertionError- if the document is invalid or produces warnings
-
getRandomName
Get a random name for use in tests- Returns:
- a random name with prefix
junit
and 128 bits of randomness
-
getRandomName
Get a random name for use in tests- Parameters:
strPrefix- the prefix to use- Returns:
- a random name with the specified prefix and 128 bits of randomness
-
getRandomName
Get a random name for use in tests- Parameters:
strPrefix- the prefix to usenRandomBits- the numnber of bits of randomness to use- Returns:
- a random name with the specified prefix and the specified number of bits of randomness
-