You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2016/04/12 15:35:38 UTC
aries-rsa git commit: [ARIES-1526] Add itest for fastbin
Repository: aries-rsa
Updated Branches:
refs/heads/master 63f5aed5f -> 495a0e939
[ARIES-1526] Add itest for fastbin
Project: http://git-wip-us.apache.org/repos/asf/aries-rsa/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-rsa/commit/495a0e93
Tree: http://git-wip-us.apache.org/repos/asf/aries-rsa/tree/495a0e93
Diff: http://git-wip-us.apache.org/repos/asf/aries-rsa/diff/495a0e93
Branch: refs/heads/master
Commit: 495a0e939964167f4008a02ae7c11da891c41534
Parents: 63f5aed
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Apr 12 15:34:12 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Apr 12 15:34:21 2016 +0200
----------------------------------------------------------------------
itests/felix/pom.xml | 28 ++++-
.../aries/rsa/itests/felix/RsaTestBase.java | 66 ++++++-----
.../rsa/itests/felix/TestDiscoveryExport.java | 115 ------------------
.../aries/rsa/itests/felix/TestRoundTrip.java | 81 -------------
.../felix/fastbin/TestFastbinRoundTrip.java | 85 +++++++++++++
.../helpers/ZookeeperDiscoveryConfigurer.java | 28 -----
.../helpers/ZookeeperServerConfigurer.java | 32 -----
.../itests/felix/tcp/TestDiscoveryExport.java | 118 +++++++++++++++++++
.../rsa/itests/felix/tcp/TestRoundTrip.java | 84 +++++++++++++
itests/pom.xml | 5 +
10 files changed, 356 insertions(+), 286 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/pom.xml
----------------------------------------------------------------------
diff --git a/itests/felix/pom.xml b/itests/felix/pom.xml
index ae15fe7..4728c9e 100644
--- a/itests/felix/pom.xml
+++ b/itests/felix/pom.xml
@@ -67,6 +67,19 @@
<artifactId>org.apache.aries.rsa.provider.tcp</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.fusesource.hawtdispatch</groupId>
+ <artifactId>hawtdispatch</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.fusesource.hawtbuf</groupId>
+ <artifactId>hawtbuf</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.rsa.provider</groupId>
+ <artifactId>org.apache.aries.rsa.provider.fastbin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.felix</groupId>
@@ -88,8 +101,6 @@
<artifactId>org.apache.aries.rsa.examples.echotcp.consumer</artifactId>
<version>${project.version}</version>
</dependency>
-
-
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
@@ -103,6 +114,11 @@
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-cm</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-inject</artifactId>
<scope>test</scope>
</dependency>
@@ -150,6 +166,14 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkCount>1</forkCount>
+ <reuseForks>false</reuseForks>
+ </configuration>
+ </plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java
index bd4a9fe..1e63729 100644
--- a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java
@@ -6,35 +6,32 @@ import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
import java.io.IOException;
-import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import javax.inject.Inject;
-import org.apache.aries.rsa.itests.felix.helpers.ZookeeperDiscoveryConfigurer;
-import org.apache.aries.rsa.itests.felix.helpers.ZookeeperServerConfigurer;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
import org.ops4j.pax.exam.options.OptionalCompositeOption;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
import org.osgi.service.cm.ConfigurationAdmin;
public class RsaTestBase {
+ protected static final String ZK_PORT = "15201";
@Inject
- BundleContext bundleContext;
+ protected BundleContext bundleContext;
@Inject
ConfigurationAdmin configAdmin;
- static OptionalCompositeOption localRepo() {
+ protected static OptionalCompositeOption localRepo() {
String localRepo = System.getProperty("maven.repo.local");
if (localRepo == null) {
localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
@@ -43,7 +40,7 @@ public class RsaTestBase {
.useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo));
}
- static MavenArtifactProvisionOption mvn(String groupId, String artifactId) {
+ protected static MavenArtifactProvisionOption mvn(String groupId, String artifactId) {
return mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
}
@@ -65,40 +62,27 @@ public class RsaTestBase {
}
}
- static Option echoTcpConsumer() {
+ protected static Option echoTcpConsumer() {
return CoreOptions.composite(
mvn("org.apache.felix", "org.apache.felix.scr"),
mvn("org.apache.aries.rsa.examples.echotcp", "org.apache.aries.rsa.examples.echotcp.api"),
- // Consumer is needed to trigger service import. Pax exam inject does not work for it
+ // Consumer is needed to trigger service import. Pax exam inject does not trigger it
mvn("org.apache.aries.rsa.examples.echotcp", "org.apache.aries.rsa.examples.echotcp.consumer")
);
}
- static Option echoTcpService() {
- return CoreOptions.composite(
+ protected static Option echoTcpService() {
+ return composite(
mvn("org.apache.felix", "org.apache.felix.scr"),
mvn("org.apache.aries.rsa.examples.echotcp", "org.apache.aries.rsa.examples.echotcp.api"),
mvn("org.apache.aries.rsa.examples.echotcp", "org.apache.aries.rsa.examples.echotcp.service")
);
}
- static InputStream configBundleConsumer() {
- return TinyBundles.bundle()
- .add(ZookeeperDiscoveryConfigurer.class)
- .set(Constants.BUNDLE_ACTIVATOR, ZookeeperDiscoveryConfigurer.class.getName())
- .build(TinyBundles.withBnd());
- }
-
- static InputStream configBundleServer() {
- return TinyBundles.bundle()
- .add(ZookeeperServerConfigurer.class)
- .set(Constants.BUNDLE_ACTIVATOR, ZookeeperServerConfigurer.class.getName())
- .build(TinyBundles.withBnd());
- }
-
- static Option rsaTcpZookeeper() {
+ protected static Option rsaCoreZookeeper() {
return composite(junitBundles(),
localRepo(),
+ systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
systemProperty("zkPort").value("15201"),
systemProperty("aries.rsa.hostname").value("localhost"),
@@ -106,7 +90,6 @@ public class RsaTestBase {
mvn("org.apache.aries.rsa", "org.apache.aries.rsa.core"),
mvn("org.apache.aries.rsa", "org.apache.aries.rsa.spi"),
mvn("org.apache.aries.rsa", "org.apache.aries.rsa.topology-manager"),
- mvn("org.apache.aries.rsa.provider", "org.apache.aries.rsa.provider.tcp"),
mvn("org.apache.aries.rsa.discovery", "org.apache.aries.rsa.discovery.local"),
mvn("org.apache.zookeeper", "zookeeper"),
mvn("org.apache.aries.rsa.discovery", "org.apache.aries.rsa.discovery.zookeeper")
@@ -114,4 +97,31 @@ public class RsaTestBase {
);
}
+ protected static Option rsaTcp() {
+ return mvn("org.apache.aries.rsa.provider", "org.apache.aries.rsa.provider.tcp");
+ }
+
+ protected static Option rsaFastBin() {
+ return composite(mvn("org.fusesource.hawtbuf", "hawtbuf"),
+ mvn("org.fusesource.hawtdispatch", "hawtdispatch"),
+ mvn("org.apache.aries.rsa.provider", "org.apache.aries.rsa.provider.fastbin"));
+ }
+
+ protected static Option configZKConsumer() {
+ return newConfiguration("org.apache.aries.rsa.discovery.zookeeper")
+ .put("zookeeper.host", "127.0.0.1")
+ .put("zookeeper.port", ZK_PORT)
+ .asOption();
+ }
+
+ protected static Option configZKServer() {
+ return newConfiguration("org.apache.aries.rsa.discovery.zookeeper.server")
+ .put("clientPort", ZK_PORT).asOption();
+ }
+
+ protected static Option configFastBin(String port) {
+ return newConfiguration("org.apache.aries.rsa.provider.fastbin")
+ .put("uri", "tcp://0.0.0.0:" + port).asOption();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestDiscoveryExport.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestDiscoveryExport.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestDiscoveryExport.java
deleted file mode 100644
index ffb4a2c..0000000
--- a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestDiscoveryExport.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.apache.aries.rsa.itests.felix;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-import static org.ops4j.pax.exam.CoreOptions.streamBundle;
-
-import java.io.ByteArrayInputStream;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
-import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
-import org.apache.aries.rsa.examples.echotcp.api.EchoService;
-import org.apache.aries.rsa.spi.DistributionProvider;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.Stat;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
-
-@RunWith(PaxExam.class)
-public class TestDiscoveryExport extends RsaTestBase {
- private static final String GREETER_ZOOKEEPER_NODE = "/osgi/service_registry/org/apache/aries/rsa/examples/echotcp/api/EchoService";
-
- @Inject
- DistributionProvider tcpProvider;
-
- @Configuration
- public static Option[] configure() throws Exception {
- return new Option[] {
- RsaTestBase.rsaTcpZookeeper(),
- RsaTestBase.echoTcpService(),
- localRepo(),
- streamBundle(configBundleServer())
- };
- }
-
- @Test
- public void testDiscoveryExport() throws Exception {
- String zkPort = bundleContext.getProperty("zkPort");
- ZooKeeper zk = new ZooKeeper("localhost:" + zkPort, 1000, new DummyWatcher());
- assertNodeExists(zk, GREETER_ZOOKEEPER_NODE, 10000);
- String endpointPath = getEndpointPath(zk, GREETER_ZOOKEEPER_NODE);
- EndpointDescription epd = getEndpointDescription(zk, endpointPath);
- zk.close();
-
- EchoService service = (EchoService)tcpProvider
- .importEndpoint(EchoService.class.getClassLoader(),
- bundleContext, new Class[]{EchoService.class}, epd);
- Assert.assertEquals("test", service.echo("test"));
- }
-
- private EndpointDescription getEndpointDescription(ZooKeeper zk, String endpointPath)
- throws KeeperException, InterruptedException {
- byte[] data = zk.getData(endpointPath, false, null);
- ByteArrayInputStream is = new ByteArrayInputStream(data);
- List<EndpointDescriptionType> epdList = new EndpointDescriptionParser().getEndpointDescriptions(is);
- Map<String, Object> props = new PropertiesMapper().toProps(epdList.get(0).getProperty());
- EndpointDescription epd = new EndpointDescription(props);
- return epd;
- }
-
- private String getEndpointPath(ZooKeeper zk, String servicePath) throws KeeperException, InterruptedException {
- List<String> children = zk.getChildren(servicePath, false);
- return servicePath + "/" + children.iterator().next();
- }
-
- private void assertNodeExists(ZooKeeper zk, String zNode, int timeout) {
- long endTime = System.currentTimeMillis() + timeout;
- Stat stat = null;
- while (stat == null && System.currentTimeMillis() < endTime) {
- try {
- stat = zk.exists(zNode, null);
- Thread.sleep(200);
- } catch (Exception e) {
- // Ignore
- }
- }
- Assert.assertNotNull("ZooKeeper node " + zNode + " was not found", stat);
- }
-
- private final class DummyWatcher implements Watcher {
- @Override
- public void process(WatchedEvent event) {
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestRoundTrip.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestRoundTrip.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestRoundTrip.java
deleted file mode 100644
index e6c19a3..0000000
--- a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestRoundTrip.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.apache.aries.rsa.itests.felix;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-import static org.junit.Assert.assertEquals;
-import static org.ops4j.pax.exam.CoreOptions.streamBundle;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
-import java.io.IOException;
-
-import javax.inject.Inject;
-
-import org.apache.aries.rsa.examples.echotcp.api.EchoService;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.ExamSystem;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.TestContainer;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.spi.PaxExamRuntime;
-
-@RunWith(PaxExam.class)
-public class TestRoundTrip extends RsaTestBase {
- private static TestContainer remoteContainer;
-
- @Inject
- EchoService echoService;
-
- public static void startRemote() throws IOException, InterruptedException {
- ExamSystem testSystem = PaxExamRuntime.createTestSystem(remoteConfig());
- remoteContainer = PaxExamRuntime.createContainer(testSystem);
- remoteContainer.start();
- }
-
- private static Option[] remoteConfig() throws IOException {
- return new Option[] {
- rsaTcpZookeeper(),
- echoTcpService(),
- streamBundle(RsaTestBase.configBundleServer()),
- systemProperty("zkPort").value("15201")
- };
- }
-
- @Configuration
- public static Option[] configure() throws Exception {
- startRemote();
- return new Option[] {
- rsaTcpZookeeper(),
- RsaTestBase.echoTcpConsumer(),
- streamBundle(RsaTestBase.configBundleConsumer()),
-
- };
- }
-
- @Test
- public void testCall() throws Exception {
- assertEquals("test", echoService.echo("test"));
- }
-
- public static void shutdownRemote() {
- remoteContainer.stop();
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/fastbin/TestFastbinRoundTrip.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/fastbin/TestFastbinRoundTrip.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/fastbin/TestFastbinRoundTrip.java
new file mode 100644
index 0000000..6efd9fd
--- /dev/null
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/fastbin/TestFastbinRoundTrip.java
@@ -0,0 +1,85 @@
+package org.apache.aries.rsa.itests.felix.fastbin;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+
+import org.apache.aries.rsa.examples.echotcp.api.EchoService;
+import org.apache.aries.rsa.itests.felix.RsaTestBase;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.ExamSystem;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.TestContainer;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.PaxExamRuntime;
+
+@RunWith(PaxExam.class)
+public class TestFastbinRoundTrip extends RsaTestBase {
+ private static TestContainer remoteContainer;
+
+ @Inject
+ EchoService echoService;
+
+ public static void startRemote() throws IOException, InterruptedException {
+ ExamSystem testSystem = PaxExamRuntime.createTestSystem(remoteConfig());
+ remoteContainer = PaxExamRuntime.createContainer(testSystem);
+ remoteContainer.start();
+ }
+
+ private static Option[] remoteConfig() throws IOException {
+ return new Option[] {
+ rsaCoreZookeeper(),
+ rsaFastBin(),
+ echoTcpService(),
+ configZKServer(),
+ configZKConsumer(),
+ configFastBin("2544"),
+ };
+ }
+
+ @Configuration
+ public static Option[] configure() throws Exception {
+ startRemote();
+ return new Option[] {
+ rsaCoreZookeeper(),
+ rsaFastBin(),
+ echoTcpConsumer(),
+ configZKConsumer(),
+ configFastBin("2545")
+ };
+ }
+
+ @Test
+ public void testCall() throws Exception {
+ assertEquals("test", echoService.echo("test"));
+ }
+
+ public static void shutdownRemote() {
+ remoteContainer.stop();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/helpers/ZookeeperDiscoveryConfigurer.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/helpers/ZookeeperDiscoveryConfigurer.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/helpers/ZookeeperDiscoveryConfigurer.java
deleted file mode 100644
index 33f7d8b..0000000
--- a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/helpers/ZookeeperDiscoveryConfigurer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.aries.rsa.itests.felix.helpers;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class ZookeeperDiscoveryConfigurer implements BundleActivator {
-
- @Override
- public void start(BundleContext context) throws Exception {
- ServiceTracker<ConfigurationAdmin, Object> tracker = new ServiceTracker<>(context, ConfigurationAdmin.class, null);
- tracker.open();
- ConfigurationAdmin configAdmin = (ConfigurationAdmin)tracker.getService();
- Dictionary<String, Object> cliProps = new Hashtable<String, Object>();
- cliProps.put("zookeeper.host", "127.0.0.1");
- cliProps.put("zookeeper.port", "" + context.getProperty("zkPort"));
- configAdmin.getConfiguration("org.apache.aries.rsa.discovery.zookeeper", null).update(cliProps);
- tracker.close();
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/helpers/ZookeeperServerConfigurer.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/helpers/ZookeeperServerConfigurer.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/helpers/ZookeeperServerConfigurer.java
deleted file mode 100644
index 3d4e90c..0000000
--- a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/helpers/ZookeeperServerConfigurer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.aries.rsa.itests.felix.helpers;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class ZookeeperServerConfigurer implements BundleActivator {
-
- @Override
- public void start(BundleContext context) throws Exception {
- ServiceTracker<ConfigurationAdmin, Object> tracker = new ServiceTracker<>(context, ConfigurationAdmin.class, null);
- tracker.open();
- ConfigurationAdmin configAdmin = (ConfigurationAdmin)tracker.getService();
- String zkPort = context.getProperty("zkPort");
- Dictionary<String, Object> svrProps = new Hashtable<String, Object>();
- svrProps.put("clientPort", zkPort);
- configAdmin.getConfiguration("org.apache.aries.rsa.discovery.zookeeper.server", null).update(svrProps);
- Dictionary<String, Object> cliProps = new Hashtable<String, Object>();
- cliProps.put("zookeeper.host", "127.0.0.1");
- cliProps.put("zookeeper.port", "" + zkPort);
- configAdmin.getConfiguration("org.apache.aries.rsa.discovery.zookeeper", null).update(cliProps);
- tracker.close();
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java
new file mode 100644
index 0000000..f8a8271
--- /dev/null
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java
@@ -0,0 +1,118 @@
+package org.apache.aries.rsa.itests.felix.tcp;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import java.io.ByteArrayInputStream;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
+import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
+import org.apache.aries.rsa.examples.echotcp.api.EchoService;
+import org.apache.aries.rsa.itests.felix.RsaTestBase;
+import org.apache.aries.rsa.spi.DistributionProvider;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.data.Stat;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
+
+@RunWith(PaxExam.class)
+public class TestDiscoveryExport extends RsaTestBase {
+ private static final String GREETER_ZOOKEEPER_NODE = "/osgi/service_registry/org/apache/aries/rsa/examples/echotcp/api/EchoService";
+
+ @Inject
+ DistributionProvider tcpProvider;
+
+ @Configuration
+ public static Option[] configure() throws Exception {
+ return new Option[] {
+ rsaCoreZookeeper(),
+ rsaTcp(),
+ echoTcpService(),
+ localRepo(),
+ configZKConsumer(),
+ configZKServer()
+ };
+ }
+
+ @Test
+ public void testDiscoveryExport() throws Exception {
+ EndpointDescription epd = getEndpoint();
+ EchoService service = (EchoService)tcpProvider
+ .importEndpoint(EchoService.class.getClassLoader(),
+ bundleContext, new Class[]{EchoService.class}, epd);
+ Assert.assertEquals("test", service.echo("test"));
+ }
+
+ private EndpointDescription getEndpoint() throws Exception {
+ ZooKeeper zk = new ZooKeeper("localhost:" + ZK_PORT, 1000, new DummyWatcher());
+ assertNodeExists(zk, GREETER_ZOOKEEPER_NODE, 10000);
+ String endpointPath = getEndpointPath(zk, GREETER_ZOOKEEPER_NODE);
+ EndpointDescription epd = getEndpointDescription(zk, endpointPath);
+ zk.close();
+ return epd;
+ }
+
+ private EndpointDescription getEndpointDescription(ZooKeeper zk, String endpointPath)
+ throws KeeperException, InterruptedException {
+ byte[] data = zk.getData(endpointPath, false, null);
+ ByteArrayInputStream is = new ByteArrayInputStream(data);
+ List<EndpointDescriptionType> epdList = new EndpointDescriptionParser().getEndpointDescriptions(is);
+ Map<String, Object> props = new PropertiesMapper().toProps(epdList.get(0).getProperty());
+ return new EndpointDescription(props);
+ }
+
+ private String getEndpointPath(ZooKeeper zk, String servicePath) throws KeeperException, InterruptedException {
+ List<String> children = zk.getChildren(servicePath, false);
+ return servicePath + "/" + children.iterator().next();
+ }
+
+ private void assertNodeExists(ZooKeeper zk, String zNode, int timeout) {
+ long endTime = System.currentTimeMillis() + timeout;
+ Stat stat = null;
+ while (stat == null && System.currentTimeMillis() < endTime) {
+ try {
+ stat = zk.exists(zNode, null);
+ Thread.sleep(200);
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ Assert.assertNotNull("ZooKeeper node " + zNode + " was not found", stat);
+ }
+
+ private final class DummyWatcher implements Watcher {
+ @Override
+ public void process(WatchedEvent event) {
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestRoundTrip.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestRoundTrip.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestRoundTrip.java
new file mode 100644
index 0000000..70ca44e
--- /dev/null
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestRoundTrip.java
@@ -0,0 +1,84 @@
+package org.apache.aries.rsa.itests.felix.tcp;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+
+import org.apache.aries.rsa.examples.echotcp.api.EchoService;
+import org.apache.aries.rsa.itests.felix.RsaTestBase;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.ExamSystem;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.TestContainer;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.PaxExamRuntime;
+
+@RunWith(PaxExam.class)
+public class TestRoundTrip extends RsaTestBase {
+
+ private static TestContainer remoteContainer;
+
+ @Inject
+ EchoService echoService;
+
+ public static void startRemote() throws IOException, InterruptedException {
+ ExamSystem testSystem = PaxExamRuntime.createTestSystem(remoteConfig());
+ remoteContainer = PaxExamRuntime.createContainer(testSystem);
+ remoteContainer.start();
+ }
+
+ private static Option[] remoteConfig() throws IOException {
+ return new Option[] {
+ rsaCoreZookeeper(),
+ rsaTcp(),
+ echoTcpService(),
+ configZKServer(),
+ configZKConsumer(),
+ };
+ }
+
+ @Configuration
+ public static Option[] configure() throws Exception {
+ startRemote();
+ return new Option[] {
+ rsaCoreZookeeper(),
+ rsaTcp(),
+ RsaTestBase.echoTcpConsumer(),
+ configZKConsumer()
+ };
+ }
+
+ @Test
+ public void testCall() throws Exception {
+ assertEquals("test", echoService.echo("test"));
+ }
+
+ public static void shutdownRemote() {
+ remoteContainer.stop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/495a0e93/itests/pom.xml
----------------------------------------------------------------------
diff --git a/itests/pom.xml b/itests/pom.xml
index 59ba1e9..8899cb8 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -48,6 +48,11 @@
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-cm</artifactId>
+ <version>${pax-exam.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-inject</artifactId>
<version>${pax-exam.version}</version>
</dependency>