cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject cxf-dosgi git commit: [DOSGI-241] Simplify Tests
Date Fri, 01 Jul 2016 09:21:43 GMT
Repository: cxf-dosgi
Updated Branches:
  refs/heads/master c1b1598d2 -> a9d93602c


[DOSGI-241] Simplify Tests


Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/a9d93602
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/a9d93602
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/a9d93602

Branch: refs/heads/master
Commit: a9d93602c942c558ccd5f773da08e7594d585893
Parents: c1b1598
Author: Christian Schneider <chris@die-schneider.net>
Authored: Fri Jul 1 11:21:37 2016 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Fri Jul 1 11:21:37 2016 +0200

----------------------------------------------------------------------
 .../systests2/common/test1/GreeterDataImpl.java |  39 ------
 .../systests2/common/test1/MyActivator.java     |  45 -------
 .../common/test1/MyServiceTracker.java          |  76 -----------
 .../common/test1/StartServiceTracker.java       |  41 ------
 .../systests2/multi/AbstractDosgiTest.java      |  74 +++++++++--
 .../dosgi/systests2/multi/TestCustomIntent.java |  63 ++++-----
 .../systests2/multi/TestDiscoveryExport.java    |  59 ++-------
 .../systests2/multi/TestExportRestService.java  |  50 +++----
 .../systests2/multi/TestExportService.java      |  25 ++--
 .../systests2/multi/TestImportService.java      | 130 ++++++-------------
 .../multi/importservice/GreeterDataImpl.java    |  39 ++++++
 .../multi/importservice/MyActivator.java        |  45 +++++++
 .../multi/importservice/MyServiceTracker.java   |  76 +++++++++++
 .../multi/importservice/SimpleGreeter.java      |  41 ++++++
 .../importservice/StartServiceTracker.java      |  44 +++++++
 15 files changed, 410 insertions(+), 437 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/GreeterDataImpl.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/GreeterDataImpl.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/GreeterDataImpl.java
