aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject aries-rsa git commit: Add service call to test
Date Sun, 13 Mar 2016 10:14:30 GMT
Repository: aries-rsa
Updated Branches:
  refs/heads/master 96a747fba -> d0e395eb8


Add service call to test


Project: http://git-wip-us.apache.org/repos/asf/aries-rsa/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-rsa/commit/d0e395eb
Tree: http://git-wip-us.apache.org/repos/asf/aries-rsa/tree/d0e395eb
Diff: http://git-wip-us.apache.org/repos/asf/aries-rsa/diff/d0e395eb

Branch: refs/heads/master
Commit: d0e395eb8a1dae8ad35820e7ad70ede11e52e856
Parents: 96a747f
Author: Christian Schneider <chris@die-schneider.net>
Authored: Sun Mar 13 11:14:23 2016 +0100
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Sun Mar 13 11:14:23 2016 +0100

----------------------------------------------------------------------
 .../rsa/itests/felix/TestDiscoveryExport.java   | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d0e395eb/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
index 5d00bc4..12f8402 100644
--- 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
@@ -22,14 +22,22 @@ package org.apache.aries.rsa.itests.felix;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.util.Dictionary;
 import java.util.Hashtable;
+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.itests.tcp.api.EchoService;
+import org.apache.aries.rsa.provider.tcp.TCPProvider;
+import org.apache.aries.rsa.spi.DistributionProvider;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
@@ -44,6 +52,8 @@ import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
 
 @RunWith(PaxExam.class)
 public class TestDiscoveryExport {
@@ -61,6 +71,9 @@ public class TestDiscoveryExport {
 
     @Inject
     ConfigurationAdmin configAdmin;
+    
+    @Inject
+    DistributionProvider tcpProvider;
 
     @Configuration
     public static Option[] configure() throws Exception {
@@ -98,6 +111,16 @@ public class TestDiscoveryExport {
         updateZkClientConfig(zkPort, configAdmin);
         ZooKeeper zk = new ZooKeeper("localhost:" + zkPort, 1000, new DummyWatcher());
         assertNodeExists(zk, GREETER_ZOOKEEPER_NODE, 10000);
+        List<String> children = zk.getChildren(GREETER_ZOOKEEPER_NODE, false);
+        EndpointDescriptionParser parser = new EndpointDescriptionParser();
+        String path = children.get(0);
+        byte[] data = zk.getData(GREETER_ZOOKEEPER_NODE + "/" + path, false, null);
+        List<EndpointDescriptionType> epdList = parser.getEndpointDescriptions(new
ByteArrayInputStream(data));
+        Map<String, Object> props = new PropertiesMapper().toProps(epdList.get(0).getProperty());
+        EndpointDescription epd = new EndpointDescription(props);
+        EchoService service = (EchoService)tcpProvider.importEndpoint(EchoService.class.getClassLoader(),
bundleContext, new Class[]{EchoService.class}, epd);
+        String answer = service.echo("test");
+        Assert.assertEquals("test", answer);
         zk.close();
     }
 


Mime
View raw message