in src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ServerSideScriptsTest.java [212:253]
public void runScripts() throws Exception {
final String resourceType = RESOURCE_TYPE_PREFIX + '/' + test.testName;
final String scriptPath = "/apps/" + resourceType;
String toDelete = null;
try {
// create test node
this.slingClient.createNode(scriptPath,
"jcr:primaryType", "sling:Folder",
"jcr:mixinTypes", "sling:Test",
"sling:resourceType", RESOURCE_TYPE_PREFIX + '/' + test.testName);
toDelete = scriptPath;
final String destPath = scriptPath + "/test.txt" + test.scriptExtension;
logger.info("Setting up node {} for {}", destPath, test.testScriptFile.getAbsoluteFile());
this.slingClient.upload(destPath, new FileInputStream(test.testScriptFile), -1, false);
// SLING-3087 with Oak, the Sling JUnit's scriptable module TestAllPaths class
// might still see the old script, and not yet the new one, for some time.
// There's probably a better way to avoid this...for now just wait a bit
Thread.sleep(2000L);
final long startTime = System.currentTimeMillis();
final ServerSideTestClient.TestResults results = slingClient.runTests("org.apache.sling.junit.scriptable.ScriptableTestsProvider");
assertEquals("Expecting 1 scriptable test", 1, results.getTestCount());
final int failureCount = test.willFail ? 1 : 0;
if( results.getFailures().size() != failureCount) {
fail("Expected "
+ failureCount + " failing tests but got " + results.getFailures().size()
+ " for " + test.testScriptFile.getAbsolutePath()
+ ": " + results.getFailures());
}
logger.info("Execution of {} took {} msec", test, System.currentTimeMillis() - startTime);
} finally {
if(toDelete != null) {
this.slingClient.delete(toDelete);
}
}
}