use of org.apache.sling.hc.support.impl.SlingRequestStatusHealthCheck in project sling by apache.
the class SlingRequestStatusHealthCheckTest method setup.
@Before
public void setup() throws Exception {
hc = new SlingRequestStatusHealthCheck();
final ResourceResolverFactory rrf = Mockito.mock(ResourceResolverFactory.class);
SetField.set(hc, "resolverFactory", rrf);
final Answer<Void> a = new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
final HttpServletRequest request = (HttpServletRequest) invocation.getArguments()[0];
final HttpServletResponse response = (HttpServletResponse) invocation.getArguments()[1];
final String path = request.getPathInfo();
if (path.length() > 0) {
final String status = path.substring(0, path.indexOf('.'));
response.setStatus(Integer.valueOf(status));
}
return null;
}
};
final SlingRequestProcessor srp = Mockito.mock(SlingRequestProcessor.class);
SetField.set(hc, "requestProcessor", srp);
Mockito.doAnswer(a).when(srp).processRequest(Matchers.any(HttpServletRequest.class), Matchers.any(HttpServletResponse.class), Matchers.any(ResourceResolver.class));
final Map<String, Object> properties = new HashMap<String, Object>();
properties.put("path", paths);
hc.activate(properties);
}
Aggregations