cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [3/3] git commit: Add OSGi itests for soap/http and soap/jms
Date Wed, 30 Apr 2014 14:25:20 GMT
Add OSGi itests for soap/http and soap/jms


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

Branch: refs/heads/master
Commit: bf6da99ae38380a78c1e0ad55eddacb7b32b7e9b
Parents: b5e2667
Author: Christian Schneider <chris@die-schneider.net>
Authored: Wed Apr 30 16:24:59 2014 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Wed Apr 30 16:24:59 2014 +0200

----------------------------------------------------------------------
 osgi/itests/pom.xml                             |  46 +++---
 .../osgi/itests/BundlesAndNamespacesTest.java   |  10 +-
 .../cxf/osgi/itests/CXFOSGiTestSupport.java     | 161 +++++++++----------
 .../apache/cxf/osgi/itests/soap/Greeter.java    |  26 +++
 .../cxf/osgi/itests/soap/GreeterImpl.java       |  28 ++++
 .../cxf/osgi/itests/soap/HttpServiceTest.java   |  77 +++++++++
 .../cxf/osgi/itests/soap/HttpTestActivator.java |  44 +++++
 .../cxf/osgi/itests/soap/JmsServiceTest.java    |  86 ++++++++++
 .../cxf/osgi/itests/soap/JmsTestActivator.java  |  57 +++++++
 9 files changed, 422 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/pom.xml
----------------------------------------------------------------------
diff --git a/osgi/itests/pom.xml b/osgi/itests/pom.xml
index bd25526..174fc39 100644
--- a/osgi/itests/pom.xml
+++ b/osgi/itests/pom.xml
@@ -30,16 +30,27 @@
     <packaging>jar</packaging>
     <properties>
         <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.apache.cxf</groupId>
             <artifactId>cxf-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-jms</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         
+        <!-- Karaf features -->
         <dependency>
             <groupId>org.apache.cxf.karaf</groupId>
             <artifactId>apache-cxf</artifactId>
@@ -47,23 +58,14 @@
             <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>
-        	<exclusions>
-        	    <exclusion>
-        	      <groupId>org.eclipse</groupId>
-        	      <artifactId>osgi</artifactId>
-        	    </exclusion>
-        	    <exclusion>
-        	      <groupId>org.apache.xerces</groupId>
-        	      <artifactId>xercesImpl</artifactId>
-        	    </exclusion>
-        	</exclusions>
+        	<groupId>org.apache.activemq</groupId>
+        	<artifactId>activemq-karaf</artifactId>
+        	<version>5.9.1</version>
+        	<type>xml</type>
+        	<classifier>features</classifier>
         </dependency>
+        
         <dependency>
         	<groupId>org.apache.karaf.features</groupId>
         	<artifactId>org.apache.karaf.features.core</artifactId>
@@ -76,9 +78,12 @@
         </dependency>
         <dependency>
         	<groupId>org.osgi</groupId>
+        	<artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+        	<groupId>org.osgi</groupId>
         	<artifactId>org.osgi.compendium</artifactId>
         </dependency>
-        
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-atinject_1.0_spec</artifactId>
@@ -121,13 +126,6 @@
         </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>

http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
index c60cee5..d4dc925 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
@@ -19,9 +19,9 @@
 
 package org.apache.cxf.osgi.itests;
 
+
 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;
@@ -29,10 +29,9 @@ 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.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
 
