You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2014/05/08 15:30:56 UTC
svn commit: r1593275 - in
/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl:
./ helpers/
Author: rombert
Date: Thu May 8 13:30:55 2014
New Revision: 1593275
URL: http://svn.apache.org/r1593275
Log:
SLING-3544 - Integration tests running against a live Sling Launchpad
instance
Removing hardcoding of repository urls.
Added:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadConfig.java (contents, props changed)
- copied, changed from r1593274, sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadUtils.java
Removed:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadUtils.java
Modified:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ExternalSlingLaunchpad.java
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SlingWstServer.java
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ToolingSupportBundle.java
Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java?rev=1593275&r1=1593274&r2=1593275&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java Thu May 8 13:30:55 2014
@@ -30,7 +30,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.sling.ide.osgi.OsgiClientException;
import org.apache.sling.ide.test.impl.helpers.DisableDebugStatusHandlers;
import org.apache.sling.ide.test.impl.helpers.ExternalSlingLaunchpad;
-import org.apache.sling.ide.test.impl.helpers.LaunchpadUtils;
+import org.apache.sling.ide.test.impl.helpers.LaunchpadConfig;
import org.apache.sling.ide.test.impl.helpers.MavenDependency;
import org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest;
import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
@@ -58,10 +58,13 @@ import org.osgi.service.prefs.BackingSto
*/
public class BundleDeploymentTest {
- private final SlingWstServer wstServer = new SlingWstServer();
+ private final LaunchpadConfig config = LaunchpadConfig.getInstance();
+
+ private final SlingWstServer wstServer = new SlingWstServer(config);
@Rule
- public TestRule chain = RuleChain.outerRule(new ExternalSlingLaunchpad()).around(new ToolingSupportBundle())
+ public TestRule chain = RuleChain.outerRule(new ExternalSlingLaunchpad(config))
+ .around(new ToolingSupportBundle(config))
.around(wstServer);
@Rule
@@ -139,7 +142,7 @@ public class BundleDeploymentTest {
private void assertSimpleServletCallsSucceeds(String expectedOutput) throws IOException, HttpException, URIException {
HttpClient c = new HttpClient();
- GetMethod gm = new GetMethod("http://localhost:" + LaunchpadUtils.getLaunchpadPort() + "/simple-servlet");
+ GetMethod gm = new GetMethod(config.getUrl() + "simple-servlet");
try {
int status = c.executeMethod(gm);
Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java?rev=1593275&r1=1593274&r2=1593275&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java Thu May 8 13:30:55 2014
@@ -34,7 +34,7 @@ import org.apache.commons.httpclient.met
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.sling.ide.test.impl.helpers.DisableDebugStatusHandlers;
import org.apache.sling.ide.test.impl.helpers.ExternalSlingLaunchpad;
-import org.apache.sling.ide.test.impl.helpers.LaunchpadUtils;
+import org.apache.sling.ide.test.impl.helpers.LaunchpadConfig;
import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
import org.apache.sling.ide.test.impl.helpers.ServerAdapter;
import org.apache.sling.ide.test.impl.helpers.SlingWstServer;
@@ -56,10 +56,12 @@ import org.junit.rules.TestRule;
*/
public class ContentDeploymentTest {
- private final SlingWstServer wstServer = new SlingWstServer();
+ private final LaunchpadConfig config = LaunchpadConfig.getInstance();
+
+ private final SlingWstServer wstServer = new SlingWstServer(config);
@Rule
- public TestRule chain = RuleChain.outerRule(new ExternalSlingLaunchpad()).around(wstServer);
+ public TestRule chain = RuleChain.outerRule(new ExternalSlingLaunchpad(config)).around(wstServer);
@Rule
public TemporaryProject projectRule = new TemporaryProject();
@@ -100,7 +102,7 @@ public class ContentDeploymentTest {
// verify that file is updated
assertSimpleCallsSucceeds("goodbye, world");
- project.deleteMember(Path.fromPortableString("/jcr_root/hello.txt"));
+ project.deleteMember(Path.fromPortableString("jcr_root/hello.txt"));
Thread.sleep(2000); // for good measure, make sure the output is there - TODO replace with polling
// verify that the file is deleted
@@ -109,7 +111,7 @@ public class ContentDeploymentTest {
private void assertSimpleCallsSucceeds(String expectedOutput) throws IOException, HttpException, URIException {
HttpClient c = new HttpClient();
- GetMethod gm = new GetMethod("http://localhost:" + LaunchpadUtils.getLaunchpadPort() + "/hello.txt");
+ GetMethod gm = new GetMethod(config.getUrl() + "hello.txt");
try {
int status = c.executeMethod(gm);
@@ -123,7 +125,7 @@ public class ContentDeploymentTest {
private void assertResourceNotFound() throws IOException, HttpException, URIException {
HttpClient c = new HttpClient();
- GetMethod gm = new GetMethod("http://localhost:" + LaunchpadUtils.getLaunchpadPort() + "/hello.txt");
+ GetMethod gm = new GetMethod(config.getUrl() + "hello.txt");
try {
int status = c.executeMethod(gm);
@@ -137,8 +139,9 @@ public class ContentDeploymentTest {
public void cleanUp() throws HttpException, IOException {
HttpClient c = new HttpClient();
c.getParams().setAuthenticationPreemptive(true);
- c.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "admin"));
- PostMethod pm = new PostMethod("http://localhost:" + LaunchpadUtils.getLaunchpadPort() + "/hello.txt");
+ c.getState().setCredentials(AuthScope.ANY,
+ new UsernamePasswordCredentials(config.getUsername(), config.getPassword()));
+ PostMethod pm = new PostMethod(config.getUrl() + "hello.txt");
Part[] parts = { new StringPart(":operation", "delete") };
pm.setRequestEntity(new MultipartRequestEntity(parts, pm.getParams()));
try {
Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ExternalSlingLaunchpad.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ExternalSlingLaunchpad.java?rev=1593275&r1=1593274&r2=1593275&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ExternalSlingLaunchpad.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ExternalSlingLaunchpad.java Thu May 8 13:30:55 2014
@@ -40,21 +40,25 @@ public class ExternalSlingLaunchpad exte
private static final int EXPECTED_START_LEVEL = 30;
private static final long MAX_WAIT_TIME_MS = TimeUnit.MINUTES.toMillis(1);
+ private final LaunchpadConfig config;
+
+ public ExternalSlingLaunchpad(LaunchpadConfig config) {
+ this.config = config;
+ }
+
@Override
protected void before() throws Throwable {
- int launchpadPort = LaunchpadUtils.getLaunchpadPort();
-
- Credentials creds = new UsernamePasswordCredentials("admin", "admin");
+ Credentials creds = new UsernamePasswordCredentials(config.getUsername(), config.getPassword());
HttpClient client = new HttpClient();
- client.getState().setCredentials(new AuthScope("localhost", launchpadPort), creds);
+ client.getState().setCredentials(new AuthScope(config.getHostname(), config.getPort()), creds);
long cutoff = System.currentTimeMillis() + MAX_WAIT_TIME_MS;
List<SlingReadyRule> rules = new ArrayList<SlingReadyRule>();
- rules.add(new StartLevelSlingReadyRule(client, launchpadPort));
- rules.add(new ActiveBundlesSlingReadyRule(client, launchpadPort));
+ rules.add(new StartLevelSlingReadyRule(client));
+ rules.add(new ActiveBundlesSlingReadyRule(client));
for (SlingReadyRule rule : rules) {
while (true) {
@@ -90,9 +94,9 @@ public class ExternalSlingLaunchpad exte
private final HttpClient client;
private final GetMethod httpMethod;
- public StartLevelSlingReadyRule(HttpClient client, int launchpadPort) {
+ public StartLevelSlingReadyRule(HttpClient client) {
this.client = client;
- httpMethod = new GetMethod("http://localhost:" + launchpadPort + "/system/console/vmstat");
+ httpMethod = new GetMethod(config.getUrl() + "system/console/vmstat");
}
@Override
@@ -123,9 +127,9 @@ public class ExternalSlingLaunchpad exte
private final HttpClient client;
private final GetMethod httpMethod;
- public ActiveBundlesSlingReadyRule(HttpClient client, int launchpadPort) {
+ public ActiveBundlesSlingReadyRule(HttpClient client) {
this.client = client;
- httpMethod = new GetMethod("http://localhost:" + launchpadPort + "/system/console/bundles.json");
+ httpMethod = new GetMethod(config.getUrl() + "system/console/bundles.json");
}
@Override
Copied: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadConfig.java (from r1593274, sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadUtils.java)
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadConfig.java?p2=sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadConfig.java&p1=sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadUtils.java&r1=1593274&r2=1593275&rev=1593275&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadUtils.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadConfig.java Thu May 8 13:30:55 2014
@@ -16,12 +16,50 @@
*/
package org.apache.sling.ide.test.impl.helpers;
-public class LaunchpadUtils {
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class LaunchpadConfig {
+
+ private static final LaunchpadConfig INSTANCE = new LaunchpadConfig();
+
+ public static LaunchpadConfig getInstance() {
+ return INSTANCE;
+ }
/**
* @return the configured launchpad port
*/
- public static int getLaunchpadPort() {
+ public int getPort() {
return Integer.getInteger("launchpad.http.port", 8080);
}
+
+ public String getUsername() {
+ return "admin";
+ }
+
+ public String getPassword() {
+ return "admin";
+ }
+
+ public String getHostname() {
+ return "localhost";
+ }
+
+ public String getProtocol() {
+ return "http";
+ }
+
+ public String getContextPath() {
+ return "/";
+ }
+
+ public String getUrl() {
+ try {
+ return new URI(getProtocol(), null, getHostname(), getPort(), getContextPath(), null, null)
+ .toString();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
Propchange: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/LaunchpadConfig.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SlingWstServer.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SlingWstServer.java?rev=1593275&r1=1593274&r2=1593275&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SlingWstServer.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SlingWstServer.java Thu May 8 13:30:55 2014
@@ -42,8 +42,13 @@ import org.junit.rules.ExternalResource;
*/
public class SlingWstServer extends ExternalResource {
+ private final LaunchpadConfig config;
private IServer server;
+ public SlingWstServer(LaunchpadConfig config) {
+ this.config = config;
+ }
+
@Override
protected void before() throws Throwable {
IRuntimeType launchpadRuntime = null;
@@ -77,12 +82,11 @@ public class SlingWstServer extends Exte
IServerWorkingCopy wc = serverType.createServer("temp.sling.launchpad.server.id", null,
new NullProgressMonitor());
- // TODO - remove hardcoding
- wc.setHost("localhost");
- wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, LaunchpadUtils.getLaunchpadPort());
- wc.setAttribute(ISlingLaunchpadServer.PROP_CONTEXT_PATH, "/");
- wc.setAttribute(ISlingLaunchpadServer.PROP_USERNAME, "admin");
- wc.setAttribute(ISlingLaunchpadServer.PROP_PASSWORD, "admin");
+ wc.setHost(config.getHostname());
+ wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, config.getPort());
+ wc.setAttribute(ISlingLaunchpadServer.PROP_CONTEXT_PATH, config.getContextPath());
+ wc.setAttribute(ISlingLaunchpadServer.PROP_USERNAME, config.getUsername());
+ wc.setAttribute(ISlingLaunchpadServer.PROP_PASSWORD, config.getPassword());
wc.setAttribute("auto-publish-setting", ISlingLaunchpadServer.PUBLISH_STATE_RESOURCE_CHANGE);
wc.setAttribute("auto-publish-time", 0);
Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ToolingSupportBundle.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ToolingSupportBundle.java?rev=1593275&r1=1593274&r2=1593275&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ToolingSupportBundle.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ToolingSupportBundle.java Thu May 8 13:30:55 2014
@@ -30,6 +30,12 @@ import org.junit.rules.ExternalResource;
*/
public class ToolingSupportBundle extends ExternalResource {
+ private final LaunchpadConfig config;
+
+ public ToolingSupportBundle(LaunchpadConfig config) {
+ this.config = config;
+ }
+
@Override
protected void before() throws Throwable {
@@ -37,8 +43,8 @@ public class ToolingSupportBundle extend
EmbeddedArtifact toolingBundle = locator.loadToolingSupportBundle();
OsgiClientFactory clientFactory = Activator.getDefault().getOsgiClientFactory();
- OsgiClient osgiClient = clientFactory.createOsgiClient(new RepositoryInfo("admin", "admin", "http://localhost:"
- + LaunchpadUtils.getLaunchpadPort() + "/"));
+ OsgiClient osgiClient = clientFactory.createOsgiClient(new RepositoryInfo(config.getUsername(), config
+ .getPassword(), config.getUrl()));
osgiClient.installBundle(toolingBundle.openInputStream(), toolingBundle.getName());
}
}