Class Utils

java.lang.Object
fr.paris.lutece.test.Utils

public class Utils extends Object
Utils for tests
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • getFileContent

      public static String getFileContent(String strFilename) throws IOException
      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

      public static void validateHtmlFragment(String html) throws IOException, SAXException
      Validate an html fragment, failing on warning
      Parameters:
      html - the fragment to validate
      Throws:
      IOException - in case of error
      SAXException - in case of error
      AssertionError - 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 validate
      failOnWarning - whether to fail on warning
      Throws:
      IOException - in case of error
      SAXException - in case of error
      AssertionError - if the fragment is invalid or produces warnings
    • validateHtml

      public static void validateHtml(String html) throws IOException, SAXException
      Validate an html document
      Parameters:
      html - the document to validate
      Throws:
      IOException - in case of error
      SAXException - in case of error
      AssertionError - 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 validate
      failOnWarning - whether to fail on warning
      Throws:
      IOException - in case of error
      SAXException - in case of error
      AssertionError - if the document is invalid or produces warnings
    • getRandomName

      public static String getRandomName()
      Get a random name for use in tests
      Returns:
      a random name with prefix junit and 128 bits of randomness
    • getRandomName

      public static String getRandomName(String strPrefix)
      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

      public static String getRandomName(String strPrefix, int nRandomBits)
      Get a random name for use in tests
      Parameters:
      strPrefix - the prefix to use
      nRandomBits - the numnber of bits of randomness to use
      Returns:
      a random name with the specified prefix and the specified number of bits of randomness