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/03/14 17:49:36 UTC

[2/5] aries-rsa git commit: Adding roundtrip test

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImplTest.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImplTest.java b/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImplTest.java
deleted file mode 100644
index 53b6139..0000000
--- a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImplTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.dosgi.discovery.zookeeper;
-
-import junit.framework.TestCase;
-
-public class InterfaceDataMonitorListenerImplTest extends TestCase {
-
-    public void testDUMMY() {
-        assertTrue(true);
-    }
-
-//    public void testChange() throws Exception {
-//        final List<DiscoveredServiceNotification> dsnCallbacks = new ArrayList<DiscoveredServiceNotification>();
-//        DiscoveredServiceTracker dst = new DiscoveredServiceTracker() {
-//            public void serviceChanged(DiscoveredServiceNotification dsn) {
-//                dsnCallbacks.add(dsn);
-//            }
-//        };
-//
-//        //----------------------------------------------------------------
-//        // Test DiscoveredServiceNotification.AVAILABLE
-//        //----------------------------------------------------------------
-//        Properties initial = new Properties();
-//        initial.put("a", "b");
-//        initial.put(ServicePublication.ENDPOINT_LOCATION, "http://somehost:12345/some/context");
-//        ByteArrayOutputStream propBytes = new ByteArrayOutputStream();
-//        initial.store(propBytes, "");
-//
-//        ZooKeeper zk = EasyMock.createMock(ZooKeeper.class);
-//        EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false))
-//            .andReturn(Arrays.asList("x#y#z"));
-//        EasyMock.expect(zk.getData(Utils.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null))
-//            .andReturn(propBytes.toByteArray());
-//        EasyMock.replay(zk);
-//
-//        InterfaceDataMonitorListenerImpl dml = new InterfaceDataMonitorListenerImpl(zk, String.class.getName(), dst);
-//
-//        assertEquals("Precondition failed", 0, dsnCallbacks.size());
-//        dml.change();
-//        assertEquals(1, dsnCallbacks.size());
-//        DiscoveredServiceNotification dsn = dsnCallbacks.iterator().next();
-//        assertEquals(Collections.singleton(String.class.getName()), dsn.getInterfaces());
-//        assertEquals(DiscoveredServiceNotification.AVAILABLE, dsn.getType());
-//        assertEquals(0, dsn.getFilters().size());
-//        ServiceEndpointDescription sed = dsn.getServiceEndpointDescription();
-//        assertEquals(Collections.singleton(String.class.getName()), sed.getProvidedInterfaces());
-//
-//        Properties expected = new Properties();
-//        expected.load(new ByteArrayInputStream(propBytes.toByteArray()));
-//        expected.put("service.exported.configs", "org.apache.cxf.ws");
-//        expected.put("org.apache.cxf.ws.address", "http://somehost:12345/some/context");
-//
-//        assertEquals(expected, sed.getProperties());
-//        EasyMock.verify(zk);
-//
-//        // Again with the same data
-//        EasyMock.reset(zk);
-//        EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false))
-//            .andReturn(Arrays.asList("x#y#z"));
-//        EasyMock.expect(zk.getData(Utils.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null))
-//            .andReturn(propBytes.toByteArray());
-//        EasyMock.replay(zk);
-//
-//        dsnCallbacks.clear();
-//        assertEquals("Precondition failed", 0, dsnCallbacks.size());
-//        dml.change();
-//        assertEquals(0, dsnCallbacks.size());
-//
-//        EasyMock.verify(zk);
-//        //----------------------------------------------------------------
-//        // Test DiscoveredServiceNotification.MODIFIED
-//        //----------------------------------------------------------------
-//        Properties modified = new Properties();
-//        modified.put("c", "d");
-//        modified.put(ServicePublication.ENDPOINT_LOCATION, "http://somehost:999/some/context");
-//        modified.put("service.exported.configs", "org.apache.cxf.rs");
-//        ByteArrayOutputStream modBytes = new ByteArrayOutputStream();
-//        modified.store(modBytes, "");
-//
-//        EasyMock.reset(zk);
-//        EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false))
-//            .andReturn(Arrays.asList("x#y#z"));
-//        EasyMock.expect(zk.getData(Utils.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null))
-//            .andReturn(modBytes.toByteArray());
-//        EasyMock.replay(zk);
-//
-//        dsnCallbacks.clear();
-//        assertEquals("Precondition failed", 0, dsnCallbacks.size());
-//        dml.change();
-//        assertEquals(1, dsnCallbacks.size());
-//        DiscoveredServiceNotification dsn2 = dsnCallbacks.iterator().next();
-//        assertEquals(Collections.singleton(String.class.getName()), dsn2.getInterfaces());
-//        assertEquals(DiscoveredServiceNotification.MODIFIED, dsn2.getType());
-//        assertEquals(0, dsn2.getFilters().size());
-//        ServiceEndpointDescription sed2 = dsn2.getServiceEndpointDescription();
-//        assertEquals(Collections.singleton(String.class.getName()), sed2.getProvidedInterfaces());
-//        assertEquals(modified, sed2.getProperties());
-//
-//        EasyMock.verify(zk);
-//
-//        //----------------------------------------------------------------
-//        // Test DiscoveredServiceNotification.MODIFIED2
-//        //----------------------------------------------------------------
-//        Properties modified2 = new Properties();
-//        modified2.put("c", "d2");
-//        modified2.put(ServicePublication.ENDPOINT_LOCATION, "http://somehost:112/some/context");
-//        modified2.put("service.exported.configs", "org.apache.cxf.ws");
-//        modified2.put("org.apache.cxf.ws.address", "http://somewhereelse/123");
-//        ByteArrayOutputStream modBytes2 = new ByteArrayOutputStream();
-//        modified2.store(modBytes2, "");
-//
-//        EasyMock.reset(zk);
-//        EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false))
-//            .andReturn(Arrays.asList("x#y#z"));
-//        EasyMock.expect(zk.getData(Utils.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null))
-//            .andReturn(modBytes2.toByteArray());
-//        EasyMock.replay(zk);
-//
-//        dsnCallbacks.clear();
-//        assertEquals("Precondition failed", 0, dsnCallbacks.size());
-//        dml.change();
-//        assertEquals(1, dsnCallbacks.size());
-//        DiscoveredServiceNotification dsn3 = dsnCallbacks.iterator().next();
-//        assertEquals(Collections.singleton(String.class.getName()), dsn3.getInterfaces());
-//        assertEquals(DiscoveredServiceNotification.MODIFIED, dsn3.getType());
-//        assertEquals(0, dsn3.getFilters().size());
-//        ServiceEndpointDescription sed3 = dsn3.getServiceEndpointDescription();
-//        assertEquals(Collections.singleton(String.class.getName()), sed3.getProvidedInterfaces());
-//        assertEquals(modified2, sed3.getProperties());
-//
-//        EasyMock.verify(zk);
-//        //----------------------------------------------------------------
-//        // Test DiscoveredServiceNotification.UNAVAILABLE
-//        //----------------------------------------------------------------
-//        EasyMock.reset(zk);
-//        EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false))
-//            .andReturn(Collections.<String>emptyList());
-//        EasyMock.replay(zk);
-//
-//        dsnCallbacks.clear();
-//        assertEquals("Precondition failed", 0, dsnCallbacks.size());
-//        dml.change();
-//        assertEquals(1, dsnCallbacks.size());
-//        DiscoveredServiceNotification dsn4 = dsnCallbacks.iterator().next();
-//        assertEquals(Collections.singleton(String.class.getName()), dsn4.getInterfaces());
-//        assertEquals(DiscoveredServiceNotification.UNAVAILABLE, dsn4.getType());
-//        assertEquals(0, dsn4.getFilters().size());
-//        ServiceEndpointDescription sed4 = dsn4.getServiceEndpointDescription();
-//        assertEquals(Collections.singleton(String.class.getName()), sed4.getProvidedInterfaces());
-//        assertEquals(modified2, sed4.getProperties());
-//
-//        EasyMock.verify(zk);
-//
-//        // Try the same again...
-//        EasyMock.reset(zk);
-//        EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false))
-//            .andReturn(Collections.<String>emptyList());
-//        EasyMock.replay(zk);
-//
-//        dsnCallbacks.clear();
-//        assertEquals("Precondition failed", 0, dsnCallbacks.size());
-//        dml.change();
-//        assertEquals("Should not receive a callback again...", 0, dsnCallbacks.size());
-//        EasyMock.verify(zk);
-//    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/ZookeeperDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/ZookeeperDiscoveryTest.java b/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/ZookeeperDiscoveryTest.java
deleted file mode 100644
index ed38d5d..0000000
--- a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/ZookeeperDiscoveryTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.cxf.dosgi.discovery.zookeeper;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.zookeeper.ZooKeeper;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-import org.junit.Assert;
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationException;
-
-
-public class ZookeeperDiscoveryTest {
-
-    @Test
-    public void testDefaults() throws ConfigurationException {
-        IMocksControl c = EasyMock.createControl();
-        BundleContext bctx = c.createMock(BundleContext.class);
-        ZooKeeperDiscovery zkd = new ZooKeeperDiscovery(bctx) {
-            @Override
-            protected ZooKeeper createZooKeeper(String host, String port, int timeout) {
-                Assert.assertEquals("localhost", host);
-                Assert.assertEquals("2181", port);
-                Assert.assertEquals(3000, timeout);
-                return null;
-            }  
-        };
-        
-        Dictionary<String, Object> configuration = new Hashtable<String, Object>();
-        zkd.updated(configuration);
-    }
-    
-    @Test
-    public void testConfig() throws ConfigurationException {
-        IMocksControl c = EasyMock.createControl();
-        BundleContext bctx = c.createMock(BundleContext.class);
-        ZooKeeperDiscovery zkd = new ZooKeeperDiscovery(bctx) {
-            @Override
-            protected ZooKeeper createZooKeeper(String host, String port, int timeout) {
-                Assert.assertEquals("myhost", host);
-                Assert.assertEquals("1", port);
-                Assert.assertEquals(1000, timeout);
-                return null;
-            }  
-        };
-        
-        Dictionary<String, Object> configuration = new Hashtable<String, Object>();
-        configuration.put("zookeeper.host", "myhost");
-        configuration.put("zookeeper.port", "1");
-        configuration.put("zookeeper.timeout", "1000");
-        zkd.updated(configuration);
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java b/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java
deleted file mode 100644
index a8498fd..0000000
--- a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.dosgi.discovery.zookeeper.publish;
-
-import java.util.Dictionary;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.zookeeper.ZooKeeper;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
-
-public class PublishingEndpointListenerFactoryTest extends TestCase {
-
-    @SuppressWarnings("unchecked")
-    public void testScope() {
-        IMocksControl c = EasyMock.createNiceControl();
-
-        BundleContext ctx = c.createMock(BundleContext.class);
-        ZooKeeper zk = c.createMock(ZooKeeper.class);
-        @SuppressWarnings("rawtypes")
-        ServiceRegistration sreg = c.createMock(ServiceRegistration.class);
-
-        PublishingEndpointListenerFactory eplf = new PublishingEndpointListenerFactory(zk, ctx);
-
-        EasyMock.expect(ctx.registerService(EasyMock.eq(EndpointListener.class.getName()), EasyMock.eq(eplf),
-                                            (Dictionary<String, String>)EasyMock.anyObject())).andReturn(sreg).once();
-
-        EasyMock.expect(ctx.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn("myUUID").anyTimes();
-
-        c.replay();
-        eplf.start();
-        c.verify();
-
-    }
-
-    @SuppressWarnings("unchecked")
-    public void testServiceFactory() {
-        IMocksControl c = EasyMock.createNiceControl();
-
-        BundleContext ctx = c.createMock(BundleContext.class);
-        ZooKeeper zk = c.createMock(ZooKeeper.class);
-        @SuppressWarnings("rawtypes")
-        ServiceRegistration sreg = c.createMock(ServiceRegistration.class);
-
-        PublishingEndpointListenerFactory eplf = new PublishingEndpointListenerFactory(zk, ctx);
-
-        EasyMock.expect(ctx.registerService(EasyMock.eq(EndpointListener.class.getName()), EasyMock.eq(eplf),
-                                (Dictionary<String, String>)EasyMock.anyObject())).andReturn(sreg).once();
-
-        EasyMock.expect(ctx.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn("myUUID").anyTimes();
-
-        PublishingEndpointListener eli = c.createMock(PublishingEndpointListener.class);
-        eli.close();
-        EasyMock.expectLastCall().once();
-
-        c.replay();
-        eplf.start();
-
-        PublishingEndpointListener service = eplf.getService(null, null);
-        assertNotNull(service);
-        assertTrue(service instanceof EndpointListener);
-
-        List<PublishingEndpointListener> listeners = eplf.getListeners();
-        assertEquals(1, listeners.size());
-        assertEquals(service, listeners.get(0));
-
-        eplf.ungetService(null, null, service);
-        listeners = eplf.getListeners();
-        assertEquals(0, listeners.size());
-
-        eplf.ungetService(null, null, eli); // no call to close
-        listeners.add(eli);
-        eplf.ungetService(null, null, eli); // call to close
-        listeners = eplf.getListeners();
-        assertEquals(0, listeners.size());
-
-        c.verify();
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java b/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
deleted file mode 100644
index 0c78d4a..0000000
--- a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.dosgi.discovery.zookeeper.publish;
-
-import static org.easymock.EasyMock.expect;
-
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
-import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooKeeper;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.easymock.IMocksControl;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
-import org.osgi.xmlns.rsa.v1_0.PropertyType;
-
-import junit.framework.TestCase;
-
-public class PublishingEndpointListenerTest extends TestCase {
-
-    private static final String ENDPOINT_PATH = "/osgi/service_registry/myClass/google.de#80##test#sub";
-
-    public void testEndpointRemovalAdding() throws KeeperException, InterruptedException {
-        IMocksControl c = EasyMock.createNiceControl();
-
-        BundleContext ctx = c.createMock(BundleContext.class);
-        ZooKeeper zk = c.createMock(ZooKeeper.class);
-
-        String path = ENDPOINT_PATH;
-        expectCreated(zk, path);
-        expectDeleted(zk, path);
-
-        c.replay();
-
-        PublishingEndpointListener eli = new PublishingEndpointListener(zk, ctx);
-        EndpointDescription endpoint = createEndpoint();
-        eli.endpointAdded(endpoint, null);
-        eli.endpointAdded(endpoint, null); // should do nothing
-        eli.endpointRemoved(endpoint, null);
-        eli.endpointRemoved(endpoint, null); // should do nothing
-
-        c.verify();
-    }
-
-    public void testDiscoveryPlugin() throws Exception {
-        BundleContext ctx = EasyMock.createMock(BundleContext.class);
-        stubCreateFilter(ctx);
-        ctx.addServiceListener(EasyMock.isA(ServiceListener.class),
-                EasyMock.eq("(objectClass=" + DiscoveryPlugin.class.getName() + ")"));
-
-        ServiceReference<DiscoveryPlugin> sr1 = createAppendPlugin(ctx);
-        ServiceReference<DiscoveryPlugin> sr2 = createPropertyPlugin(ctx);
-
-        EasyMock.expect(ctx.getServiceReferences(DiscoveryPlugin.class.getName(), null))
-                .andReturn(new ServiceReference[]{sr1, sr2}).anyTimes();
-        EasyMock.replay(ctx);
-
-        EndpointDescription endpoint = createEndpoint();
-
-        Map<String, Object> expectedProps = new HashMap<String, Object>(endpoint.getProperties());
-        expectedProps.put("endpoint.id", "http://google.de:80/test/sub/appended");
-        expectedProps.put("foo", "bar");
-        expectedProps.put("service.imported", "true");
-
-        final ZooKeeper zk = EasyMock.createNiceMock(ZooKeeper.class);
-        String expectedFullPath = "/osgi/service_registry/org/foo/myClass/some.machine#9876##test";
-        
-        List<PropertyType> props2 = new PropertiesMapper().fromProps(expectedProps);
-        EndpointDescriptionType epd = new EndpointDescriptionType();
-        epd.getProperty().addAll(props2);
-        byte[] data = new EndpointDescriptionParser().getData(epd);
-        expectCreated(zk, expectedFullPath, EasyMock.aryEq(data));
-        EasyMock.replay(zk);
-
-        PublishingEndpointListener eli = new PublishingEndpointListener(zk, ctx);
-
-        List<EndpointDescription> endpoints = getEndpoints(eli);
-        assertEquals("Precondition", 0, endpoints.size());
-        eli.endpointAdded(endpoint, null);
-        assertEquals(1, endpoints.size());
-
-        //TODO enable
-        //EasyMock.verify(zk);
-    }
-
-
-
-    public void testClose() throws KeeperException, InterruptedException {
-        IMocksControl c = EasyMock.createNiceControl();
-        BundleContext ctx = c.createMock(BundleContext.class);
-        ZooKeeper zk = c.createMock(ZooKeeper.class);
-        expectCreated(zk, ENDPOINT_PATH);
-        expectDeleted(zk, ENDPOINT_PATH);
-
-        c.replay();
-
-        PublishingEndpointListener eli = new PublishingEndpointListener(zk, ctx);
-        EndpointDescription endpoint = createEndpoint();
-        eli.endpointAdded(endpoint, null);
-        eli.close(); // should result in zk.delete(...)
-
-        c.verify();
-    }
-
-    @SuppressWarnings("unchecked")
-    private ServiceReference<DiscoveryPlugin> createAppendPlugin(BundleContext ctx) {
-        DiscoveryPlugin plugin1 = new DiscoveryPlugin() {
-            public String process(Map<String, Object> mutableProperties, String endpointKey) {
-                String eid = (String) mutableProperties.get("endpoint.id");
-                mutableProperties.put("endpoint.id", eid + "/appended");
-                return endpointKey;
-            }
-        };
-        ServiceReference<DiscoveryPlugin> sr1 = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(ctx.getService(sr1)).andReturn(plugin1).anyTimes();
-        return sr1;
-    }
-
-    @SuppressWarnings("unchecked")
-    private ServiceReference<DiscoveryPlugin> createPropertyPlugin(BundleContext ctx) {
-        DiscoveryPlugin plugin2 = new DiscoveryPlugin() {
-            public String process(Map<String, Object> mutableProperties, String endpointKey) {
-                mutableProperties.put("foo", "bar");
-                return endpointKey.replaceAll("localhost", "some.machine");
-            }
-        };
-        ServiceReference<DiscoveryPlugin> sr2 = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(ctx.getService(sr2)).andReturn(plugin2).anyTimes();
-        return sr2;
-    }
-
-    @SuppressWarnings("unchecked")
-    private List<EndpointDescription> getEndpoints(PublishingEndpointListener eli) throws Exception {
-        Field field = eli.getClass().getDeclaredField("endpoints");
-        field.setAccessible(true);
-        return (List<EndpointDescription>) field.get(eli);
-    }
-
-    private void stubCreateFilter(BundleContext ctx) throws InvalidSyntaxException {
-        EasyMock.expect(ctx.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-    }
-
-    private void expectCreated(ZooKeeper zk, String path, byte[] dataMatcher) throws KeeperException, InterruptedException {
-        expect(zk.create(EasyMock.eq(path), 
-                         dataMatcher, 
-                         EasyMock.eq(Ids.OPEN_ACL_UNSAFE),
-                         EasyMock.eq(CreateMode.EPHEMERAL)))
-            .andReturn("");
-    }
-    
-    private void expectCreated(ZooKeeper zk, String path) throws KeeperException, InterruptedException {
-        expect(zk.create(EasyMock.eq(path), 
-                         (byte[])EasyMock.anyObject(), 
-                         EasyMock.eq(Ids.OPEN_ACL_UNSAFE),
-                         EasyMock.eq(CreateMode.EPHEMERAL)))
-            .andReturn("");
-    }
-
-    private void expectDeleted(ZooKeeper zk, String path) throws InterruptedException, KeeperException {
-        zk.delete(EasyMock.eq(path), EasyMock.eq(-1));
-        EasyMock.expectLastCall().once();
-    }
-
-    private EndpointDescription createEndpoint() {
-        Map<String, Object> props = new HashMap<String, Object>();
-        props.put(Constants.OBJECTCLASS, new String[] {"myClass"});
-        props.put(RemoteConstants.ENDPOINT_ID, "http://google.de:80/test/sub");
-        props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myConfig");
-        return new EndpointDescription(props);
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java b/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
deleted file mode 100644
index 01aea63..0000000
--- a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.dosgi.discovery.zookeeper.subscribe;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.zookeeper.ZooKeeper;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.easymock.IMocksControl;
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
-
-public class InterfaceMonitorManagerTest {
-
-    @Test
-    public void testEndpointListenerTrackerCustomizer() {
-        IMocksControl c = EasyMock.createNiceControl();
-        BundleContext ctx = c.createMock(BundleContext.class);
-        ServiceReference<EndpointListener> sref = createService(c);
-        ServiceReference<EndpointListener> sref2 = createService(c);
-        ZooKeeper zk = c.createMock(ZooKeeper.class);
-        InterfaceMonitorManager eltc = new InterfaceMonitorManager(ctx, zk);
-
-        c.replay();
-
-        // sref has no scope -> nothing should happen
-        assertEquals(0, eltc.getEndpointListenerScopes().size());
-        assertEquals(0, eltc.getInterests().size());
-
-        eltc.addInterest(sref, "(objectClass=mine)", "mine");
-        assertScopeIncludes(sref, eltc);
-        assertEquals(1, eltc.getEndpointListenerScopes().size());
-        assertEquals(1, eltc.getInterests().size());
-
-        eltc.addInterest(sref, "(objectClass=mine)", "mine");
-        assertScopeIncludes(sref, eltc);
-        assertEquals(1, eltc.getEndpointListenerScopes().size());
-        assertEquals(1, eltc.getInterests().size());
-
-        eltc.addInterest(sref2, "(objectClass=mine)", "mine");
-        assertScopeIncludes(sref, eltc);
-        assertScopeIncludes(sref2, eltc);
-        assertEquals(2, eltc.getEndpointListenerScopes().size());
-        assertEquals(1, eltc.getInterests().size());
-
-        eltc.removeInterest(sref);
-        assertScopeIncludes(sref2, eltc);
-        assertEquals(1, eltc.getEndpointListenerScopes().size());
-        assertEquals(1, eltc.getInterests().size());
-
-        eltc.removeInterest(sref);
-        assertScopeIncludes(sref2, eltc);
-        assertEquals(1, eltc.getEndpointListenerScopes().size());
-        assertEquals(1, eltc.getInterests().size());
-
-        eltc.removeInterest(sref2);
-        assertEquals(0, eltc.getEndpointListenerScopes().size());
-        assertEquals(0, eltc.getInterests().size());
-
-        c.verify();
-    }
-
-    @SuppressWarnings("unchecked")
-    private ServiceReference<EndpointListener> createService(IMocksControl c) {
-        final Map<String, ?> p = new HashMap<String, Object>();
-        ServiceReference<EndpointListener> sref = c.createMock(ServiceReference.class);
-        EasyMock.expect(sref.getPropertyKeys()).andAnswer(new IAnswer<String[]>() {
-            public String[] answer() throws Throwable {
-                return p.keySet().toArray(new String[p.size()]);
-            }
-        }).anyTimes();
-
-        EasyMock.expect(sref.getProperty((String)EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                String key = (String)(EasyMock.getCurrentArguments()[0]);
-                return p.get(key);
-            }
-        }).anyTimes();
-        return sref;
-    }
-
-    private void assertScopeIncludes(ServiceReference<EndpointListener> sref, InterfaceMonitorManager eltc) {
-        List<String> srefScope = eltc.getEndpointListenerScopes().get(sref);
-        assertEquals(1, srefScope.size());
-        assertEquals("(objectClass=mine)", srefScope.get(0));
-        
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java b/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java
deleted file mode 100644
index 044b360..0000000
--- a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.dosgi.discovery.zookeeper.subscribe;
-
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
-import org.apache.cxf.dosgi.discovery.zookeeper.util.Utils;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher.Event.EventType;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.Stat;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
-
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-
-public class InterfaceMonitorTest extends TestCase {
-
-    public void testInterfaceMonitor() throws KeeperException, InterruptedException {
-        IMocksControl c = EasyMock.createControl();
-
-        ZooKeeper zk = c.createMock(ZooKeeper.class);
-        expect(zk.getState()).andReturn(ZooKeeper.States.CONNECTED).anyTimes();
-
-        String scope = "(myProp=test)";
-        String interf = "es.schaaf.test";
-        String node = Utils.getZooKeeperPath(interf);
-
-        EndpointListener endpointListener = c.createMock(EndpointListener.class);
-        InterfaceMonitor im = new InterfaceMonitor(zk, interf, endpointListener, scope);
-        zk.exists(eq(node), eq(im), eq(im), EasyMock.anyObject());
-        EasyMock.expectLastCall().once();
-
-        expect(zk.exists(eq(node), eq(false))).andReturn(new Stat()).anyTimes();
-        expect(zk.getChildren(eq(node), eq(false))).andReturn(Collections.<String> emptyList()).once();
-        expect(zk.getChildren(eq(node), eq(im))).andReturn(Collections.<String> emptyList()).once();
-
-        c.replay();
-        im.start();
-        // simulate a zk callback
-        WatchedEvent we = new WatchedEvent(EventType.NodeCreated, KeeperState.SyncConnected, node);
-        im.process(we);
-        c.verify();
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java b/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java
deleted file mode 100644
index 1f72b88..0000000
--- a/discovery/zookeeper/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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.
- */
-package org.apache.cxf.dosgi.discovery.zookeeper.util;
-
-import junit.framework.TestCase;
-
-public class UtilsTest extends TestCase {
-
-    public void testGetZooKeeperPath() {
-        assertEquals(Utils.PATH_PREFIX + '/' + "org/example/Test",
-            Utils.getZooKeeperPath("org.example.Test"));
-
-        // used for the recursive discovery
-        assertEquals(Utils.PATH_PREFIX, Utils.getZooKeeperPath(null));
-        assertEquals(Utils.PATH_PREFIX, Utils.getZooKeeperPath(""));
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/Readme.md
----------------------------------------------------------------------
diff --git a/examples/echotcp/Readme.md b/examples/echotcp/Readme.md
new file mode 100644
index 0000000..c7b0525
--- /dev/null
+++ b/examples/echotcp/Readme.md
@@ -0,0 +1,44 @@
+# Example echo TCP
+
+Implements a simple echo service and exposes it using the Aries RSA TCP provider.
+
+# Install
+
+Download Apache Karaf 4.0.5
+
+## Service
+Extract to container_a and start. In the shell execute the commands below:
+
+config:property-set -p org.apache.aries.rsa.discovery.zookeeper zookeeper.port 2181
+config:property-set -p org.apache.aries.rsa.discovery.zookeeper.server clientPort 2181
+feature:repo-add aries-rsa 1.8-SNAPSHOT
+feature:install scr aries-rsa-provider-tcp aries-rsa-discovery-zookeeper
+install -s mvn:org.apache.aries.rsa.examples.echotcp/org.apache.aries.rsa.examples.echotcp.api
+install -s mvn:org.apache.aries.rsa.examples.echotcp/org.apache.aries.rsa.examples.echotcp.service
+
+The log should show that the service is exported using the tcp provider and published to zookeeper.
+It should look similar to this:
+
+2016-03-14 11:59:53,548 | INFO  | pool-50-thread-5 | TopologyManagerExport            | 57 - org.apache.aries.rsa.topology-manager - 1.8.0.SNAPSHOT | TopologyManager: export successful for [org.apache.aries.rsa.examples.echotcp.api.EchoService], endpoints: [{component.id=1, component.name=org.apache.aries.rsa.examples.echotcp.service.EchoServiceImpl, endpoint.framework.uuid=2b242970-0d54-49c4-a321-b0c323809c24, endpoint.id=tcp://192.168.0.129:36384, endpoint.package.version.org.apache.aries.rsa.examples.echotcp.api=1.0.0, endpoint.service.id=138, objectClass=[org.apache.aries.rsa.examples.echotcp.api.EchoService], service.bundleid=64, service.imported=true, service.imported.configs=[aries.tcp], service.scope=bundle}]
+2016-03-14 11:59:53,549 | INFO  | pool-50-thread-5 | PublishingEndpointListener       | 54 - org.apache.aries.rsa.discovery.zookeeper - 1.8.0.SNAPSHOT | Local EndpointDescription added: {component.id=1, component.name=org.apache.aries.rsa.examples.echotcp.service.EchoServiceImpl, endpoint.framework.uuid=2b242970-0d54-49c4-a321-b0c323809c24, endpoint.id=tcp://192.168.0.129:36384, endpoint.package.version.org.apache.aries.rsa.examples.echotcp.api=1.0.0, endpoint.service.id=138, objectClass=[org.apache.aries.rsa.examples.echotcp.api.EchoService], service.bundleid=64, service.imported=true, service.imported.configs=[aries.tcp], service.scope=bundle}
+
+
+## Consumer
+Extract to container_b and start. In the shell execute the commands below:
+
+config:property-set -p org.apache.aries.rsa.discovery.zookeeper zookeeper.port 2181
+feature:repo-add aries-rsa 1.8-SNAPSHOT
+feature:install scr aries-rsa-provider-tcp aries-rsa-discovery-zookeeper
+install -s mvn:org.apache.aries.rsa.examples.echotcp/org.apache.aries.rsa.examples.echotcp.api
+install -s mvn:org.apache.aries.rsa.examples.echotcp/org.apache.aries.rsa.examples.echotcp.consumer
+
+The consumer should start and show:
+Sending to echo service
+Good morning
+
+The log should show that the discovery picks up the endpoint from zookeeper and that the RemoteServiceAdmin imports the service.
+
+2016-03-14 12:03:30,518 | INFO  | er])-EventThread | InterfaceMonitor                 | 54 - org.apache.aries.rsa.discovery.zookeeper - 1.8.0.SNAPSHOT | found new node /osgi/service_registry/org/apache/aries/rsa/examples/echotcp/api/EchoService/[192.168.0.129#36384#]   ( []->child )  props: [1, org.apache.aries.rsa.examples.echotcp.service.EchoServiceImpl, 2b242970-0d54-49c4-a321-b0c323809c24, tcp://192.168.0.129:36384, 1.0.0, 138, [Ljava.lang.String;@69a6817f, 64, true, [Ljava.lang.String;@8514b3a, bundle]
+2016-03-14 12:03:30,520 | INFO  | er])-EventThread | InterfaceMonitorManager          | 54 - org.apache.aries.rsa.discovery.zookeeper - 1.8.0.SNAPSHOT | calling EndpointListener.endpointAdded: org.apache.aries.rsa.topologymanager.importer.TopologyManagerImport@2366e9c8 from bundle org.apache.aries.rsa.topology-manager for endpoint: {component.id=1, component.name=org.apache.aries.rsa.examples.echotcp.service.EchoServiceImpl, endpoint.framework.uuid=2b242970-0d54-49c4-a321-b0c323809c24, endpoint.id=tcp://192.168.0.129:36384, endpoint.package.version.org.apache.aries.rsa.examples.echotcp.api=1.0.0, endpoint.service.id=138, objectClass=[org.apache.aries.rsa.examples.echotcp.api.EchoService], service.bundleid=64, service.imported=true, service.imported.configs=[aries.tcp], service.scope=bundle}
+2016-03-14 12:03:30,522 | INFO  | pool-41-thread-1 | RemoteServiceAdminCore           | 52 - org.apache.aries.rsa.core - 1.8.0.SNAPSHOT | Importing service tcp://192.168.0.129:36384 with interfaces [org.apache.aries.rsa.examples.echotcp.api.EchoService] using handler class org.apache.aries.rsa.provider.tcp.TCPProvider.
+

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/api/bnd.bnd
----------------------------------------------------------------------
diff --git a/examples/echotcp/api/bnd.bnd b/examples/echotcp/api/bnd.bnd
new file mode 100644
index 0000000..73d19a4
--- /dev/null
+++ b/examples/echotcp/api/bnd.bnd
@@ -0,0 +1 @@
+Export-Package: org.apache.aries.rsa.examples.echotcp.api
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/api/pom.xml
----------------------------------------------------------------------
diff --git a/examples/echotcp/api/pom.xml b/examples/echotcp/api/pom.xml
new file mode 100644
index 0000000..e24452f
--- /dev/null
+++ b/examples/echotcp/api/pom.xml
@@ -0,0 +1,11 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.aries.rsa.examples</groupId>
+    <artifactId>org.apache.aries.rsa.examples.echotcp</artifactId>
+    <version>1.8-SNAPSHOT</version>
+  </parent>
+  <groupId>org.apache.aries.rsa.examples.echotcp</groupId>
+  <artifactId>org.apache.aries.rsa.examples.echotcp.api</artifactId>
+  <packaging>bundle</packaging>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/api/src/main/java/org/apache/aries/rsa/examples/echotcp/api/EchoService.java
----------------------------------------------------------------------
diff --git a/examples/echotcp/api/src/main/java/org/apache/aries/rsa/examples/echotcp/api/EchoService.java b/examples/echotcp/api/src/main/java/org/apache/aries/rsa/examples/echotcp/api/EchoService.java
new file mode 100644
index 0000000..998c0d7
--- /dev/null
+++ b/examples/echotcp/api/src/main/java/org/apache/aries/rsa/examples/echotcp/api/EchoService.java
@@ -0,0 +1,5 @@
+package org.apache.aries.rsa.examples.echotcp.api;
+
+public interface EchoService {
+    public String echo(String msg);
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/api/src/main/java/org/apache/aries/rsa/examples/echotcp/api/packageinfo
----------------------------------------------------------------------
diff --git a/examples/echotcp/api/src/main/java/org/apache/aries/rsa/examples/echotcp/api/packageinfo b/examples/echotcp/api/src/main/java/org/apache/aries/rsa/examples/echotcp/api/packageinfo
new file mode 100644
index 0000000..c72722a
--- /dev/null
+++ b/examples/echotcp/api/src/main/java/org/apache/aries/rsa/examples/echotcp/api/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.0

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/consumer/bnd.bnd
----------------------------------------------------------------------
diff --git a/examples/echotcp/consumer/bnd.bnd b/examples/echotcp/consumer/bnd.bnd
new file mode 100644
index 0000000..f29f0a2
--- /dev/null
+++ b/examples/echotcp/consumer/bnd.bnd
@@ -0,0 +1 @@
+-dsannotations: *
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/consumer/pom.xml
----------------------------------------------------------------------
diff --git a/examples/echotcp/consumer/pom.xml b/examples/echotcp/consumer/pom.xml
new file mode 100644
index 0000000..a479018
--- /dev/null
+++ b/examples/echotcp/consumer/pom.xml
@@ -0,0 +1,39 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.rsa.examples</groupId>
+        <artifactId>org.apache.aries.rsa.examples.echotcp</artifactId>
+        <version>1.8-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.aries.rsa.examples.echotcp</groupId>
+    <artifactId>org.apache.aries.rsa.examples.echotcp.consumer</artifactId>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.rsa.examples.echotcp</groupId>
+            <artifactId>org.apache.aries.rsa.examples.echotcp.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/consumer/src/main/java/org/apache/aries/rsa/examples/echotcp/consumer/EchoConsumer.java
----------------------------------------------------------------------
diff --git a/examples/echotcp/consumer/src/main/java/org/apache/aries/rsa/examples/echotcp/consumer/EchoConsumer.java b/examples/echotcp/consumer/src/main/java/org/apache/aries/rsa/examples/echotcp/consumer/EchoConsumer.java
new file mode 100644
index 0000000..988901f
--- /dev/null
+++ b/examples/echotcp/consumer/src/main/java/org/apache/aries/rsa/examples/echotcp/consumer/EchoConsumer.java
@@ -0,0 +1,41 @@
+/**
+ * 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.
+ */
+package org.apache.aries.rsa.examples.echotcp.consumer;
+
+import org.apache.aries.rsa.examples.echotcp.api.EchoService;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(immediate=true)
+public class EchoConsumer {
+    
+    EchoService echoService;
+
+    @Activate
+    public void activate() {
+        System.out.println("Sending to echo service");
+        System.out.println(echoService.echo("Good morning"));
+    }
+
+    @Reference
+    public void setEchoService(EchoService echoService) {
+        this.echoService = echoService;
+    }
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/pom.xml
----------------------------------------------------------------------
diff --git a/examples/echotcp/pom.xml b/examples/echotcp/pom.xml
new file mode 100644
index 0000000..f12604b
--- /dev/null
+++ b/examples/echotcp/pom.xml
@@ -0,0 +1,76 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.rsa</groupId>
+        <artifactId>examples</artifactId>
+        <version>1.8-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.aries.rsa.examples</groupId>
+    <artifactId>org.apache.aries.rsa.examples.echotcp</artifactId>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>api</module>
+        <module>service</module>
+        <module>consumer</module>
+    </modules>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>3.0.1</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <obrRepository>NONE</obrRepository>
+                    <instructions>
+                        <Export-Package>!*</Export-Package>
+                        <_include>-bnd.bnd</_include>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.5.1</version>
+                <configuration>
+                    <source>1.7</source>
+                    <target>1.7</target>
+                    <maxmem>256M</maxmem>
+                    <fork>false</fork>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/service/bnd.bnd
----------------------------------------------------------------------
diff --git a/examples/echotcp/service/bnd.bnd b/examples/echotcp/service/bnd.bnd
new file mode 100644
index 0000000..73d19a4
--- /dev/null
+++ b/examples/echotcp/service/bnd.bnd
@@ -0,0 +1 @@
+Export-Package: org.apache.aries.rsa.examples.echotcp.api
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/service/pom.xml
----------------------------------------------------------------------
diff --git a/examples/echotcp/service/pom.xml b/examples/echotcp/service/pom.xml
new file mode 100644
index 0000000..50506ac
--- /dev/null
+++ b/examples/echotcp/service/pom.xml
@@ -0,0 +1,39 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.rsa.examples</groupId>
+        <artifactId>org.apache.aries.rsa.examples.echotcp</artifactId>
+        <version>1.8-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.aries.rsa.examples.echotcp</groupId>
+    <artifactId>org.apache.aries.rsa.examples.echotcp.service</artifactId>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.rsa.examples.echotcp</groupId>
+            <artifactId>org.apache.aries.rsa.examples.echotcp.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/echotcp/service/src/main/java/org/apache/aries/rsa/examples/echotcp/service/EchoServiceImpl.java
----------------------------------------------------------------------
diff --git a/examples/echotcp/service/src/main/java/org/apache/aries/rsa/examples/echotcp/service/EchoServiceImpl.java b/examples/echotcp/service/src/main/java/org/apache/aries/rsa/examples/echotcp/service/EchoServiceImpl.java
new file mode 100644
index 0000000..8b31e03
--- /dev/null
+++ b/examples/echotcp/service/src/main/java/org/apache/aries/rsa/examples/echotcp/service/EchoServiceImpl.java
@@ -0,0 +1,14 @@
+package org.apache.aries.rsa.examples.echotcp.service;
+
+import org.apache.aries.rsa.examples.echotcp.api.EchoService;
+import org.osgi.service.component.annotations.Component;
+
+@Component(property={"service.exported.interfaces=*"})
+public class EchoServiceImpl implements EchoService {
+
+    @Override
+    public String echo(String msg) {
+        return msg;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
new file mode 100644
index 0000000..ba60a97
--- /dev/null
+++ b/examples/pom.xml
@@ -0,0 +1,43 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+      <groupId>org.apache.aries.rsa</groupId>
+      <artifactId>parent</artifactId>
+      <version>1.8-SNAPSHOT</version>
+      <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+    
+    <artifactId>examples</artifactId>
+    <packaging>pom</packaging>
+    
+    <name>Aries Remote Service Admin Examples</name>
+
+    <properties>
+      <topDirectoryLocation>..</topDirectoryLocation>
+    </properties>
+
+    <modules>
+    <module>echotcp</module>
+    </modules>
+</project>

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/features/src/main/resources/features.xml b/features/src/main/resources/features.xml
index d4325fa..efa8ff2 100644
--- a/features/src/main/resources/features.xml
+++ b/features/src/main/resources/features.xml
@@ -24,8 +24,4 @@
         <bundle>mvn:org.apache.aries.rsa.discovery/zookeeper/${project.version}</bundle>
     </feature>
 
-    <feature name="aries-rsa-zookeeper-server" version="${project.version}">
-        <bundle>mvn:org.apache.zookeeper/zookeeper/${zookeeper.version}</bundle>
-        <bundle>mvn:org.apache.aries.rsa.discovery/zookeeper-server/${project.version}</bundle>
-    </feature>
 </features>

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/itests/felix/pom.xml
----------------------------------------------------------------------
diff --git a/itests/felix/pom.xml b/itests/felix/pom.xml
index c76dbe4..bf82d9c 100644
--- a/itests/felix/pom.xml
+++ b/itests/felix/pom.xml
@@ -34,6 +34,12 @@
             <version>1.8.8</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr</artifactId>
+            <version>2.0.0</version>
+        </dependency>
+        
+        <dependency>
             <groupId>org.apache.aries.rsa</groupId>
             <artifactId>core</artifactId>
             <version>${project.version}</version>
@@ -58,21 +64,33 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.aries.rsa.discovery</groupId>
-            <artifactId>zookeeper-server</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.aries.rsa.provider</groupId>
             <artifactId>tcp</artifactId>
             <version>${project.version}</version>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.aries.rsa.itests</groupId>
-            <artifactId>testbundle-tcp-service</artifactId>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.rsa.examples.echotcp</groupId>
+            <artifactId>org.apache.aries.rsa.examples.echotcp.api</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.aries.rsa.examples.echotcp</groupId>
+            <artifactId>org.apache.aries.rsa.examples.echotcp.service</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.rsa.examples.echotcp</groupId>
+            <artifactId>org.apache.aries.rsa.examples.echotcp.consumer</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        
+        
 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
@@ -99,19 +117,18 @@
             <artifactId>pax-exam-link-mvn</artifactId>
             <scope>test</scope>
         </dependency>
-
         <dependency>
             <groupId>org.ops4j.pax.url</groupId>
             <artifactId>pax-url-aether</artifactId>
             <scope>test</scope>
         </dependency>
-
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.framework</artifactId>
             <version>5.0.1</version>
             <scope>test</scope>
         </dependency>
+
         <dependency>
             <groupId>org.apache.zookeeper</groupId>
             <artifactId>zookeeper</artifactId>

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/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
new file mode 100644
index 0000000..90856ff
--- /dev/null
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java
@@ -0,0 +1,120 @@
+package org.apache.aries.rsa.itests.felix;
+
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+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 java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import javax.inject.Inject;
+
+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 {
+
+    @Inject
+    BundleContext bundleContext;
+
+    @Inject
+    ConfigurationAdmin configAdmin;
+
+    static OptionalCompositeOption localRepo() {
+        String localRepo = System.getProperty("maven.repo.local");
+        if (localRepo == null) {
+            localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+        }
+        return when(localRepo != null)
+            .useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo));
+    }
+
+    static MavenArtifactProvisionOption mvn(String groupId, String artifactId) {
+        return mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
+    }
+
+    public void testInstalled() throws Exception {
+        for (Bundle bundle : bundleContext.getBundles()) {
+            System.out.println(bundle.getBundleId() + " " + bundle.getSymbolicName() + " " + bundle.getState()
+                               + " " + bundle.getVersion());
+        }
+    }
+
+    protected int configureZookeeper() throws IOException, InterruptedException {
+        final int zkPort = 12051;
+        // getFreePort(); does not seem to work
+        System.out.println("*** Port for ZooKeeper Server: " + zkPort);
+        updateZkServerConfig(zkPort, configAdmin);
+        Thread.sleep(1000); // To avoid exceptions in zookeeper client
+        updateZkClientConfig(zkPort, configAdmin);
+        return zkPort;
+    }
+
+    protected void updateZkClientConfig(final int zkPort, ConfigurationAdmin cadmin) throws IOException {
+        Dictionary<String, Object> cliProps = new Hashtable<String, Object>();
+        cliProps.put("zookeeper.host", "127.0.0.1");
+        cliProps.put("zookeeper.port", "" + zkPort);
+        cadmin.getConfiguration("org.apache.aries.rsa.discovery.zookeeper", null).update(cliProps);
+    }
+
+    protected void updateZkServerConfig(final int zkPort, ConfigurationAdmin cadmin) throws IOException {
+        Dictionary<String, Object> svrProps = new Hashtable<String, Object>();
+        svrProps.put("clientPort", zkPort);
+        cadmin.getConfiguration("org.apache.aries.rsa.discovery.zookeeper.server", null).update(svrProps);
+    }
+
+    protected int getFreePort() throws IOException {
+        ServerSocket socket = new ServerSocket();
+        try {
+            socket.setReuseAddress(true); // enables quickly reopening socket on same port
+            socket.bind(new InetSocketAddress(0)); // zero finds a free port
+            return socket.getLocalPort();
+        } finally {
+            socket.close();
+        }
+    }
+
+    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() {
+        return composite(junitBundles(), 
+                         localRepo(),
+                         systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+                         systemProperty("zkPort").value("15201"),
+                         mvn("org.apache.felix", "org.apache.felix.configadmin"),
+                         mvn("org.apache.aries.rsa", "core"), mvn("org.apache.aries.rsa", "spi"),
+                         mvn("org.apache.aries.rsa", "topology-manager"),
+                         mvn("org.apache.aries.rsa.provider", "tcp"),
+                         mvn("org.apache.aries.rsa.discovery", "local"),
+                         mvn("org.apache.zookeeper", "zookeeper"),
+                         mvn("org.apache.aries.rsa.discovery", "zookeeper")
+                         //CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+            );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/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 389c88a..dea4929 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
@@ -19,17 +19,10 @@ package org.apache.aries.rsa.itests.felix;
  */
 
 
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
 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 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;
 
@@ -37,7 +30,7 @@ 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.examples.echotcp.api.EchoService;
 import org.apache.aries.rsa.spi.DistributionProvider;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
@@ -50,71 +43,35 @@ import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
 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 {
-
-    private final class DummyWatcher implements Watcher {
-        @Override
-        public void process(WatchedEvent event) {
-        }
-    }
-
-    private static final String GREETER_ZOOKEEPER_NODE = "/osgi/service_registry/org/apache/aries/rsa/itests/tcp/api/EchoService";
-
-    @Inject
-    BundleContext bundleContext;
+public class TestDiscoveryExport extends RsaTestBase {
+    private static final String GREETER_ZOOKEEPER_NODE = "/osgi/service_registry/org/apache/aries/rsa/examples/echotcp/api/EchoService";
 
     @Inject
-    ConfigurationAdmin configAdmin;
-    
-    @Inject
     DistributionProvider tcpProvider;
 
     @Configuration
     public static Option[] configure() throws Exception {
-        String localRepo = System.getProperty("maven.repo.local");
 
-        if (localRepo == null) {
-            localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
-        }
         return new Option[] {
                 CoreOptions.junitBundles(),
                 systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
-                mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.configadmin").versionAsInProject(),
-                mavenBundle().groupId("org.apache.aries.rsa").artifactId("core").versionAsInProject(),
-                mavenBundle().groupId("org.apache.aries.rsa").artifactId("spi").versionAsInProject(),
-                mavenBundle().groupId("org.apache.aries.rsa").artifactId("topology-manager").versionAsInProject(),
-                mavenBundle().groupId("org.apache.aries.rsa.provider").artifactId("tcp").versionAsInProject(),
-                mavenBundle().groupId("org.apache.aries.rsa.discovery").artifactId("local").versionAsInProject(),
-                mavenBundle().groupId("org.apache.zookeeper").artifactId("zookeeper").versionAsInProject(),
-                mavenBundle().groupId("org.apache.aries.rsa.discovery").artifactId("zookeeper").versionAsInProject(),
-                mavenBundle().groupId("org.apache.aries.rsa.discovery").artifactId("zookeeper-server").versionAsInProject(),
-                mavenBundle().groupId("org.apache.aries.rsa.itests").artifactId("testbundle-tcp-service").versionAsInProject(),
-                when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo))
+                RsaTestBase.rsaTcpZookeeper(),
+                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"),
+                localRepo(),
+                streamBundle(configBundleServer())
                 //CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
         };
     }
-    
-    public void testInstalled() throws Exception {
-        for (Bundle bundle : bundleContext.getBundles()) {
-            System.out.println(bundle.getBundleId() + " " + bundle.getSymbolicName() + " " + bundle.getState() + " " + bundle.getVersion());
-        }
-    }
 
     @Test
     public void testDiscoveryExport() throws Exception {
-        final int zkPort = 12051;
-        //getFreePort(); does not seem to work 
-        System.out.println("*** Port for ZooKeeper Server: " + zkPort);
-        updateZkServerConfig(zkPort, configAdmin);
-        Thread.sleep(1000); // To avoid exceptions in clients
-        updateZkClientConfig(zkPort, configAdmin);
+        String zkPort = bundleContext.getProperty("zkPort");
         ZooKeeper zk = new ZooKeeper("localhost:" + zkPort, 1000, new DummyWatcher());
         assertNodeExists(zk, GREETER_ZOOKEEPER_NODE, 10000);
         List<String> children = zk.getChildren(GREETER_ZOOKEEPER_NODE, false);
@@ -143,28 +100,11 @@ public class TestDiscoveryExport {
         }
         Assert.assertNotNull("ZooKeeper node " + zNode + " was not found", stat);
     }
-
-    protected void updateZkClientConfig(final int zkPort, ConfigurationAdmin cadmin) throws IOException {
-        Dictionary<String, Object> cliProps = new Hashtable<String, Object>();
-        cliProps.put("zookeeper.host", "127.0.0.1");
-        cliProps.put("zookeeper.port", "" + zkPort);
-        cadmin.getConfiguration("org.apache.aries.rsa.discovery.zookeeper", null).update(cliProps);
-    }
-
-    protected void updateZkServerConfig(final int zkPort, ConfigurationAdmin cadmin) throws IOException {
-        Dictionary<String, Object> svrProps = new Hashtable<String, Object>();
-        svrProps.put("clientPort", zkPort);
-        cadmin.getConfiguration("org.apache.aries.rsa.discovery.zookeeper.server", null).update(svrProps);
-    }
     
-    protected int getFreePort() throws IOException {
-        ServerSocket socket = new ServerSocket();
-        try {
-            socket.setReuseAddress(true); // enables quickly reopening socket on same port
-            socket.bind(new InetSocketAddress(0)); // zero finds a free port
-            return socket.getLocalPort();
-        } finally {
-            socket.close();
+    private final class DummyWatcher implements Watcher {
+        @Override
+        public void process(WatchedEvent event) {
         }
     }
+
 }

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/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
new file mode 100644
index 0000000..d20c808
--- /dev/null
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/TestRoundTrip.java
@@ -0,0 +1,88 @@
+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 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.Assert;
+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(),
+            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"),
+            streamBundle(RsaTestBase.configBundleServer()),
+            systemProperty("zkPort").value("15201")
+        };
+    }
+
+    @Configuration
+    public static Option[] configure() throws Exception {
+        startRemote();
+        return new Option[] {
+                rsaTcpZookeeper(),
+                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
+                mvn("org.apache.aries.rsa.examples.echotcp", "org.apache.aries.rsa.examples.echotcp.consumer"),
+                streamBundle(RsaTestBase.configBundleConsumer()),
+                
+        };
+    }
+
+    @Test
+    public void testCall() throws Exception {
+        String answer = echoService.echo("test");
+        Assert.assertEquals("test", answer);
+    }
+
+    public static void shutdownRemote() {
+        remoteContainer.stop();
+    }
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/ZookeeperDiscoveryConfigurer.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/ZookeeperDiscoveryConfigurer.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/ZookeeperDiscoveryConfigurer.java
new file mode 100644
index 0000000..e12a988
--- /dev/null
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/ZookeeperDiscoveryConfigurer.java
@@ -0,0 +1,28 @@
+package org.apache.aries.rsa.itests.felix;
+
+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/69bb901e/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/ZookeeperServerConfigurer.java
----------------------------------------------------------------------
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/ZookeeperServerConfigurer.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/ZookeeperServerConfigurer.java
new file mode 100644
index 0000000..e859207
--- /dev/null
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/ZookeeperServerConfigurer.java
@@ -0,0 +1,32 @@
+package org.apache.aries.rsa.itests.felix;
+
+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/69bb901e/itests/pom.xml
----------------------------------------------------------------------
diff --git a/itests/pom.xml b/itests/pom.xml
index cb59984..7a6b227 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -33,7 +33,6 @@
 
     <modules>
         <module>felix</module>
-        <module>testbundle-service-tcp</module>
     </modules>
 
     <dependencyManagement>

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/itests/testbundle-service-tcp/bnd.bnd
----------------------------------------------------------------------
diff --git a/itests/testbundle-service-tcp/bnd.bnd b/itests/testbundle-service-tcp/bnd.bnd
deleted file mode 100644
index b0cfcc1..0000000
--- a/itests/testbundle-service-tcp/bnd.bnd
+++ /dev/null
@@ -1,3 +0,0 @@
-Bundle-Activator: org.apache.aries.rsa.itests.tcp.service.Activator
-Export-Package: org.apache.aries.rsa.itests.tcp.api
-Private-Package: org.apache.aries.rsa.itests.tcp.service
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/itests/testbundle-service-tcp/pom.xml
----------------------------------------------------------------------
diff --git a/itests/testbundle-service-tcp/pom.xml b/itests/testbundle-service-tcp/pom.xml
deleted file mode 100644
index 0fd4d3c..0000000
--- a/itests/testbundle-service-tcp/pom.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' ?>
-<!--
-  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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-      <groupId>org.apache.aries.rsa</groupId>
-      <artifactId>itests</artifactId>
-      <version>1.8-SNAPSHOT</version>
-      <relativePath>../pom.xml</relativePath>
-    </parent>
-
-    <groupId>org.apache.aries.rsa.itests</groupId>
-    <artifactId>testbundle-tcp-service</artifactId>
-    <packaging>bundle</packaging>
-
-    <name>Aries Remote Service Admin itests testbundle service tcp</name>
-
-    <dependencies>
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/69bb901e/itests/testbundle-service-tcp/src/main/java/org/apache/aries/rsa/itests/tcp/api/EchoService.java
----------------------------------------------------------------------
diff --git a/itests/testbundle-service-tcp/src/main/java/org/apache/aries/rsa/itests/tcp/api/EchoService.java b/itests/testbundle-service-tcp/src/main/java/org/apache/aries/rsa/itests/tcp/api/EchoService.java
deleted file mode 100644
index 877917b..0000000
--- a/itests/testbundle-service-tcp/src/main/java/org/apache/aries/rsa/itests/tcp/api/EchoService.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.aries.rsa.itests.tcp.api;
-
-public interface EchoService {
-    public String echo(String msg);
-}