+
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class BundlesAndNamespacesTest extends CXFOSGiTestSupport {
@@ -54,11 +53,6 @@ public class BundlesAndNamespacesTest extends CXFOSGiTestSupport {
     public Option[] config() {
         return new Option[]{
                 cxfBaseConfig(),
-                systemProperty("java.awt.headless").value("true"),
-
-                editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg", 
-                                         "org.ops4j.pax.url.mvn.localRepository",
-                                         System.getProperty("localRepository")),
                 logLevel(LogLevel.INFO)};
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
index 8ab8622..4e144de 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
@@ -20,6 +20,7 @@
 package org.apache.cxf.osgi.itests;
 
 
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
@@ -43,7 +44,6 @@ import org.apache.felix.service.command.CommandProcessor;
 import org.apache.felix.service.command.CommandSession;
 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;
@@ -57,25 +57,34 @@ import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 
+import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
 
 /**
  * 
  */
 public class CXFOSGiTestSupport {
+    static final String KARAF_VERSION = "2.3.5";
     static final Long COMMAND_TIMEOUT = 10000L;
     static final Long DEFAULT_TIMEOUT = 20000L;
     static final Long SERVICE_TIMEOUT = 30000L;
 
     @Inject
     protected BundleContext bundleContext;
-    
+
     @Inject
     protected FeaturesService featureService;
-    
-    ExecutorService executor = Executors.newCachedThreadPool();
+
+    protected ExecutorService executor = Executors.newCachedThreadPool();
+
+    protected MavenUrlReference cxfUrl;
+    protected MavenUrlReference karafUrl;
 
     /**
      * @param probe
@@ -89,35 +98,33 @@ public class CXFOSGiTestSupport {
 
     /**
      * Create an {@link org.ops4j.pax.exam.Option} for using a .
-     *
+     * 
      * @return
      */
     protected Option cxfBaseConfig() {
-        MavenUrlReference karafUrl = maven()
-            .groupId("org.apache.karaf")
-            .artifactId("apache-karaf")
-            .versionAsInProject()
+        karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version(KARAF_VERSION)
             .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/")),
-             features(cxfUrl, "cxf-core", "cxf-jaxws")
-        );
+        cxfUrl = maven().groupId("org.apache.cxf.karaf").artifactId("apache-cxf").versionAsInProject()
+            .type("xml").classifier("features");
+        String localRepo = System.getProperty("localRepository");
+        return composite(karafDistributionConfiguration()
+                             .frameworkUrl(karafUrl)
+                             .karafVersion(KARAF_VERSION)
+                             .name("Apache Karaf")
+                             .useDeployFolder(false)
+                             .unpackDirectory(new File("target/paxexam/")),
+                         keepRuntimeFolder(),
+                         features(cxfUrl, "cxf-core", "cxf-jaxws"),
+                         systemProperty("java.awt.headless").value("true"),
+                         when(localRepo != null)
+                             .useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
+                                                                  "org.ops4j.pax.url.mvn.localRepository",
+                                                                  localRepo)));
     }
 
     /**
-     * Executes a shell command and returns output as a String.
-     * Commands have a default timeout of 10 seconds.
-     *
+     * Executes a shell command and returns output as a String. Commands have a default timeout
of 10 seconds.
+     * 
      * @param command
      * @return
      */
