in src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java [97:136]
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();
// Response contains an array of objects identified by
// their INFO_TYPE, extract the tests
// 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());
}
}