Class TestUtils

java.lang.Object
org.apache.struts2.junit.util.TestUtils

public class TestUtils extends Object
Utility methods for test classes
  • Constructor Details

    • TestUtils

      public TestUtils()
  • Method Details

    • normalize

      public static String normalize(String json, boolean removeSpaces)
      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 starting
      removeSpaces - removes white spaces from the JSON or not
      Returns:
      the normalized string
    • normalize

      public static String normalize(URL url) throws Exception
      Throws:
      Exception
    • compare

      public static boolean compare(URL url, String text) throws Exception
      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

      public static void assertEquals(URL source, String text) throws Exception
      Throws:
      Exception
    • readContent

      public static String readContent(URL url) throws Exception
      Throws:
      Exception
    • readContent

      public static String readContent(URL url, Charset encoding) throws Exception
      Throws:
      Exception