@@ -126,12 +133,11 @@ public class CXFOSGiTestSupport {
     }
 
     /**
-     * Executes a shell command and returns output as a String.
-     * Commands have a default timeout of 10 seconds.
-     *
+     * Executes a shell command and returns output as a String. Commands have a default timeout
of 10 seconds.
+     * 
      * @param command The command to execute.
      * @param timeout The amount of time in millis to wait for the command to execute.
-     * @param silent  Specifies if the command should be displayed in the screen.
+     * @param silent Specifies if the command should be displayed in the screen.
      * @return
      */
     protected String executeCommand(final String command, final Long timeout, final Boolean
silent) {
@@ -139,23 +145,22 @@ public class CXFOSGiTestSupport {
         final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
         final PrintStream printStream = new PrintStream(byteArrayOutputStream);
         final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
-        final CommandSession commandSession 
-            = commandProcessor.createSession(System.in, printStream, System.err);
-        FutureTask<String> commandFuture = new FutureTask<String>(
-                new Callable<String>() {
-                    public String call() {
-                        try {
-                            if (!silent) {
-                                System.err.println(command);
-                            }
-                            commandSession.execute(command);
-                        } catch (Exception e) {
-                            e.printStackTrace(System.err);
-                        }
-                        printStream.flush();
-                        return byteArrayOutputStream.toString();
+        final CommandSession commandSession = commandProcessor.createSession(System.in, printStream,
+                                                                             System.err);
+        FutureTask<String> commandFuture = new FutureTask<String>(new Callable<String>()
{
+            public String call() {
+                try {
+                    if (!silent) {
+                        System.err.println(command);
                     }
-                });
+                    commandSession.execute(command);
+                } catch (Exception e) {
+                    e.printStackTrace(System.err);
+                }
+                printStream.flush();
+                return byteArrayOutputStream.toString();
+            }
+        });
 
         try {
             executor.submit(commandFuture);
@@ -169,9 +174,8 @@ public class CXFOSGiTestSupport {
     }
 
     /**
-     * Executes multiple commands inside a Single Session.
-     * Commands have a default timeout of 10 seconds.
-     *
+     * Executes multiple commands inside a Single Session. Commands have a default timeout
of 10 seconds.
+     * 
      * @param commands
      * @return
      */
@@ -180,22 +184,21 @@ public class CXFOSGiTestSupport {
         final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
         final PrintStream printStream = new PrintStream(byteArrayOutputStream);
         final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
-        final CommandSession commandSession 
-            = commandProcessor.createSession(System.in, printStream, System.err);
-        FutureTask<String> commandFuture = new FutureTask<String>(
-                new Callable<String>() {
-                    public String call() {
-                        try {
-                            for (String command : commands) {
-                                System.err.println(command);
-                                commandSession.execute(command);
-                            }
-                        } catch (Exception e) {
-                            e.printStackTrace(System.err);
-                        }
-                        return byteArrayOutputStream.toString();
+        final CommandSession commandSession = commandProcessor.createSession(System.in, printStream,
+                                                                             System.err);
+        FutureTask<String> commandFuture = new FutureTask<String>(new Callable<String>()
{
+            public String call() {
+                try {
+                    for (String command : commands) {
+                        System.err.println(command);
+                        commandSession.execute(command);
                     }
-                });
+                } catch (Exception e) {
+                    e.printStackTrace(System.err);
+                }
+                return byteArrayOutputStream.toString();
+            }
+        });
 
         try {
             executor.submit(commandFuture);
@@ -221,8 +224,8 @@ public class CXFOSGiTestSupport {
     }
 
     /*
-    * Explode the dictionary into a ,-delimited list of key=value pairs
-    */
+     * Explode the dictionary into a ,-delimited list of key=value pairs
+     */
     private static String explode(Dictionary<String, String> dictionary) {
         Enumeration<String> keys = dictionary.keys();
         StringBuffer result = new StringBuffer();
@@ -245,7 +248,7 @@ public class CXFOSGiTestSupport {
     }
 
     @SuppressWarnings({
-        "rawtypes", "unchecked"
+        "unchecked"
     })
     protected <T> T getOsgiService(Class<T> type, String filter, long timeout)
{
         ServiceTracker tracker = null;
@@ -287,10 +290,10 @@ public class CXFOSGiTestSupport {
             throw new RuntimeException(e);
         }
     }
-    
+
     /**
      * Finds a free port starting from the give port numner.
-     *
+     * 
      * @return
      */
     protected int getFreePort(int port) {
@@ -302,7 +305,7 @@ public class CXFOSGiTestSupport {
 
     /**
      * Returns true if port is available for use.
-     *
+     * 
      * @param port
      * @return
      */
@@ -316,7 +319,7 @@ public class CXFOSGiTestSupport {
             ds.setReuseAddress(true);
             return true;
         } catch (IOException e) {
-            //ignore
+            // ignore
         } finally {
             if (ds != null) {
                 ds.close();
@@ -337,17 +340,16 @@ 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();
+        return references != null ? Arrays.asList(references) : Collections.<ServiceReference>
emptyList();
     }
-    
+
     protected void assertBundleStarted(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)) {
@@ -356,10 +358,7 @@ public class CXFOSGiTestSupport {
         }
         return null;
     }
-    
-    @SuppressWarnings({
-        "rawtypes", "unchecked"
-    })
+
     public void assertServicePublished(String filter, int timeout) {
         try {
             Filter serviceFilter = bundleContext.createFilter(filter);
@@ -371,10 +370,10 @@ public class CXFOSGiTestSupport {
                 throw new IllegalStateException("Expected service with filter " + filter
+ " was not found");
             }
         } catch (Exception e) {
-            throw new RuntimeException("Unexpected exception occured" , e);
+            throw new RuntimeException("Unexpected exception occured", e);
         }
     }
-    
+
     public void assertBlueprintNamespacePublished(String namespace, int timeout) {
         assertServicePublished(String.format("(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)"
                                              + "(osgi.service.blueprint.namespace=%s))",
namespace), timeout);

http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/Greeter.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/Greeter.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/Greeter.java
new file mode 100644
index 0000000..51d0af9
--- /dev/null
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/Greeter.java
@@ -0,0 +1,26 @@
+/**
+ * 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.osgi.itests.soap;
+
+import javax.jws.WebService;
+
+@WebService
+public interface Greeter {
+    String greetMe(String name);
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/GreeterImpl.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/GreeterImpl.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/GreeterImpl.java
new file mode 100644
index 0000000..45261ba
--- /dev/null
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/GreeterImpl.java
@@ -0,0 +1,28 @@
+/**
+ * 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.osgi.itests.soap;
+
+public class GreeterImpl implements Greeter {
+
+    @Override
+    public String greetMe(String name) {
+        return "Hi " + name;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
new file mode 100644
index 0000000..8420a6a
--- /dev/null
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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.osgi.itests.soap;
+
+import java.io.InputStream;
+
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.osgi.itests.CXFOSGiTestSupport;
+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.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Constants;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class HttpServiceTest extends CXFOSGiTestSupport {
+
+    @Test
+    public void testHttpEndpoint() throws Exception {
+        Greeter greeter = greeterHttp();
+        String res = greeter.greetMe("Chris");
+        Assert.assertEquals("Hi Chris", res);
+    }
+    
+    private Greeter greeterHttp() {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(Greeter.class);
+        factory.setAddress("http://localhost:8181/cxf/greeter");
+        return factory.create(Greeter.class);
+    }
+    
+    @Configuration
+    public Option[] config() {
+        return new Option[] {
+            cxfBaseConfig(),
+            logLevel(LogLevel.INFO),
+            features(cxfUrl, "cxf-http"),
+            provision(serviceBundle())
+        };
+    }
+
+    private InputStream serviceBundle() {
+        return TinyBundles.bundle()
+                  .add(HttpTestActivator.class)
+                  .add(Greeter.class)
+                  .add(GreeterImpl.class)
+                  .set(Constants.BUNDLE_ACTIVATOR, HttpTestActivator.class.getName())
+                  .build(TinyBundles.withBnd());
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java
b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java
new file mode 100644
index 0000000..5082508
--- /dev/null
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.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.osgi.itests.soap;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class HttpTestActivator implements BundleActivator {
+
+    private Server server;
+
+    @Override
+    public void start(BundleContext arg0) throws Exception {
+        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+        factory.setServiceClass(Greeter.class);
+        factory.setAddress("/greeter");
+        factory.setServiceBean(new GreeterImpl());
+        server = factory.create();
+    }
+
+    @Override
+    public void stop(BundleContext arg0) throws Exception {
+        server.destroy();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
new file mode 100644
index 0000000..31cce39
--- /dev/null
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
@@ -0,0 +1,86 @@
+/**
+ * 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.osgi.itests.soap;
+
+import java.io.InputStream;
+import java.util.Collections;
+
+import org.apache.activemq.spring.ActiveMQConnectionFactory;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.osgi.itests.CXFOSGiTestSupport;
+import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
+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.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.options.MavenUrlReference;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Constants;
+
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class JmsServiceTest extends CXFOSGiTestSupport {
+
+    @Test
+    public void testJmsEndpoint() throws Exception {
+        Greeter greeter = greeterJms();
+        String res = greeter.greetMe("Chris");
+        Assert.assertEquals("Hi Chris", res);
+    }
+
+    private Greeter greeterJms() {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(Greeter.class);
+        factory.setAddress("jms:queue:greeter");
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
+        connectionFactory.setUserName("karaf");
+        connectionFactory.setPassword("karaf");
+        factory.setFeatures(Collections.singletonList(new ConnectionFactoryFeature(connectionFactory)));
+        return factory.create(Greeter.class);
+    }
+
+    @Configuration
+    public Option[] config() {
+        MavenUrlReference activeMQFeature = maven().groupId("org.apache.activemq")
+            .artifactId("activemq-karaf").type("xml").classifier("features").versionAsInProject();
+        return new Option[] {
+            cxfBaseConfig(),
+            logLevel(LogLevel.INFO),
+            features(activeMQFeature, "activemq-broker-noweb"),
+            features(cxfUrl, "cxf-transports-jms"),
+            provision(serviceBundle())
+        };
+    }
+
+    private InputStream serviceBundle() {
+        return TinyBundles.bundle().add(JmsTestActivator.class).add(Greeter.class).add(GreeterImpl.class)
+            .set(Constants.BUNDLE_ACTIVATOR, JmsTestActivator.class.getName()).build(TinyBundles.withBnd());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/bf6da99a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsTestActivator.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsTestActivator.java
b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsTestActivator.java
new file mode 100644
index 0000000..c04fcbe
--- /dev/null
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsTestActivator.java
@@ -0,0 +1,57 @@
+/**
+ * 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.osgi.itests.soap;
+
+import java.util.Collections;
+
+import org.apache.activemq.spring.ActiveMQConnectionFactory;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class JmsTestActivator implements BundleActivator {
+    private Server server;
+
+    @Override
+    public void start(BundleContext bc) throws Exception {
+        /*
+        ServiceTracker tracker = new ServiceTracker(bc, ConnectionFactory.class.getName(),
null);
+        */
+        // This can block the activator. Use an async approach in production code
+        /*
+        ConnectionFactory connectionFactory = (ConnectionFactory)tracker.getService();
+        */
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
+        connectionFactory.setUserName("karaf");
+        connectionFactory.setPassword("karaf");
+        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+        factory.setServiceClass(Greeter.class);
+        factory.setAddress("jms:queue:greeter");
+        factory.setFeatures(Collections.singletonList(new ConnectionFactoryFeature(connectionFactory)));
+        factory.setServiceBean(new GreeterImpl());
+        server = factory.create();
+    }
+
+    @Override
+    public void stop(BundleContext arg0) throws Exception {
+        server.destroy();
+    }
+}


Mime
View raw message