[DOSGI-241] Simplify Tests
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 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 @@
 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 @@
     }
 
     @SuppressWarnings({
-        "rawtypes", "unchecked"
+                       "rawtypes", "unchecked"
     })
     protected ServiceReference waitService(BundleContext bc, Class cls, String filter, int timeout)
         throws Exception {
@@ -156,7 +163,8 @@
 
     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 @@
             }
         }
     }
-    
+
+    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") //
+        );
+    }
+
 }
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.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 @@
         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());
+    }
 }
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";
+    private static final String GREETER_ZOOKEEPER_NODE = //
+        "/osgi/service_registry/org/apache/cxf/dosgi/samples/greeter/GreeterService/localhost#9090##greeter";
 
-    @Inject
-    BundleContext bundleContext;
-
-    @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);
-    }
-    
-
 }
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.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());
+    }
 }
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.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.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");
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.
+        Map<GreetingPhrase, String> result = greeterService.greetMe("OSGi");
+        GreetingPhrase phrase = result.keySet().iterator().next();
+        Assert.assertEquals("Hi", phrase.getPhrase());
+    }
 
-        // 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);
-
-            // 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 @@
             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");
-        }
-    }
 }
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/multi/importservice/GreeterDataImpl.java
similarity index 95%
rename from systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/GreeterDataImpl.java
rename to systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java
index 31f2988..096d116 100644
--- 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/multi/importservice/GreeterDataImpl.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.dosgi.systests2.common.test1;
+package org.apache.cxf.dosgi.systests2.multi.importservice;
 
 import org.apache.cxf.dosgi.samples.greeter.GreeterData;
 
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/multi/importservice/MyActivator.java
similarity index 94%
rename from systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java
rename to systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java
index 6740725..08fe288 100644
--- 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/multi/importservice/MyActivator.java
@@ -16,15 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.dosgi.systests2.common.test1;
+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;
 
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/multi/importservice/MyServiceTracker.java
similarity index 97%
rename from systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java
rename to systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java
index 2886ce8..cc2d8ba 100644
--- 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/multi/importservice/MyServiceTracker.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.dosgi.systests2.common.test1;
+package org.apache.cxf.dosgi.systests2.multi.importservice;
 
 import java.util.Dictionary;
 import java.util.Hashtable;
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
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/multi/importservice/StartServiceTracker.java
similarity index 92%
rename from systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java
rename to systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java
index 40319ec..cd14c2b 100644
--- 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/multi/importservice/StartServiceTracker.java
@@ -16,13 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.dosgi.systests2.common.test1;
+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;