Package com.adobe.cq.testing.util
Class TestUtil
java.lang.Object
com.adobe.cq.testing.util.TestUtil
Some helper utilities for testing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.commons.lang3.time.FastDateFormatThe formatter for ISO8601 date time including milliseconds and time zone. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbinaryCompare(InputStream i1, InputStream i2) Makes a MD5 compare of two input streams.static StringgetMD5Checksum(InputStream stream) Calculates the MD5 checksum for a input stream.static DateparseJsonDateString(String dateString) Parses a string representing a date, as it is returned when requesting a node using .jsonstatic StringreplaceSpecialCharsForRegexp(String regexp) Escapes special characters in the string to avoid breaking a regexp
-
Field Details
-
ISO_DATETIME_TIME_ZONE_FORMAT
public static final org.apache.commons.lang3.time.FastDateFormat ISO_DATETIME_TIME_ZONE_FORMATThe 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
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
Makes a MD5 compare of two input streams. the input streams are closed after md5 has been calculated.- Parameters:
i1- First Input Streami2- Second Input Stream- Returns:
- true if binaries are the same otherwise false
-
replaceSpecialCharsForRegexp
Escapes special characters in the string to avoid breaking a regexp- Parameters:
regexp- regexp to escape- Returns:
- the escaped regexp
-