public class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
getFileContent(String strFilename)
Gets the content of a file as a string
|
static String |
getRandomName()
Get a random name for use in tests
|
static String |
getRandomName(String strPrefix)
Get a random name for use in tests
|
static String |
getRandomName(String strPrefix,
int nRandomBits)
Get a random name for use in tests
|
static void |
registerAdminUser(javax.servlet.http.HttpServletRequest request,
fr.paris.lutece.portal.business.user.AdminUser user)
Register an admin user
|
static void |
registerAdminUserWithRigth(javax.servlet.http.HttpServletRequest request,
fr.paris.lutece.portal.business.user.AdminUser user,
String strRight)
Register an admin user with a given right
|
static void |
validateHtml(String html)
Validate an html document
|
static void |
validateHtml(String html,
boolean failOnWarning)
Validate an html document
|
static void |
validateHtmlFragment(String html)
Validate an html fragment, failing on warning
|
static void |
validateHtmlFragment(String html,
boolean failOnWarning)
Validate an html fragment
|
public static void registerAdminUserWithRigth(javax.servlet.http.HttpServletRequest request,
fr.paris.lutece.portal.business.user.AdminUser user,
String strRight)
request - the request to register the user intouser - The userstrRight - The rightpublic static void registerAdminUser(javax.servlet.http.HttpServletRequest request,
fr.paris.lutece.portal.business.user.AdminUser user)
request - the request to register the user intouser - The userpublic static String getFileContent(String strFilename) throws IOException
strFilename - The filename (ie: myfile.text for file stored in src/test/resources)IOException - If an IO error occurspublic static void validateHtmlFragment(String html) throws IOException, SAXException
html - the fragment to validateIOException - in case of errorSAXException - in case of errorAssertionError - if the fragment is invalid or produces warningspublic static void validateHtmlFragment(String html, boolean failOnWarning) throws IOException, SAXException
html - the fragment to validatefailOnWarning - whether to fail on warningIOException - in case of errorSAXException - in case of errorAssertionError - if the fragment is invalid or produces warningspublic static void validateHtml(String html) throws IOException, SAXException
html - the document to validateIOException - in case of errorSAXException - in case of errorAssertionError - if the document is invalid or produces warningspublic static void validateHtml(String html, boolean failOnWarning) throws IOException, SAXException
html - the document to validatefailOnWarning - whether to fail on warningIOException - in case of errorSAXException - in case of errorAssertionError - if the document is invalid or produces warningspublic static String getRandomName()
junitand 128 bits of randomness
public static String getRandomName(String strPrefix)
strPrefix - the prefix to usepublic static String getRandomName(String strPrefix, int nRandomBits)
strPrefix - the prefix to usenRandomBits - the numnber of bits of randomness to useCopyright © 2020 City of Paris. All rights reserved.