SLING-2602 : Simplify usage of system properties for integration tests
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1387625 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java b/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
index 9f7d222..86d423b 100644
--- a/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
+++ b/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
@@ -49,9 +49,10 @@
/** If this system property is set, the startup check is skipped. */
public static final String PROPERTY_SKIP_STARTUP_CHECK = "launchpad.skip.startupcheck";
- public static final String HTTP_BASE_URL = removeEndingSlash(System.getProperty("launchpad.http.server.url", "http://localhost:8888"));
- public static final String WEBDAV_BASE_URL = removeEndingSlash(System.getProperty("launchpad.webdav.server.url", "http://localhost:8888"));
- public static final String SERVLET_CONTEXT = removeEndingSlash(System.getProperty("launchpad.servlet.context", ""));
+ public static final String HTTP_URL = removeEndingSlash(System.getProperty("launchpad.http.server.url", "http://localhost:8888"));
+ public static final String HTTP_BASE_URL = removePath(HTTP_URL);
+ public static final String WEBDAV_BASE_URL = removeEndingSlash(System.getProperty("launchpad.webdav.server.url", HTTP_BASE_URL));
+ public static final String SERVLET_CONTEXT = removeEndingSlash(System.getProperty("launchpad.servlet.context", getPath(HTTP_URL)));
/** base path for test files */
public static final String TEST_PATH = "/launchpad-integration-tests";
@@ -121,6 +122,24 @@
return str;
}
+ private static String removePath(String str) {
+ final int pos = str.indexOf(":/");
+ final int slashPos = str.indexOf('/', pos+3);
+ if ( slashPos != -1 ) {
+ return str.substring(0, slashPos);
+ }
+ return str;
+ }
+
+ private static String getPath(String str) {
+ final int pos = str.indexOf(":/");
+ final int slashPos = str.indexOf('/', pos+3);
+ if ( slashPos != -1 ) {
+ return str.substring(slashPos);
+ }
+ return "";
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();