deleted file mode 100644
index 31f2988..0000000
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/GreeterDataImpl.java
+++ /dev/null
@@ -1,39 +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.systests2.common.test1;
-
-import org.apache.cxf.dosgi.samples.greeter.GreeterData;
-
-public class GreeterDataImpl implements GreeterData {
-
-    public int getAge() {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    public String getName() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public boolean isException() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java
deleted file mode 100644
index 6740725..0000000
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java
+++ /dev/null
@@ -1,45 +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.systests2.common.test1;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class MyActivator implements BundleActivator {
-
-    private ServiceTracker startTracker;
-    private ServiceTracker tracker;
-
-    public void start(final BundleContext bc) throws Exception {
-        Filter filter = bc.createFilter("(&(objectClass=java.lang.Object)(testName=test1))");
-        tracker = new MyServiceTracker(bc);
-
-        // The start tracker waits until a service from the test class is set before the
-        // 'MyServiceTracker' is activated.
-        startTracker = new StartServiceTracker(bc, filter, tracker);
-        startTracker.open();
-    }
-
-    public void stop(BundleContext bc) throws Exception {
-        startTracker.close();
-        tracker.close();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java
deleted file mode 100644
index 2886ce8..0000000
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java
+++ /dev/null
@@ -1,76 +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.systests2.common.test1;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.apache.cxf.dosgi.samples.greeter.GreeterException;
-import org.apache.cxf.dosgi.samples.greeter.GreeterService;
-import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class MyServiceTracker extends ServiceTracker<GreeterService, GreeterService> {
-
-    private static StringBuffer invocationResult = new StringBuffer();
-
-    public MyServiceTracker(BundleContext context) {
-        super(context, GreeterService.class, null);
-    }
-
-    @Override
-    public GreeterService addingService(ServiceReference<GreeterService> reference) {
-        GreeterService service = super.addingService(reference);
-        System.out.println("[client] Got a GreeterService...");
-        invokeGreeter(service);
-        return service;
-    }
-
-    public static String getResult() {
-        return invocationResult.toString();
-    }
-
-    private void invokeGreeter(GreeterService svc) {
-        try {
-            Map<GreetingPhrase, String> result = svc.greetMe("OSGi");
-            for (Map.Entry<GreetingPhrase, String> e : result.entrySet()) {
-                GreetingPhrase key = e.getKey();
-                invocationResult.append(key.getPhrase());
-                invocationResult.append(e.getValue());
-            }
-            try {
-                svc.greetMe(new GreeterDataImpl());
-            } catch (GreeterException ex) {
-                invocationResult.append(";exception");
-            }
-            Dictionary<String, Object> props = new Hashtable<String, Object>();
-            props.put("result", invocationResult.toString());
-            props.put("testResult", "test1");
-
-            System.out.println("[client] Successfully invoked remote service. Registering test response service...");
-            context.registerService(String.class.getName(), "test1", props);
-        } catch (Exception x) {
-            System.err.println("[client] Error during remote service invocation:");
-            x.printStackTrace(System.err);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java
deleted file mode 100644
index 40319ec..0000000
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java
+++ /dev/null
@@ -1,41 +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.systests2.common.test1;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class StartServiceTracker extends ServiceTracker {
-
-    private ServiceTracker tracker;
-
-    public StartServiceTracker(BundleContext context, Filter filter, ServiceTracker tracker) {
-        super(context, filter, null);
-        this.tracker = tracker;
-    }
-
-    @Override
-    public Object addingService(ServiceReference reference) {
-        System.out.println("Test object available, so starting the service client tracker...");
-        tracker.open();
-        return super.addingService(reference);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
index 98579d2..7fc4c6a 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
@@ -18,6 +18,10 @@
  */
 package org.apache.cxf.dosgi.systests2.multi;
 
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
 
 import java.io.IOException;
@@ -33,7 +37,12 @@ import java.util.concurrent.TimeoutException;
 
 import javax.inject.Inject;
 
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.data.Stat;
+import org.junit.Assert;
+import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -42,23 +51,21 @@ import org.osgi.framework.ServiceReference;
 public class AbstractDosgiTest {
     static final int ZK_PORT = 35101;
     private static final int TIMEOUT = 20;
-    
+
     @Inject
     BundleContext bundleContext;
-    
-    
-    
+
     /**
-     * Sleeps for a short interval, throwing an exception if timeout has been reached.
-     * Used to facilitate a retry interval with timeout when used in a loop.
+     * Sleeps for a short interval, throwing an exception if timeout has been reached. Used to facilitate a
+     * retry interval with timeout when used in a loop.
      *
      * @param startTime the start time of the entire operation in milliseconds
      * @param timeout the timeout duration for the entire operation in seconds
      * @param message the error message to use when timeout occurs
      * @throws InterruptedException if interrupted while sleeping
      */
-    private static void sleepOrTimeout(long startTime, long timeout, String message) throws
-            InterruptedException, TimeoutException {
+    private static void sleepOrTimeout(long startTime, long timeout, String message)
+        throws InterruptedException, TimeoutException {
         timeout *= 1000; // seconds to millis
         long elapsed = System.currentTimeMillis() - startTime;
         long remaining = timeout - elapsed;
@@ -70,7 +77,7 @@ public class AbstractDosgiTest {
     }
 
     @SuppressWarnings({
-        "rawtypes", "unchecked"
+                       "rawtypes", "unchecked"
     })
     protected ServiceReference waitService(BundleContext bc, Class cls, String filter, int timeout)
         throws Exception {
@@ -156,7 +163,8 @@ public class AbstractDosgiTest {
 
     protected void assertBundlesStarted() {
         for (Bundle bundle : bundleContext.getBundles()) {
-            System.out.println(bundle.getSymbolicName() + ":" + bundle.getVersion() + ": " + bundle.getState());
+            System.out
+                .println(bundle.getSymbolicName() + ":" + bundle.getVersion() + ": " + bundle.getState());
             if (bundle.getState() != Bundle.ACTIVE) {
                 try {
                     bundle.start();
@@ -166,15 +174,55 @@ public class AbstractDosgiTest {
             }
         }
     }
-    
+
+    protected ZooKeeper createZookeeperClient() throws IOException {
+        return new ZooKeeper("localhost:" + ZK_PORT, 1000, null);
+    }
+
+    protected void assertNodeExists(ZooKeeper zk, String zNode, int timeout) {
+        long endTime = System.currentTimeMillis() + timeout;
+        Stat stat = null;
+        while (stat == null && System.currentTimeMillis() < endTime) {
+            try {
+                stat = zk.exists(zNode, null);
+                Thread.sleep(200);
+            } catch (Exception e) {
+                // Ignore
+            }
+        }
+        Assert.assertNotNull("ZooKeeper node " + zNode + " was not found", stat);
+    }
+
     protected static Option configZKConsumer() {
-        return newConfiguration("org.apache.aries.rsa.discovery.zookeeper").put("zookeeper.host", "127.0.0.1")
+        return newConfiguration("org.apache.aries.rsa.discovery.zookeeper") //
+            .put("zookeeper.host", "127.0.0.1") //
             .put("zookeeper.port", "" + ZK_PORT).asOption();
     }
 
     protected static Option configZKServer() {
-        return newConfiguration("org.apache.aries.rsa.discovery.zookeeper.server").put("clientPort", "" + ZK_PORT)
+        return newConfiguration("org.apache.aries.rsa.discovery.zookeeper.server")
+            .put("clientPort", "" + ZK_PORT) //
             .asOption();
     }
 
+    protected static MavenArtifactProvisionOption greeterImpl() {
+        return mavenBundle().groupId("org.apache.cxf.dosgi.samples")
+            .artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject();
+    }
+
+    protected static MavenArtifactProvisionOption greeterInterface() {
+        return mavenBundle().groupId("org.apache.cxf.dosgi.samples")
+            .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject();
+    }
+
+    protected static Option basicTestOptions() throws Exception {
+        return composite(MultiBundleTools.getDistro(), //
+                         CoreOptions.junitBundles(), //
+                         systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"), //
+                         systemProperty("pax.exam.osgi.unresolved.fail").value("true"), //
+                         frameworkStartLevel(100)
+        // CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005") //
+        );
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
index e7c4b4a..c66b358 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
@@ -19,17 +19,12 @@
 package org.apache.cxf.dosgi.systests2.multi;
 
 import static org.apache.cxf.dosgi.systests2.multi.GreeterServiceProxyFactory.createGreeterServiceProxy;
-import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.provision;
 import static org.ops4j.pax.exam.CoreOptions.streamBundle;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.io.InputStream;
 import java.util.Map;
 
-import javax.inject.Inject;
-
 import org.apache.cxf.dosgi.samples.greeter.GreeterService;
 import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
 import org.apache.cxf.dosgi.systests2.multi.customintent.AddGreetingPhraseInterceptor;
@@ -41,48 +36,23 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 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.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 
 @RunWith(PaxExam.class)
 public class TestCustomIntent extends AbstractDosgiTest {
 
-    @Inject
-    BundleContext bundleContext;
-
-    protected static InputStream getCustomIntentBundle() {
-        return TinyBundles.bundle()
-                .add(CustomIntentActivator.class)
-                .add(CustomFeature.class)
-                .add(AddGreetingPhraseInterceptor.class)
-                .set(Constants.BUNDLE_SYMBOLICNAME, "CustomIntent")
-                .set(Constants.BUNDLE_ACTIVATOR, CustomIntentActivator.class.getName()).build(TinyBundles.withBnd());
-    }
-
-    protected static InputStream getServiceBundle() {
-        return TinyBundles.bundle()
-                .add(GreeterServiceWithCustomIntentActivator.class)
-                .add(EmptyGreeterService.class)
-                .set(Constants.BUNDLE_SYMBOLICNAME, "EmptyGreeterService")
-                .set(Constants.BUNDLE_ACTIVATOR, GreeterServiceWithCustomIntentActivator.class.getName())
-                .build(TinyBundles.withBnd());
-    }
-
     @Configuration
     public static Option[] configure() throws Exception {
-        return new Option[] {
-                MultiBundleTools.getDistro(),
-                CoreOptions.junitBundles(),
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
-                mavenBundle().groupId("org.apache.cxf.dosgi.samples")
-                    .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
-                streamBundle(getCustomIntentBundle()).noStart(),
-                provision(getServiceBundle()),
-                frameworkStartLevel(100) };
+        return new Option[] //
+        {
+         basicTestOptions(), //
+         greeterInterface(), //
+         streamBundle(getCustomIntentBundle()).noStart(), //
+         provision(getServiceBundle())
+        };
     }
 
     @Test
@@ -98,4 +68,23 @@ public class TestCustomIntent extends AbstractDosgiTest {
         GreetingPhrase phrase = result.keySet().iterator().next();
         Assert.assertEquals("Hi from custom intent", phrase.getPhrase());
     }
+
+    private static InputStream getCustomIntentBundle() {
+        return TinyBundles.bundle() //
+            .add(CustomIntentActivator.class) //
+            .add(CustomFeature.class) //
+            .add(AddGreetingPhraseInterceptor.class) //
+            .set(Constants.BUNDLE_SYMBOLICNAME, "CustomIntent") //
+            .set(Constants.BUNDLE_ACTIVATOR, CustomIntentActivator.class.getName())
+            .build(TinyBundles.withBnd());
+    }
+
+    private static InputStream getServiceBundle() {
+        return TinyBundles.bundle() //
+            .add(GreeterServiceWithCustomIntentActivator.class) //
+            .add(EmptyGreeterService.class) //
+            .set(Constants.BUNDLE_SYMBOLICNAME, "EmptyGreeterService") //
+            .set(Constants.BUNDLE_ACTIVATOR, GreeterServiceWithCustomIntentActivator.class.getName())
+            .build(TinyBundles.withBnd());
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java
index 51db7f9..b0113fd 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java
@@ -18,73 +18,36 @@
  */
 package org.apache.cxf.dosgi.systests2.multi;
 
-import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
-import javax.inject.Inject;
-
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.Stat;
-import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationAdmin;
 
 @RunWith(PaxExam.class)
 public class TestDiscoveryExport extends AbstractDosgiTest {
 
-    private static final String GREETER_ZOOKEEPER_NODE
-        = "/osgi/service_registry/org/apache/cxf/dosgi/samples/greeter/GreeterService/localhost#9090##greeter";
-
-    @Inject
-    BundleContext bundleContext;
+    private static final String GREETER_ZOOKEEPER_NODE = //
+        "/osgi/service_registry/org/apache/cxf/dosgi/samples/greeter/GreeterService/localhost#9090##greeter";
 
-    @Inject
-    ConfigurationAdmin configAdmin;
-    
     @Configuration
     public static Option[] configure() throws Exception {
-        return new Option[] {
-                MultiBundleTools.getDistro(),
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
-                configZKServer(),
-                configZKConsumer(),
-                mavenBundle().groupId("org.apache.servicemix.bundles")
-                    .artifactId("org.apache.servicemix.bundles.junit").version("4.9_2"),
-                mavenBundle().groupId("org.apache.cxf.dosgi.samples")
-                    .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
-                mavenBundle().groupId("org.apache.cxf.dosgi.samples")
-                    .artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject(),
-                frameworkStartLevel(100),
-                //CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+        return new Option[] //
+        {
+         basicTestOptions(), //
+         configZKServer(), //
+         configZKConsumer(), //
+         greeterInterface(), //
+         greeterImpl(),
         };
     }
 
     @Test
     public void testDiscoveryExport() throws Exception {
-        ZooKeeper zk = new ZooKeeper("localhost:" + ZK_PORT, 1000, null);
-        assertNodeExists(zk, GREETER_ZOOKEEPER_NODE, 14000);
+        ZooKeeper zk = createZookeeperClient();
+        assertNodeExists(zk, GREETER_ZOOKEEPER_NODE, 5000);
         zk.close();
     }
 
-    private void assertNodeExists(ZooKeeper zk, String zNode, int timeout) {
-        long endTime = System.currentTimeMillis() + timeout;
-        Stat stat = null;
-        while (stat == null && System.currentTimeMillis() < endTime) {
-            try {
-                stat = zk.exists(zNode, null);
-                Thread.sleep(200);
-            } catch (Exception e) {
-                // Ignore
-            }
-        }
-        Assert.assertNotNull("ZooKeeper node " + zNode + " was not found", stat);
-    }
-    
-
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
index 6eeb4b7..7ce7d43 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
@@ -18,17 +18,11 @@
  */
 package org.apache.cxf.dosgi.systests2.multi;
 
-
-
-import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.provision;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.io.InputStream;
 
-import javax.inject.Inject;
-
 import org.apache.cxf.dosgi.systests2.multi.rest.RestTranslate;
 import org.apache.cxf.dosgi.systests2.multi.rest.RestTranslateImpl;
 import org.apache.cxf.dosgi.systests2.multi.rest.TranslateActivator;
@@ -37,56 +31,46 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 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.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 
 @RunWith(PaxExam.class)
 public class TestExportRestService extends AbstractDosgiTest {
-
-    @Inject
-    BundleContext bundleContext;
-    
     String webPort = "9091";
 
     @Configuration
     public Option[] configure() throws Exception {
-        return new Option[] {
-                MultiBundleTools.getDistro(),
-                systemProperty("org.osgi.service.http.port").value(webPort),
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
-                mavenBundle().groupId("org.apache.cxf.dosgi.samples")
-                    .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
-                CoreOptions.junitBundles(),
-                provision(getServiceBundle()),
-                frameworkStartLevel(100),
-                //CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+        return new Option[] //
+        {//
+         basicTestOptions(), //
+         systemProperty("org.osgi.service.http.port").value(webPort), //
+         provision(getServiceBundle())
         };
     }
-    
-    private InputStream getServiceBundle() {
-        return TinyBundles.bundle()
-                .add(RestTranslate.class)
-                .add(RestTranslateImpl.class)
-                .add(TranslateActivator.class)
-                .set(Constants.BUNDLE_SYMBOLICNAME, "RestTranslate")
-                .set(Constants.BUNDLE_ACTIVATOR, TranslateActivator.class.getName())
-                .build(TinyBundles.withBnd());
-    }
 
     @Test
-    public void testEndpointAvailable() throws Exception {
+    public void testCallService() throws Exception {
         waitWebPage("http://localhost:" + webPort + "/cxf/translate");
         try {
             WebClient client = WebClient.create("http://localhost:" + webPort + "/cxf/translate/hello");
             String result = client.get(String.class);
             Assert.assertEquals("hallo", result);
         } catch (Exception e) {
+            // Avoid serialization problems when just letting the exception fly
             e.printStackTrace();
             throw new RuntimeException(e.getMessage());
         }
     }
+
+    private InputStream getServiceBundle() {
+        return TinyBundles.bundle() //
+            .add(RestTranslate.class) //
+            .add(RestTranslateImpl.class) //
+            .add(TranslateActivator.class) //
+            .set(Constants.BUNDLE_SYMBOLICNAME, "RestTranslate") //
+            .set(Constants.BUNDLE_ACTIVATOR, TranslateActivator.class.getName()) //
+            .build(TinyBundles.withBnd());
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
index 97d791e..1516499 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
@@ -26,9 +26,6 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
 import org.apache.cxf.dosgi.samples.greeter.GreeterData;
 import org.apache.cxf.dosgi.samples.greeter.GreeterException;
 import org.apache.cxf.dosgi.samples.greeter.GreeterService;
@@ -37,33 +34,27 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 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 static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
 
 @RunWith(PaxExam.class)
 public class TestExportService extends AbstractDosgiTest {
 
     @Configuration
     public static Option[] configure() throws Exception {
-        return new Option[] {
-            MultiBundleTools.getDistro(),
-            CoreOptions.junitBundles(),
-            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
-            mavenBundle().groupId("org.apache.cxf.dosgi.samples")
-                .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
-            mavenBundle().groupId("org.apache.cxf.dosgi.samples")
-                .artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject(),
-            //CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+        return new Option[] //
+        {//
+         basicTestOptions(), //
+         greeterInterface(), //
+         greeterImpl(),
         };
     }
 
     @Test
     public void testAccessEndpoint() throws Exception {
-        assertBundlesStarted();
         waitPort(9090);
         checkWsdl(new URL("http://localhost:9090/greeter?wsdl"));
         checkServiceCall("http://localhost:9090/greeter");

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java
index 8c1a816..fce0114 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java
@@ -18,114 +18,82 @@
  */
 package org.apache.cxf.dosgi.systests2.multi;
 
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
 import java.io.InputStream;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Map;
 
 import javax.inject.Inject;
 
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.dosgi.samples.greeter.GreeterData;
-import org.apache.cxf.dosgi.samples.greeter.GreeterException;
 import org.apache.cxf.dosgi.samples.greeter.GreeterService;
 import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
-import org.apache.cxf.dosgi.systests2.common.test1.GreeterDataImpl;
-import org.apache.cxf.dosgi.systests2.common.test1.MyActivator;
-import org.apache.cxf.dosgi.systests2.common.test1.MyServiceTracker;
-import org.apache.cxf.dosgi.systests2.common.test1.StartServiceTracker;
+import org.apache.cxf.dosgi.systests2.multi.importservice.GreeterDataImpl;
+import org.apache.cxf.dosgi.systests2.multi.importservice.MyActivator;
+import org.apache.cxf.dosgi.systests2.multi.importservice.MyServiceTracker;
+import org.apache.cxf.dosgi.systests2.multi.importservice.SimpleGreeter;
+import org.apache.cxf.dosgi.systests2.multi.importservice.StartServiceTracker;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ServerFactoryBean;
+import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 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.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-
-import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 @RunWith(PaxExam.class)
 public class TestImportService extends AbstractDosgiTest {
-
     @Inject
-    BundleContext bundleContext;
+    GreeterService greeterService;
+    private Server server;
 
     @Configuration
     public static Option[] configure() throws Exception {
-        return new Option[] {
-                MultiBundleTools.getDistro(),
-                CoreOptions.junitBundles(),
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
-                mavenBundle().groupId("org.apache.cxf.dosgi.samples")
-                    .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
-                provision(createServiceConsumerBundle()),
-                // increase for debugging
-                systemProperty("org.apache.cxf.dosgi.test.serviceWaitTimeout").value(
-                        System.getProperty("org.apache.cxf.dosgi.test.serviceWaitTimeout", "200")),
-                frameworkStartLevel(100),
-                //CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+        return new Option[] //
+        {//
+         basicTestOptions(), //
+         greeterInterface(), //
+         provision(createServiceConsumerBundle()), //
+         // increase for debugging
+         systemProperty("org.apache.cxf.dosgi.test.serviceWaitTimeout")
+             .value(System.getProperty("org.apache.cxf.dosgi.test.serviceWaitTimeout", "200")),
         };
     }
 
     protected static InputStream createServiceConsumerBundle() {
-        return TinyBundles.bundle()
-            .add(MyActivator.class)
-            .add(MyServiceTracker.class)
-            .add(StartServiceTracker.class)
-            .add(GreeterDataImpl.class)
-            .add("OSGI-INF/remote-service/remote-services.xml", TestImportService.class.getResource("/rs-test1.xml"))
-            .set(Constants.BUNDLE_SYMBOLICNAME, "testClientBundle")
-            .set(Constants.EXPORT_PACKAGE, "org.apache.cxf.dosgi.systests2.common.test1")
-            .set(Constants.BUNDLE_ACTIVATOR, MyActivator.class.getName())
+        return TinyBundles.bundle() //
+            .add(MyActivator.class) //
+            .add(MyServiceTracker.class) //
+            .add(StartServiceTracker.class) //
+            .add(GreeterDataImpl.class) //
+            .add("OSGI-INF/remote-service/remote-services.xml",
+                 TestImportService.class.getResource("/rs-test1.xml")) //
+            .set(Constants.BUNDLE_SYMBOLICNAME, "testClientBundle") //
+            .set(Constants.BUNDLE_ACTIVATOR, MyActivator.class.getName()) //
             .build(TinyBundles.withBnd());
     }
 
+    @Before
+    public void createCXFService() {
+        server = publishTestGreeter();
+    }
+
     @Test
     public void testClientConsumer() throws Exception {
-        // This test tests the consumer side of Distributed OSGi. It works as follows:
-        // 1. It creates a little test bundle on the fly and starts that in the framework
-        //    (this happens in the configure() method above). The test bundle waits until its
-        //    instructed to start doing stuff. It's give this instruction via a service that is
-        //    registered by this test (the service is of type java.lang.Object and has testName=test1).
-        // 2. The test manually creates a CXF server of the appropriate type (using ServerFactoryBean)
-        // 3. It signals the client bundle by registering a service to start doing its work.
-        //    This registers a ServiceTracker in the client bundle for the remote service that is created
-        //    by the test in step 2. The client bundle knows about the address through the
-        //    remote-services.xml file.
-        // 4. The client bundle will invoke the remote service and record the results in a service that it
-        //    registers in the Service Registry.
-        // 5. The test waits for this service to appear and then checks the results which are available as
-        //    a service property.
-
-        // Set up a Server in the test
-        Server server = null;
-        try {
-            server = publishTestGreeter();
-
-            Dictionary<String, Object> props = new Hashtable<String, Object>();
-            props.put("testName", "test1");
-            bundleContext.registerService(Object.class.getName(), new Object(), props);
+        Map<GreetingPhrase, String> result = greeterService.greetMe("OSGi");
+        GreetingPhrase phrase = result.keySet().iterator().next();
+        Assert.assertEquals("Hi", phrase.getPhrase());
+    }
 
-            // Wait for the service tracker in the test bundle to register a service with the test result
-            @SuppressWarnings("rawtypes")
-            ServiceReference ref = waitService(bundleContext, String.class, "(testResult=test1)", 20);
-            Assert.assertEquals("HiOSGi;exception", ref.getProperty("result"));
-        } finally {
-            if (server != null) {
-                server.stop();
-            }
-            
-        }
+    @After
+    public void stopCXFService() {
+        server.stop();
     }
 
     private Server publishTestGreeter() {
@@ -136,24 +104,10 @@ public class TestImportService extends AbstractDosgiTest {
             factory.setServiceClass(GreeterService.class);
             factory.setAddress("http://localhost:9191/grrr");
             factory.getServiceFactory().setDataBinding(new AegisDatabinding());
-            factory.setServiceBean(new TestGreeter());
+            factory.setServiceBean(new SimpleGreeter());
             return factory.create();
         } finally {
             Thread.currentThread().setContextClassLoader(cl);
         }
     }
-
-    public static class TestGreeter implements GreeterService {
-
-        public Map<GreetingPhrase, String> greetMe(String name) {
-            Map<GreetingPhrase, String> m = new HashMap<GreetingPhrase, String>();
-            GreetingPhrase gp = new GreetingPhrase("Hi");
-            m.put(gp, name);
-            return m;
-        }
-
-        public GreetingPhrase[] greetMe(GreeterData gd) throws GreeterException {
-            throw new GreeterException("TestGreeter");
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java
new file mode 100644
index 0000000..096d116
--- /dev/null
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java
@@ -0,0 +1,39 @@
+/**
+ * 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.systests2.multi.importservice;
+
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
+
+public class GreeterDataImpl implements GreeterData {
+
+    public int getAge() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public String getName() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isException() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java
new file mode 100644
index 0000000..08fe288
--- /dev/null
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java
@@ -0,0 +1,45 @@
+/**
+ * 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.systests2.multi.importservice;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.util.tracker.ServiceTracker;
+
+@SuppressWarnings("rawtypes")
+public class MyActivator implements BundleActivator {
+    private ServiceTracker startTracker;
+    private ServiceTracker tracker;
+
+    public void start(final BundleContext bc) throws Exception {
+        Filter filter = bc.createFilter("(&(objectClass=java.lang.Object)(testName=test1))");
+        tracker = new MyServiceTracker(bc);
+
+        // The start tracker waits until a service from the test class is set before the
+        // 'MyServiceTracker' is activated.
+        startTracker = new StartServiceTracker(bc, filter, tracker);
+        startTracker.open();
+    }
+
+    public void stop(BundleContext bc) throws Exception {
+        startTracker.close();
+        tracker.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java
new file mode 100644
index 0000000..cc2d8ba
--- /dev/null
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java
@@ -0,0 +1,76 @@
+/**
+ * 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.systests2.multi.importservice;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.cxf.dosgi.samples.greeter.GreeterException;
+import org.apache.cxf.dosgi.samples.greeter.GreeterService;
+import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class MyServiceTracker extends ServiceTracker<GreeterService, GreeterService> {
+
+    private static StringBuffer invocationResult = new StringBuffer();
+
+    public MyServiceTracker(BundleContext context) {
+        super(context, GreeterService.class, null);
+    }
+
+    @Override
+    public GreeterService addingService(ServiceReference<GreeterService> reference) {
+        GreeterService service = super.addingService(reference);
+        System.out.println("[client] Got a GreeterService...");
+        invokeGreeter(service);
+        return service;
+    }
+
+    public static String getResult() {
+        return invocationResult.toString();
+    }
+
+    private void invokeGreeter(GreeterService svc) {
+        try {
+            Map<GreetingPhrase, String> result = svc.greetMe("OSGi");
+            for (Map.Entry<GreetingPhrase, String> e : result.entrySet()) {
+                GreetingPhrase key = e.getKey();
+                invocationResult.append(key.getPhrase());
+                invocationResult.append(e.getValue());
+            }
+            try {
+                svc.greetMe(new GreeterDataImpl());
+            } catch (GreeterException ex) {
+                invocationResult.append(";exception");
+            }
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            props.put("result", invocationResult.toString());
+            props.put("testResult", "test1");
+
+            System.out.println("[client] Successfully invoked remote service. Registering test response service...");
+            context.registerService(String.class.getName(), "test1", props);
+        } catch (Exception x) {
+            System.err.println("[client] Error during remote service invocation:");
+            x.printStackTrace(System.err);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/SimpleGreeter.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/SimpleGreeter.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/SimpleGreeter.java
new file mode 100644
index 0000000..e39c315
--- /dev/null
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/SimpleGreeter.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.cxf.dosgi.systests2.multi.importservice;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
+import org.apache.cxf.dosgi.samples.greeter.GreeterException;
+import org.apache.cxf.dosgi.samples.greeter.GreeterService;
+import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
+
+public class SimpleGreeter implements GreeterService {
+
+    public Map<GreetingPhrase, String> greetMe(String name) {
+        Map<GreetingPhrase, String> m = new HashMap<GreetingPhrase, String>();
+        GreetingPhrase gp = new GreetingPhrase("Hi");
+        m.put(gp, name);
+        return m;
+    }
+
+    public GreetingPhrase[] greetMe(GreeterData gd) throws GreeterException {
+        throw new GreeterException("TestGreeter");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/a9d93602/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java
new file mode 100644
index 0000000..cd14c2b
--- /dev/null
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java
@@ -0,0 +1,44 @@
+/**
+ * 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.systests2.multi.importservice;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+@SuppressWarnings({
+    "unchecked", "rawtypes"
+   })
+public class StartServiceTracker extends ServiceTracker {
+
+    private ServiceTracker tracker;
+
+    public StartServiceTracker(BundleContext context, Filter filter, ServiceTracker tracker) {
+        super(context, filter, null);
+        this.tracker = tracker;
+    }
+
+    @Override
+    public Object addingService(ServiceReference reference) {
+        System.out.println("Test object available, so starting the service client tracker...");
+        tracker.open();
+        return super.addingService(reference);
+    }
+}


Mime
View raw message