You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2014/04/27 13:14:20 UTC
svn commit: r1590373 - in
/sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests:
pom.xml
src/main/java/org/apache/sling/launchpad/karaf/testing/KarafTestSupport.java
Author: olli
Date: Sun Apr 27 11:14:20 2014
New Revision: 1590373
URL: http://svn.apache.org/r1590373
Log:
SLING-3017 define test and configuration support more obviously, update Karaf to 3.0.1
Modified:
sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/pom.xml
sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/src/main/java/org/apache/sling/launchpad/karaf/testing/KarafTestSupport.java
Modified: sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/pom.xml?rev=1590373&r1=1590372&r2=1590373&view=diff
==============================================================================
--- sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/pom.xml (original)
+++ sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/pom.xml Sun Apr 27 11:14:20 2014
@@ -48,11 +48,17 @@
<version>2.0</version>
<scope>test</scope>
</dependency>
+ <!-- OSGi -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
<!-- Apache Karaf -->
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>org.apache.karaf.features.core</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1</version>
<scope>provided</scope>
</dependency>
<!-- Apache Sling -->
@@ -108,7 +114,7 @@
<groupId>org.apache.karaf</groupId>
<artifactId>apache-karaf</artifactId>
<type>tar.gz</type>
- <version>3.0.0</version>
+ <version>3.0.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
Modified: sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/src/main/java/org/apache/sling/launchpad/karaf/testing/KarafTestSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/src/main/java/org/apache/sling/launchpad/karaf/testing/KarafTestSupport.java?rev=1590373&r1=1590372&r2=1590373&view=diff
==============================================================================
--- sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/src/main/java/org/apache/sling/launchpad/karaf/testing/KarafTestSupport.java (original)
+++ sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-integration-tests/src/main/java/org/apache/sling/launchpad/karaf/testing/KarafTestSupport.java Sun Apr 27 11:14:20 2014
@@ -19,6 +19,7 @@
package org.apache.sling.launchpad.karaf.testing;
import java.io.File;
+import java.io.IOException;
import java.net.ServerSocket;
import javax.inject.Inject;
@@ -30,6 +31,8 @@ import org.ops4j.pax.exam.util.Filter;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
@@ -44,18 +47,13 @@ import static org.ops4j.pax.tinybundles.
public abstract class KarafTestSupport {
- protected int sshPort;
-
- protected int httpPort;
-
- protected int rmiRegistryPort;
-
- protected int rmiServerPort;
-
@Inject
protected BundleContext bundleContext;
@Inject
+ protected ConfigurationAdmin configurationAdmin;
+
+ @Inject
@Filter(timeout = 300000)
BootFinished bootFinished;
@@ -63,11 +61,11 @@ public abstract class KarafTestSupport {
public static final String KARAF_ARTIFACT_ID = "apache-karaf";
- public static final String KARAF_VERSION = "3.0.0";
+ public static final String KARAF_VERSION = "3.0.1";
public static final String KARAF_NAME = "Apache Karaf";
- protected KarafTestSupport() {
+ public KarafTestSupport() {
}
protected synchronized int findFreePort() {
@@ -81,47 +79,37 @@ public abstract class KarafTestSupport {
}
}
- protected synchronized int sshPort() {
- if (sshPort == 0) {
- sshPort = findFreePort();
- }
- return sshPort;
- }
+ // test support
- protected synchronized int httpPort() {
- if (httpPort == 0) {
- httpPort = findFreePort();
- }
- return httpPort;
+ protected int httpPort() throws IOException {
+ final Configuration configuration = configurationAdmin.getConfiguration("org.ops4j.pax.web");
+ return Integer.parseInt(configuration.getProperties().get("org.osgi.service.http.port").toString());
}
- protected synchronized int rmiRegistryPort() {
- if (rmiRegistryPort == 0) {
- rmiRegistryPort = findFreePort();
+ protected Bundle findBundle(final String symbolicName) {
+ for (final Bundle bundle : bundleContext.getBundles()) {
+ if (symbolicName.equals(bundle.getSymbolicName())) {
+ return bundle;
+ }
}
- return rmiRegistryPort;
+ return null;
}
- protected synchronized int rmiServerPort() {
- if (rmiServerPort == 0) {
- rmiServerPort = findFreePort();
- }
- return rmiServerPort;
- }
+ // configuration support
- public String karafGroupId() {
+ protected String karafGroupId() {
return KARAF_GROUP_ID;
}
- public String karafArtifactId() {
+ protected String karafArtifactId() {
return KARAF_ARTIFACT_ID;
}
- public String karafVersion() {
+ protected String karafVersion() {
return KARAF_VERSION;
}
- public String karafName() {
+ protected String karafName() {
return KARAF_NAME;
}
@@ -129,15 +117,6 @@ public abstract class KarafTestSupport {
return editConfigurationFileExtend("etc/org.apache.karaf.features.cfg", "featuresBoot", "," + feature);
}
- protected Bundle findBundle(final String symbolicName) {
- for (final Bundle bundle : bundleContext.getBundles()) {
- if (symbolicName.equals(bundle.getSymbolicName())) {
- return bundle;
- }
- }
- return null;
- }
-
protected String featureRepository() {
return "mvn:org.apache.sling/org.apache.sling.launchpad.karaf-features/0.1.1-SNAPSHOT/xml/features";
}
@@ -148,26 +127,30 @@ public abstract class KarafTestSupport {
.add(KarafTestSupport.class)
.set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.sling.launchpad.karaf-integration-tests")
.set(Constants.EXPORT_PACKAGE, "org.apache.sling.launchpad.karaf.testing")
- .set(Constants.IMPORT_PACKAGE, "javax.inject, org.apache.karaf.features, org.ops4j.pax.exam, org.ops4j.pax.exam.options, org.ops4j.pax.exam.util, org.ops4j.pax.tinybundles.core, org.osgi.framework")
+ .set(Constants.IMPORT_PACKAGE, "javax.inject, org.apache.karaf.features, org.ops4j.pax.exam, org.ops4j.pax.exam.options, org.ops4j.pax.exam.util, org.ops4j.pax.tinybundles.core, org.osgi.framework, org.osgi.service.cm")
.build()
).start();
}
protected Option[] baseConfiguration() {
+ final int rmiRegistryPort = findFreePort();
+ final int rmiServerPort = findFreePort();
+ final int sshPort = findFreePort();
+ final int httpPort = findFreePort();
return options(
karafDistributionConfiguration()
.frameworkUrl(maven().groupId(karafGroupId()).artifactId(karafArtifactId()).version(karafVersion()).type("tar.gz"))
.karafVersion(karafVersion())
.useDeployFolder(false)
.name(karafName())
- .unpackDirectory(new File("target/paxexam/")),
+ .unpackDirectory(new File("target/paxexam/" + getClass().getSimpleName())),
keepRuntimeFolder(),
logLevel(LogLevelOption.LogLevel.INFO),
editConfigurationFileExtend("etc/org.apache.karaf.features.cfg", "featuresRepositories", "," + featureRepository()),
- editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", Integer.toString(rmiRegistryPort())),
- editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", Integer.toString(rmiServerPort())),
- editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", Integer.toString(sshPort())),
- editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port", Integer.toString(httpPort())),
+ editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", Integer.toString(rmiRegistryPort)),
+ editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", Integer.toString(rmiServerPort)),
+ editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", Integer.toString(sshPort)),
+ editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port", Integer.toString(httpPort)),
mavenBundle()
.groupId("org.ops4j.pax.tinybundles")
.artifactId("tinybundles")