cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1551914 - in /cxf/trunk: osgi/itests/pom.xml osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BasicFeatureTest.java osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java parent/pom.xml
Date Wed, 18 Dec 2013 11:14:13 GMT
Author: cschneider
Date: Wed Dec 18 11:14:13 2013
New Revision: 1551914

URL: http://svn.apache.org/r1551914
Log:
[CXF-5468] - Upgrade osgi itests to pax exam 3.4.0 and karaf 2.3.3

Modified:
    cxf/trunk/osgi/itests/pom.xml
    cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BasicFeatureTest.java
    cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
    cxf/trunk/parent/pom.xml

Modified: cxf/trunk/osgi/itests/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/osgi/itests/pom.xml?rev=1551914&r1=1551913&r2=1551914&view=diff
==============================================================================
--- cxf/trunk/osgi/itests/pom.xml (original)
+++ cxf/trunk/osgi/itests/pom.xml Wed Dec 18 11:14:13 2013
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-parent</artifactId>
-        <version>2.6.0-SNAPSHOT</version>
+        <version>3.0.0-SNAPSHOT</version>
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
     <groupId>org.apache.cxf.osgi.itests</groupId>
@@ -29,50 +29,99 @@
     <name>Apache CXF :: OSGi :: Integration Tests</name>
     <packaging>jar</packaging>
     <properties>
-        <pax.exam.version>2.3.0.M1</pax.exam.version>
-        <pax.exam.karaf.version>0.4.0</pax.exam.karaf.version>
+        <pax.exam.version>3.4.0</pax.exam.version>
         <pax.url.version>1.2.8</pax.url.version>
         <cxf.surefire.fork.mode>once</cxf.surefire.fork.mode>
     </properties>
     <dependencies>
         <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-mvn</artifactId>
-            <version>${pax.url.version}</version>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-core</artifactId>
+            <version>${project.version}</version>
         </dependency>
+        
         <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-aether</artifactId>
-            <version>${pax.url.version}</version>
+            <groupId>org.apache.cxf.karaf</groupId>
+            <artifactId>apache-cxf</artifactId>
+            <version>${project.version}</version>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
+        
+        <dependency>
+        	<groupId>org.apache.karaf</groupId>
+        	<artifactId>apache-karaf</artifactId>
+        	<version>${cxf.karaf.version}</version>
+        	<type>tar.gz</type>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.karaf.features</groupId>
+        	<artifactId>org.apache.karaf.features.core</artifactId>
+        	<version>${cxf.karaf.version}</version>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.karaf.shell</groupId>
+        	<artifactId>org.apache.karaf.shell.console</artifactId>
+        	<version>${cxf.karaf.version}</version>
+        </dependency>
+        <dependency>
+        	<groupId>org.osgi</groupId>
+        	<artifactId>org.osgi.compendium</artifactId>
         </dependency>
+        
         <dependency>
-            <groupId>org.apache.karaf</groupId>
-            <artifactId>apache-karaf</artifactId>
-            <version>${cxf.karaf.version}</version>
-            <type>tar.gz</type>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.openengsb.labs.paxexam.karaf</groupId>
-            <artifactId>paxexam-karaf-container</artifactId>
-            <version>${pax.exam.karaf.version}</version>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+
+        
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam-junit4</artifactId>
             <version>${pax.exam.version}</version>
             <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${pax.exam.version}</version>
             <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-core</artifactId>
