Package com.adobe.cq.testing.junit.rules
Class LogTracerRule
java.lang.Object
org.junit.rules.ExternalResource
com.adobe.cq.testing.junit.rules.LogTracerRule
- All Implemented Interfaces:
org.junit.rules.TestRule
public class LogTracerRule
extends org.junit.rules.ExternalResource
-
Constructor Summary
ConstructorDescriptionLogTracerRule
(org.apache.sling.testing.junit.rules.instance.Instance quickstartRule) LogTracerRule
(org.apache.sling.testing.junit.rules.instance.Instance quickstartRule, int recordingCacheSizeInMB, int recordingCacheDurationInSecs) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
after()
Restore the original configuration state of the log tracer.protected void
before()
Store the state of the log tracer configuration and enable it.com.fasterxml.jackson.databind.JsonNode
getLogs
(org.apache.sling.testing.clients.SlingHttpResponse response) Parse the tracer request id from the given response object and return the corresponding logs from the tracer servlet as JSON array.List
<org.apache.http.Header> com.fasterxml.jackson.databind.JsonNode
getTracerReport
(org.apache.sling.testing.clients.SlingHttpResponse response) Parse the tracer request id from the given response object and return the corresponding tracer report from the tracer servlet as JSON object.void
setTracerHeaders
(List<org.apache.http.Header> headers) void
verifyLog
(org.apache.sling.testing.clients.SlingHttpResponse response) Parse the tracer request id from the given response object and check if there are any entries in the corresponding log.Methods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
LogTracerRule
public LogTracerRule(org.apache.sling.testing.junit.rules.instance.Instance quickstartRule) -
LogTracerRule
public LogTracerRule(org.apache.sling.testing.junit.rules.instance.Instance quickstartRule, int recordingCacheSizeInMB, int recordingCacheDurationInSecs)
-
-
Method Details
-
getTracerHeaders
-
setTracerHeaders
-
before
protected void before() throws org.apache.sling.testing.clients.ClientException, org.apache.sling.testing.clients.util.config.InstanceConfigException, InterruptedExceptionStore the state of the log tracer configuration and enable it.- Overrides:
before
in classorg.junit.rules.ExternalResource
- Throws:
org.apache.sling.testing.clients.ClientException
org.apache.sling.testing.clients.util.config.InstanceConfigException
InterruptedException
-
after
protected void after()Restore the original configuration state of the log tracer.- Overrides:
after
in classorg.junit.rules.ExternalResource
-
getTracerReport
public com.fasterxml.jackson.databind.JsonNode getTracerReport(org.apache.sling.testing.clients.SlingHttpResponse response) throws org.apache.sling.testing.clients.ClientException, InterruptedException Parse the tracer request id from the given response object and return the corresponding tracer report from the tracer servlet as JSON object.- Parameters:
response
- SlingHttpResponse object- Returns:
- Request report as JSONObject
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
getLogs
public com.fasterxml.jackson.databind.JsonNode getLogs(org.apache.sling.testing.clients.SlingHttpResponse response) throws org.apache.sling.testing.clients.ClientException, InterruptedException Parse the tracer request id from the given response object and return the corresponding logs from the tracer servlet as JSON array.- Parameters:
response
- SlingHttpResponse object- Returns:
- Request logs as JSONArray
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
verifyLog
public void verifyLog(org.apache.sling.testing.clients.SlingHttpResponse response) throws org.apache.sling.testing.clients.ClientException, InterruptedException Parse the tracer request id from the given response object and check if there are any entries in the corresponding log. Marks the test case from which this method was called as failed if there are any log entries.- Parameters:
response
- SlingHttpResponse object- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-