use of org.apache.sling.testing.tools.http.RequestCustomizer in project sling by apache.
the class SlingRemoteTestRunner method maybeExecuteTests.
private void maybeExecuteTests() throws Exception {
if (testHttpClient != null) {
// Tests already ran
return;
}
testHttpClient = new RemoteTestHttpClient(testParameters.getJunitServletUrl(), this.username, this.password, true);
// Let the parameters class customize the request if desired
if (testParameters instanceof RequestCustomizer) {
testHttpClient.setRequestCustomizer((RequestCustomizer) testParameters);
}
// Run tests remotely and get response
final RequestExecutor executor = testHttpClient.runTests(testParameters.getTestClassesSelector(), testParameters.getTestMethodSelector(), "json");
executor.assertContentType("application/json");
final JsonArray json = Json.createReader(new StringReader(JsonTicksConverter.tickToDoubleQuote(executor.getContent()))).readArray();
// based on this vlaue
for (int i = 0; i < json.size(); i++) {
final JsonObject obj = json.getJsonObject(i);
if (obj.containsKey("INFO_TYPE") && "test".equals(obj.getString("INFO_TYPE"))) {
children.add(new SlingRemoteTest(testClass, obj));
}
}
log.info("Server-side tests executed as {} at {} with path {}", new Object[] { this.username, testParameters.getJunitServletUrl(), testHttpClient.getTestExecutionPath() });
// Optionally check that number of tests is as expected
if (testParameters instanceof SlingTestsCountChecker) {
((SlingTestsCountChecker) testParameters).checkNumberOfTests(children.size());
}
}
Aggregations