-            <version>${project.version}</version>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-karaf</artifactId>
+            <version>${pax.exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${pax.exam.version}</version>
+            <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>1.2.8</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
     </dependencies>
     <build>
         <plugins>
@@ -80,37 +129,12 @@
             <plugin>
                 <groupId>org.apache.servicemix.tooling</groupId>
                 <artifactId>depends-maven-plugin</artifactId>
-                <version>1.2</version>
                 <executions>
                     <execution>
                         <id>generate-depends-file</id>
                         <goals>
                             <goal>generate-depends-file</goal>
                         </goals>
-                        <phase>compile</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>unpack-unix</id>
-                        <phase>generate-resources</phase>
-                        <goals>
-                            <goal>unpack</goal>
-                        </goals>
-                        <configuration>
-                            <artifactItems>
-                                <artifactItem>
-                                    <groupId>org.apache.karaf</groupId>
-                                    <artifactId>apache-karaf</artifactId>
-                                    <type>tar.gz</type>
-                                    <outputDirectory>target/karaf-base</outputDirectory>
-                                </artifactItem>
-                            </artifactItems>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>

Modified: cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BasicFeatureTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BasicFeatureTest.java?rev=1551914&r1=1551913&r2=1551914&view=diff
==============================================================================
--- cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BasicFeatureTest.java (original)
+++ cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BasicFeatureTest.java Wed
Dec 18 11:14:13 2013
@@ -19,55 +19,34 @@
 
 package org.apache.cxf.osgi.itests;
 
-import java.io.File;
-
-import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openengsb.labs.paxexam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.ExamReactorStrategy;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
 
-import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
-import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.logLevel;
-import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
 
-@RunWith(JUnit4TestRunner.class)
-@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
 public class BasicFeatureTest extends CXFOSGiTestSupport {
-    //private static final String UNINSTALLED = "[uninstalled]";
-    //private static final String INSTALLED = "[installed  ]";
-
     @Test
-    public void testCXFFeaturesModule() throws InterruptedException {
-        installCXF();
-        Thread.sleep(DEFAULT_TIMEOUT);
-
-        System.err.println(executeCommand("list"));
-
-
-    }
-
-    @After
-    public void tearDown() {
-        try {
-            unInstallCXF();
-        } catch (Exception ex) {
-            //Ignore
-        }
+    public void testCXFFeaturesModule() throws Exception {
+        assertBundleInstalled("org.apache.cxf.cxf-core");
+        assertBlueprintNameSpacePublished("http://cxf.apache.org/blueprint/core");
+        assertBlueprintNameSpacePublished("http://cxf.apache.org/configuration/beans");
+        assertBlueprintNameSpacePublished("http://cxf.apache.org/configuration/parameterized-types");
     }
 
     @Configuration
     public Option[] config() {
-        File file = new File("target/karaf-base/apache-karaf-2.2.5/etc/jre.properties.cxf")
-            .getAbsoluteFile();
         return new Option[]{
-                cxfDistributionConfiguration(), 
+                cxfBaseConfig(), 
                 keepRuntimeFolder(),
-                replaceConfigurationFile("etc/jre.properties", file),
-                logLevel(LogLevelOption.LogLevel.INFO)};
+                logLevel(LogLevel.INFO)};
     }
 }

Modified: cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
URL: http://svn.apache.org/viewvc/cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java?rev=1551914&r1=1551913&r2=1551914&view=diff
==============================================================================
--- cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
(original)
+++ cxf/trunk/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
Wed Dec 18 11:14:13 2013
@@ -36,14 +36,19 @@ import java.util.concurrent.ExecutorServ
 import java.util.concurrent.Executors;
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.TimeUnit;
+
 import javax.inject.Inject;
 
+import org.apache.aries.blueprint.NamespaceHandler;
 import org.apache.felix.service.command.CommandProcessor;
 import org.apache.felix.service.command.CommandSession;
-import org.ops4j.pax.exam.MavenUtils;
+import org.apache.karaf.features.FeaturesService;
+import org.junit.Assert;
+import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.ProbeBuilder;
 import org.ops4j.pax.exam.TestProbeBuilder;
-import org.ops4j.pax.exam.junit.ProbeBuilder;
+import org.ops4j.pax.exam.options.MavenUrlReference;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -53,8 +58,9 @@ import org.osgi.framework.InvalidSyntaxE
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 
-import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
 import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
 
 /**
  * 
@@ -63,24 +69,13 @@ public class CXFOSGiTestSupport {
     static final Long COMMAND_TIMEOUT = 10000L;
     static final Long DEFAULT_TIMEOUT = 20000L;
     static final Long SERVICE_TIMEOUT = 30000L;
-    static final String GROUP_ID = "org.apache.karaf";
-    static final String ARTIFACT_ID = "apache-karaf";
-
-    static final String INSTANCE_STARTED = "Started";
-    static final String INSTANCE_STARTING = "Starting";
-
-    static final String CXF_FEATURE_URL 
-        = "mvn:org.apache.cxf.karaf/apache-cxf/" 
-          //+ org.apache.cxf.version.Version.getCurrentVersion()
-          + "2.6.0-SNAPSHOT"
-          + "/xml/features";
-
-    static final String DEBUG_OPTS = " --java-opts \"-Xdebug -Xnoagent -Djava.compiler=NONE"

-        + " -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%s\"";
 
     @Inject
     protected BundleContext bundleContext;
-
+    
+    @Inject
+    protected FeaturesService featureService;
+    
     ExecutorService executor = Executors.newCachedThreadPool();
 
     /**
@@ -90,35 +85,34 @@ public class CXFOSGiTestSupport {
     @ProbeBuilder
     public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
         probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*,org.apache.felix.service.*;status=provisional");
-
         return probe;
     }
 
-
-    /**
-     * Installs the CXF feature
-     */
-    protected void installCXF() {
-        System.err.println(executeCommand("features:addurl " + CXF_FEATURE_URL));
-        System.err.println(executeCommand("features:install cxf"));
-    }
-
-    protected void unInstallCXF() {
-        System.err.println(executeCommand("features:uninstall cxf"));
-        System.err.println(executeCommand("list"));
-    }
-
     /**
      * Create an {@link org.ops4j.pax.exam.Option} for using a .
      *
      * @return
      */
-    protected Option cxfDistributionConfiguration() {
-        return karafDistributionConfiguration().frameworkUrl(
-                maven().groupId(GROUP_ID).artifactId(ARTIFACT_ID).versionAsInProject().type("tar.gz"))
-                .karafVersion(MavenUtils.getArtifactVersion(GROUP_ID, ARTIFACT_ID))
+    protected Option cxfBaseConfig() {
+        MavenUrlReference karafUrl = maven()
+            .groupId("org.apache.karaf")
+            .artifactId("apache-karaf")
+            .versionAsInProject()
+            .type("tar.gz");
+        MavenUrlReference cxfUrl = maven()
+            .groupId("org.apache.cxf.karaf")
+            .artifactId("apache-cxf")
+            .versionAsInProject()
+            .type("xml")
+            .classifier("features");
+        return CoreOptions.composite(
+             karafDistributionConfiguration()
+                .frameworkUrl(karafUrl)
+                .karafVersion("2.3.3")
                 .name("Apache Karaf")
-                .unpackDirectory(new File("target/paxexam/"));
+                .unpackDirectory(new File("target/paxexam/")),
+             features(cxfUrl, "cxf-core")
+        );
     }
 
     /**
@@ -251,6 +245,9 @@ public class CXFOSGiTestSupport {
         return getOsgiService(type, null, SERVICE_TIMEOUT);
     }
 
+    @SuppressWarnings({
+        "rawtypes", "unchecked"
+    })
     protected <T> T getOsgiService(Class<T> type, String filter, long timeout)
{
         ServiceTracker tracker = null;
         try {
@@ -271,7 +268,6 @@ public class CXFOSGiTestSupport {
             // This is buggy, as the service reference may change i think
             Object svc = type.cast(tracker.waitForService(timeout));
             if (svc == null) {
-                @SuppressWarnings("unchecked")
                 Dictionary<String, String> dic = bundleContext.getBundle().getHeaders();
                 System.err.println("Test bundle headers: " + explode(dic));
 
@@ -292,7 +288,7 @@ public class CXFOSGiTestSupport {
             throw new RuntimeException(e);
         }
     }
-
+    
     /**
      * Finds a free port starting from the give port numner.
      *
@@ -342,7 +338,38 @@ public class CXFOSGiTestSupport {
     /**
      * Provides an iterable collection of references, even if the original array is null
      */
+    @SuppressWarnings("rawtypes")
     private static Collection<ServiceReference> asCollection(ServiceReference[] references)
{
         return references != null ? Arrays.asList(references) : Collections.<ServiceReference>emptyList();
     }
+    
+    protected void assertBundleInstalled(String name) {
+        Bundle bundle = findBundleByName(name);
+        Assert.assertNotNull("Bundle " + name + " should be installed", bundle);
+        Assert.assertEquals("Bundle " + name + " should be started", Bundle.ACTIVE, bundle.getState());
+    }
+    
+    protected Bundle findBundleByName(String symbolicName) {
+        for (Bundle bundle : bundleContext.getBundles()) {
+            if (bundle.getSymbolicName().equals(symbolicName)) {
+                return bundle;
+            }
+        }
+        return null;
+    }
+    
+    public void assertServicePublished(String filter) {
+        try {
+            Filter serviceFilter = bundleContext.createFilter(filter);
+            ServiceTracker<?, ?> tracker = new ServiceTracker<Object, Object>(bundleContext,
serviceFilter, null);
+            tracker.waitForService(SERVICE_TIMEOUT);
+        } catch (Exception e) {
+            throw new RuntimeException("Unexpected exception occured" , e);
+        }
+    }
+    
+    public void assertBlueprintNameSpacePublished(String namespace) {
+        assertServicePublished(String.format("(&(objectClass=%s)(osgi.service.blueprint.namespace='%s'))",

+                                             NamespaceHandler.class.getName(), namespace));
+    }
 }

Modified: cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1551914&r1=1551913&r2=1551914&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Wed Dec 18 11:14:13 2013
@@ -158,7 +158,7 @@
         <cxf.aries.version>1.0.0</cxf.aries.version>
         <cxf.aries.version.range>[1.0,2)</cxf.aries.version.range>
         <cxf.osgi.version>4.2.0</cxf.osgi.version>
-        <cxf.karaf.version>2.2.9</cxf.karaf.version>
+        <cxf.karaf.version>2.3.3</cxf.karaf.version>
         <cxf.pax.logging.version>1.6.0</cxf.pax.logging.version>
         <cxf.felix.framework.version>2.0.5</cxf.felix.framework.version>
         <cxf.felix.configadmin.version>1.2.4</cxf.felix.configadmin.version>



Mime
View raw message