in src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java [507:537]
public String executeScript(String localFilename, List<NameValuePair> params) throws Exception {
// Use unique resource type
int counter = 0;
synchronized (getClass()) {
counter = ++executeCounter;
}
final String resourceType = EXECUTE_RESOURCE_TYPE + counter;
final String scriptPath = "/apps/" + resourceType;
testClient.mkdirs(WEBDAV_BASE_URL , scriptPath);
final int pos = localFilename.lastIndexOf(".");
if(pos < 1) {
throw new IllegalArgumentException("localFilename must have extension (" + localFilename + ")");
}
final String ext = localFilename.substring(pos + 1);
final List<String> toDelete = new LinkedList<String>();
try {
toDelete.add(uploadTestScript(scriptPath, localFilename, "txt." + ext));
final Map<String, String> props = new HashMap<String, String>();
props.put(SLING_RESOURCE_TYPE, resourceType);
final String nodePath = scriptPath + "/node" + counter;
final String nodeUrl = testClient.createNode(HTTP_BASE_URL + nodePath, props);
toDelete.add(nodeUrl);
return getContent(nodeUrl + ".txt", CONTENT_TYPE_DONTCARE, params);
} finally {
for(String url : toDelete) {
testClient.delete(url);
}
}
}