@@ -23,6 +23,7 @@ |
import csip.utils.JSONUtils; |
import csip.utils.Services; |
import java.io.File; |
+import java.net.URISyntaxException; |
import java.util.Arrays; |
import java.util.Date; |
import java.util.List; |
@@ -34,6 +35,7 @@ |
import java.util.logging.SimpleFormatter; |
import java.util.logging.StreamHandler; |
import org.apache.commons.io.FileUtils; |
+import org.apache.http.client.utils.URIBuilder; |
import org.codehaus.jettison.json.JSONArray; |
import org.codehaus.jettison.json.JSONException; |
import org.codehaus.jettison.json.JSONObject; |
@@ -58,12 +60,13 @@ |
File target; |
|
String testing; |
- int concurrent; |
- int timeout; |
- int delay; |
- int rounds; |
+ int concurrent = 1; |
+ int timeout = 1000; |
+ int delay = 0; |
+ int rounds = 1; |
+ String contextUrl = null; |
|
- boolean downloadFiles; |
+ boolean downloadFiles = true; |
String logLevel = "WARNING"; |
final JSONArray reports = new JSONArray(); |
|
@@ -100,24 +103,36 @@ |
throw new RuntimeException("invalid testing method: " + testing); |
} |
|
- concurrent = Integer.parseInt(config.getProperty("concurrency", "1")); |
- if (concurrent < 1) { |
- concurrent = 1; |
+ String d = config.getProperty("contextURL", System.getProperty("csip.test.contexturl")); |
+ if (d != null && !d.equals("${csip.test.contexturl}")) { |
+ contextUrl = d; |
} |
- timeout = Integer.parseInt(config.getProperty("timeout", "3600")); |
- if (timeout < 1000) { |
- timeout = 1000; |
+ |
+ d = config.getProperty("concurrency", System.getProperty("csip.test.concurrency")); |
+ if (d != null) { |
+ concurrent = Integer.parseInt(d); |
} |
- delay = Integer.parseInt(config.getProperty("delay", "0")); |
- if (delay < 0) { |
- delay = 0; |
+ |
+ d = config.getProperty("timeout", System.getProperty("csip.test.timeout")); |
+ if (d != null) { |
+ timeout = Integer.parseInt(d); |
} |
- rounds = Integer.parseInt(config.getProperty("rounds", "1")); |
- if (rounds < 1) { |
- rounds = 1; |
+ |
+ d = config.getProperty("delay", System.getProperty("csip.test.delay")); |
+ if (d != null) { |
+ delay = Integer.parseInt(d); |
} |
+ |
+ d = config.getProperty("rounds", System.getProperty("csip.test.rounds")); |
+ if (d != null) { |
+ rounds = Integer.parseInt(d); |
+ } |
+ |
// warmup phase: 0-off, 1-on |
- downloadFiles = Boolean.parseBoolean(config.getProperty("download_files", "true")); |
+ d = config.getProperty("download_files", System.getProperty("csip.test.downloadfiles")); |
+ if (d != null) { |
+ downloadFiles = Boolean.parseBoolean(d); |
+ } |
|
logLevel = config.getProperty("logLevel", "WARNING"); |
if ((logLevel != null) && (logLevel.length() > 0)) { |
@@ -154,7 +169,11 @@ |
File f = files[i]; |
JSONObject json = new JSONObject(FileUtils.readFileToString(f)); |
String url = JSONUtils.getMetaInfo(json).getString("service_url"); |
- System.out.println(f.getName() + " [" + url + "] "); |
+ if (contextUrl != null) { |
+ url = contextUrl + getServicePath(url); |
+ } |
+ |
+ System.out.println(f.getName() + " >>>>>>>>> " + url + " "); |
report.put("file", f.toString()); |
report.put("service", url); |
|
@@ -407,14 +426,22 @@ |
} |
|
|
+ static String getServicePath(String url) throws URISyntaxException { |
+// URIBuilder b = new URIBuilder("http://localhost:8080/csip-example/m/simpleservice/2.0"); |
+ URIBuilder b = new URIBuilder(url); |
+ return b.getPath().substring(b.getPath().indexOf('/', 1)); |
+ } |
+ |
+ |
public static void main(String[] args) throws Exception { |
-// args = new String[]{"/od/projects/csip-all/csip-example/test/service_tests/all"}; |
- args = new String[]{"/od/tmp/csip-testing"}; |
- Properties config = new Properties(); |
- config.setProperty("concurrency", "1"); |
- config.setProperty("verify", "keyvalue"); |
-// config.setProperty("rounds", "3"); |
-// config.setProperty("delay", "3000"); |
- System.out.println(run(config, args).toString(4).replace("\\/", "/")); |
+//// args = new String[]{"/od/projects/csip-all/csip-example/test/service_tests/all"}; |
+// args = new String[]{"/od/tmp/csip-testing"}; |
+// Properties config = new Properties(); |
+// config.setProperty("concurrency", "1"); |
+// config.setProperty("verify", "keyvalue"); |
+//// config.setProperty("rounds", "3"); |
+//// config.setProperty("delay", "3000"); |
+// System.out.println(run(config, args).toString(4).replace("\\/", "/")); |
+ |
} |
} |