Author: veithen
Date: Thu Mar 13 15:20:31 2014
New Revision: 1577191

URL: http://svn.apache.org/r1577191
Log:
Refactored the OSGi test: the test code itself doesn't need to run in the OSGi 
container and we don't need to install a probe. Instead, we just need to run 
the container and send SOAP requests to the services deployed in the container.

Modified:
    axis/axis2/java/core/trunk/modules/osgi-tests/pom.xml
    axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java

Modified: axis/axis2/java/core/trunk/modules/osgi-tests/pom.xml
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/osgi-tests/pom.xml?rev=1577191&r1=1577190&r2=1577191&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/osgi-tests/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/osgi-tests/pom.xml Thu Mar 13 15:20:31 
2014
@@ -76,21 +76,8 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-junit4</artifactId>
-            <version>${exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.11</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-atinject_1.0_spec</artifactId>
-            <version>1.0</version>
             <scope>test</scope>
         </dependency>
     </dependencies>

Modified: 
axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java?rev=1577191&r1=1577190&r2=1577191&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java 
(original)
+++ axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java 
Thu Mar 13 15:20:31 2014
@@ -17,38 +17,33 @@
  * under the License.
  */
 import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.provision;
 import static org.ops4j.pax.exam.CoreOptions.url;
 import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
 
-import javax.inject.Inject;
-
 import org.apache.axis2.osgi.module.Handler1;
 import org.apache.axis2.osgi.module.Handler2;
 import org.apache.axis2.osgi.module.SimpleModule;
 import org.apache.axis2.osgi.service.Activator;
 import org.apache.axis2.osgi.service.Calculator;
 import org.apache.axis2.osgi.service.Version;
+import org.apache.felix.framework.FrameworkFactory;
 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.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.ExamSystem;
+import org.ops4j.pax.exam.nat.internal.NativeTestContainer;
+import org.ops4j.pax.exam.spi.DefaultExamSystem;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
 public class OSGiTest {
-    @Configuration
-    public static Option[] configuration() {
-        return options(
+    @Test
+    public void test() throws Exception {
+        ExamSystem system = DefaultExamSystem.create(options(
+                
url("link:classpath:META-INF/links/org.ops4j.pax.logging.api.link"),
+                url("link:classpath:META-INF/links/org.osgi.compendium.link"),
                 
url("link:classpath:org.apache.servicemix.bundles.wsdl4j.link"),
                 
url("link:classpath:org.apache.geronimo.specs.geronimo-activation_1.1_spec.link"),
 // TODO: should not be necessary on Java 6
                 
url("link:classpath:org.apache.geronimo.specs.geronimo-jms_1.1_spec.link"), // 
TODO: why the heck is this required???
@@ -88,23 +83,22 @@ public class OSGiTest {
                     .set(Constants.BUNDLE_SYMBOLICNAME, "version.service")
                     .set(Constants.BUNDLE_ACTIVATOR, Activator.class.getName())
                     .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
-                    .build()),
-                junitBundles());
-    }
-    
-    @Inject
-    private BundleContext context;
-    
-    @Test
-    public void test() {
-        boolean found = false;
-        for (Bundle bundle : context.getBundles()) {
-            if (bundle.getSymbolicName().equals("org.apache.axis2.osgi")) {
-                found = true;
-                Assert.assertEquals(Bundle.ACTIVE, bundle.getState());
-                break;
+                    .build())));
+        NativeTestContainer container = new NativeTestContainer(system, new 
FrameworkFactory());
+        container.start();
+        try {
+            BundleContext context = 
container.getSystemBundle().getBundleContext();
+            boolean found = false;
+            for (Bundle bundle : context.getBundles()) {
+                if (bundle.getSymbolicName().equals("org.apache.axis2.osgi")) {
+                    found = true;
+                    Assert.assertEquals(Bundle.ACTIVE, bundle.getState());
+                    break;
+                }
             }
+            assertTrue(found);
+        } finally {
+            container.stop();
         }
-        assertTrue(found);
     }
 }


Reply via email to