Class Util
java.lang.Object
com.adobe.cq.testing.client.assets.Util
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckContentDisposition(org.apache.sling.testing.clients.SlingHttpResponse response, String expected) Check if the content disposition header of the response is equal to the given valuestatic voidcheckContentLength(org.apache.sling.testing.clients.SlingHttpResponse response, long expected) Check if the content length of the response is equal to the given valuestatic com.fasterxml.jackson.databind.JsonNodegetJsonChildNode(com.fasterxml.jackson.databind.JsonNode parent, String... children) Retrieve a child nodestatic longgetJsonLongValue(com.fasterxml.jackson.databind.JsonNode parent, String fieldName) Retrieve the long value of a fieldstatic longgetResourceSize(String resourcePath) Retrieve the size of a resource.
-
Method Details
-
getResourceSize
public static long getResourceSize(String resourcePath) throws org.apache.sling.testing.clients.ClientException Retrieve the size of a resource. Could be optimized by checking the URL and if it's a file on disk to get the file size directly. The code tries to be general though, and the assets uploaded should be small.- Parameters:
resourcePath- Path to the resource available to the class loader- Returns:
- Size of the resource
- Throws:
org.apache.sling.testing.clients.ClientException- Thrown if the size of the resource can't be calculated
-
checkContentLength
public static void checkContentLength(org.apache.sling.testing.clients.SlingHttpResponse response, long expected) throws org.apache.sling.testing.clients.ClientException Check if the content length of the response is equal to the given value- Parameters:
response- HTTP responseexpected- Expected content length- Throws:
org.apache.sling.testing.clients.ClientException- Thrown if the content-length of the HTTP response doesn't match expected
-
checkContentDisposition
public static void checkContentDisposition(org.apache.sling.testing.clients.SlingHttpResponse response, String expected) throws org.apache.sling.testing.clients.ClientException Check if the content disposition header of the response is equal to the given value- Parameters:
response- HTTP responseexpected- Expected content disposition- Throws:
org.apache.sling.testing.clients.ClientException- Thrown if the content-disposition of the HTTP response doesn't match expected
-
getJsonChildNode
public static com.fasterxml.jackson.databind.JsonNode getJsonChildNode(com.fasterxml.jackson.databind.JsonNode parent, String... children) Retrieve a child node- Parameters:
parent- Parent nodechildren- Each child goes down one level, e.g. (root, a, b) will go to root/a/b- Returns:
- Child node or null if the node doesn't exist
-
getJsonLongValue
public static long getJsonLongValue(com.fasterxml.jackson.databind.JsonNode parent, String fieldName) Retrieve the long value of a field- Parameters:
parent- Parent nodefieldName- Field to retrieve- Returns:
- Long value in field or 0 if the field doesn't exist
-