Class TestUtil

java.lang.Object
com.adobe.cq.testing.util.TestUtil

public class TestUtil extends Object
Some helper utilities for testing.
  • Field Details

    • ISO_DATETIME_TIME_ZONE_FORMAT

      public static final org.apache.commons.lang3.time.FastDateFormat ISO_DATETIME_TIME_ZONE_FORMAT
      The formatter for ISO8601 date time including milliseconds and time zone. That's how date stings must look like to be send and stored in nodes using post request
  • Constructor Details

    • TestUtil

      public TestUtil()
  • Method Details

    • parseJsonDateString

      public static Date parseJsonDateString(String dateString) throws org.apache.sling.testing.clients.ClientException
      Parses a string representing a date, as it is returned when requesting a node using .json
      Parameters:
      dateString - string representing a date
      Returns:
      the date object
      Throws:
      org.apache.sling.testing.clients.ClientException - if the string cannot be parsed
    • getMD5Checksum

      public static String getMD5Checksum(InputStream stream)
      Calculates the MD5 checksum for a input stream. The input stream gets closed after checksum has been calculated.
      Parameters:
      stream - the input stream
      Returns:
      the MD5 Checksum string
    • binaryCompare

      public static boolean binaryCompare(InputStream i1, InputStream i2)
      Makes a MD5 compare of two input streams. the input streams are closed after md5 has been calculated.
      Parameters:
      i1 - First Input Stream
      i2 - Second Input Stream
      Returns:
      true if binaries are the same otherwise false
    • replaceSpecialCharsForRegexp

      public static String replaceSpecialCharsForRegexp(String regexp)
      Escapes special characters in the string to avoid breaking a regexp
      Parameters:
      regexp - regexp to escape
      Returns:
      the escaped regexp