servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r1476158 - in /servicemix/smx5/trunk: assemblies/apache-servicemix/src/main/filtered-resources/ examples/cxf/cxf-osgi/ examples/cxf/cxf-ws-addressing/ examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/wsaddress...
Date Fri, 26 Apr 2013 12:12:53 GMT
Author: gertv
Date: Fri Apr 26 12:12:48 2013
New Revision: 1476158

URL: http://svn.apache.org/r1476158
Log:
SM-2195: Add integration tests for CXF examples

Added:
    servicemix/smx5/trunk/itests/src/test/resources/OSGI-INF/
    servicemix/smx5/trunk/itests/src/test/resources/OSGI-INF/blueprint/
    servicemix/smx5/trunk/itests/src/test/resources/OSGI-INF/blueprint/blueprint.xml
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/CamelTestSupport.scala
Modified:
    servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
    servicemix/smx5/trunk/examples/cxf/cxf-osgi/pom.xml
    servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/pom.xml
    servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/wsaddressing/Client.java
    servicemix/smx5/trunk/examples/cxf/cxf-ws-security-signature/pom.xml
    servicemix/smx5/trunk/itests/pom.xml
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTest.scala
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala
    servicemix/smx5/trunk/parent/pom.xml

Modified: servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
(original)
+++ servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
Fri Apr 26 12:12:48 2013
@@ -89,6 +89,7 @@
         <feature version="${cxf.version}">cxf</feature>
         <bundle dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jbi-api-1.0/${servicemix.specs.version}</bundle>
         <bundle dependency="true">mvn:org.springframework/spring-beans/${spring.version}</bundle>
+        <bundle dependency="true">mvn:commons-io/commons-io/${commons-io.version}</bundle>
         <bundle>mvn:org.apache.servicemix.examples/cxf-ws-addressing/${version}</bundle>
     </feature>
     <feature name="examples-cxf-ws-security-osgi" version="${version}" resolver="(obr)">

Modified: servicemix/smx5/trunk/examples/cxf/cxf-osgi/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/cxf/cxf-osgi/pom.xml?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/cxf/cxf-osgi/pom.xml (original)
+++ servicemix/smx5/trunk/examples/cxf/cxf-osgi/pom.xml Fri Apr 26 12:12:48 2013
@@ -66,7 +66,6 @@
                             javax.jws,
                             javax.wsdl,
                             javax.xml.namespace,
-                            org.apache.servicemix.util,
                             org.springframework.beans.factory.config,
                             *
                         </Import-Package>

Modified: servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/pom.xml?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/pom.xml (original)
+++ servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/pom.xml Fri Apr 26 12:12:48 2013
@@ -48,9 +48,8 @@
             <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.servicemix</groupId>
-            <artifactId>servicemix-utils</artifactId>
-            <version>1.5.0</version>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
         </dependency>
     </dependencies>
 
@@ -106,10 +105,10 @@
                             org.apache.cxf.interceptor,
                             org.apache.cxf.ws.addressing,
                             org.apache.cxf.ws.addressing.soap,
-                            org.apache.servicemix.util,
                             org.apache.cxf.message, 
                             org.apache.cxf.phase,
-                            org.springframework.beans.factory.config
+                            org.springframework.beans.factory.config,
+                            *
                         </Import-Package>
                         <Export-Package>
                             org.apache.servicemix.examples.cxf.wsaddressing,

Modified: servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/wsaddressing/Client.java
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/wsaddressing/Client.java?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/wsaddressing/Client.java
(original)
+++ servicemix/smx5/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/wsaddressing/Client.java
Fri Apr 26 12:12:48 2013
@@ -19,11 +19,11 @@ package org.apache.servicemix.examples.c
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
 
-import org.apache.servicemix.util.FileUtil;
+import org.apache.commons.io.IOUtils;
+
 
 public class Client{
     public static void main(String[] args) {
@@ -42,11 +42,11 @@ public class Client{
         OutputStream os = connection.getOutputStream();
         // Post the request file.
         InputStream fis = getClass().getClassLoader().getResourceAsStream("org/apache/servicemix/examples/cxf/wsaddressing/request.xml");
-        FileUtil.copyInputStream(fis, os);
+        IOUtils.copy(fis, os);
         // Read the response.
         InputStream is = connection.getInputStream();
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        FileUtil.copyInputStream(is, baos);
+        IOUtils.copy(is, baos);
         System.out.println("the response is =====>");
         System.out.println(baos.toString());
     }

Modified: servicemix/smx5/trunk/examples/cxf/cxf-ws-security-signature/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/cxf/cxf-ws-security-signature/pom.xml?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/cxf/cxf-ws-security-signature/pom.xml (original)
+++ servicemix/smx5/trunk/examples/cxf/cxf-ws-security-signature/pom.xml Fri Apr 26 12:12:48
2013
@@ -73,10 +73,9 @@
                             org.springframework.beans.factory.config,
                             javax.security.auth.callback,
                             org.apache.ws.security,
-                            org.apache.servicemix.util,
                             org.apache.ws.security.processor,
                             org.apache.cxf.binding.soap.saaj,
-			    org.apache.commons.io
+			                      org.apache.commons.io
                         </Import-Package>
                         <Export-Package>org.apache.servicemix.examples.cxf</Export-Package>
                         <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>

Modified: servicemix/smx5/trunk/itests/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/pom.xml?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/itests/pom.xml (original)
+++ servicemix/smx5/trunk/itests/pom.xml Fri Apr 26 12:12:48 2013
@@ -119,6 +119,11 @@
           </exclusion>
         </exclusions>
       </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-core-osgi</artifactId>
+        <scope>test</scope>
+      </dependency>
     </dependencies>
 
   <build>
@@ -154,7 +159,6 @@
           <execution>
             <id>compile</id>
             <goals>
-              <goal>compile</goal>
               <goal>testCompile</goal>
             </goals>
           </execution>

Added: servicemix/smx5/trunk/itests/src/test/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/src/test/resources/OSGI-INF/blueprint/blueprint.xml?rev=1476158&view=auto
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ servicemix/smx5/trunk/itests/src/test/resources/OSGI-INF/blueprint/blueprint.xml Fri Apr
26 12:12:48 2013
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+  <camelContext id="context" xmlns="http://camel.apache.org/schema/blueprint" />
+
+  <bean class="org.apache.servicemix.itests.CamelContextHolder" factory-method="apply">
+    <argument ref="context"/>
+  </bean>
+
+</blueprint>
\ No newline at end of file

Added: servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/CamelTestSupport.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/CamelTestSupport.scala?rev=1476158&view=auto
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/CamelTestSupport.scala
(added)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/CamelTestSupport.scala
Fri Apr 26 12:12:48 2013
@@ -0,0 +1,54 @@
+/**
+ * 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.servicemix.itests
+
+import org.apache.camel.impl.DefaultProducerTemplate
+import org.apache.camel.{ProducerTemplate, CamelContext}
+
+/**
+ * Provides access to a Camel context and producer to use for integration testing.
+ */
+trait CamelTestSupport extends Await {
+
+  def camelContext = await(CamelContextHolder.context)
+
+  lazy val camelProducer : ProducerTemplate = {
+    val producer = new DefaultProducerTemplate(camelContext.getOrElse(throw new RuntimeException("Gave
up waiting for a CamelContext")))
+    producer.start()
+    producer
+  }
+
+  /**
+   * Convenience method to perform a Camel request and return a String
+   */
+  def requestString(url: String) : String = camelProducer.requestBody(url, null, classOf[String])
+
+}
+
+/**
+ * Singleton object that gets a CamelContext injected through Blueprint
+ */
+object CamelContextHolder {
+
+  var context: Option[CamelContext] = None
+
+  def apply(c: CamelContext) = {
+    context = Option(c)
+    context
+  }
+
+}

Modified: servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTest.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTest.scala?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTest.scala
(original)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTest.scala
Fri Apr 26 12:12:48 2013
@@ -22,13 +22,14 @@ import org.ops4j.pax.exam.junit.ExamReac
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactorFactory
 import org.junit.{Ignore, Test}
+import org.junit.Assert.{assertTrue,assertNotNull}
 
 /**
  * Tests cases for the examples
  */
 @RunWith(classOf[JUnit4TestRunner])
 @ExamReactorStrategy(Array(classOf[EagerSingleStagedReactorFactory]))
-class ExamplesIntegrationTest extends IntegrationTestSupport {
+class ExamplesIntegrationTest extends IntegrationTestSupport with CamelTestSupport {
 
   @Configuration
   def config() = servicemixTestConfiguration() ++ scalaTestConfiguration
@@ -36,7 +37,7 @@ class ExamplesIntegrationTest extends In
   @Test
   @Ignore("Example currently does not install, cfr. https://issues.apache.org/jira/browse/SM-2183")
   def testActiveMQCamelBlueprintExample = testWithFeature("examples-activemq-camel-blueprint")
{
-    expect("log messages for activemq-camel-blueprint example") {
+    expect {
       logging.containsMessage(line => line.contains("ActiveMQ-Blueprint-Example set body"))
     }
   }
@@ -44,25 +45,72 @@ class ExamplesIntegrationTest extends In
   @Test
   @Ignore("Example requires more PermGen memory than the default, cfr. https://issues.apache.org/jira/browse/SM-2187")
   def testCamelDroolsExample = testWithFeature("examples-camel-drools") {
-    expect("log messages for activemq-camel-blueprint example") {
+    expect {
       logging.containsEvent( _.getLoggerName == "ServeDrink" )
     }
   }
 
   @Test
   def testCamelOsgiExample : Unit = testWithFeature("examples-camel-osgi") {
-    expect("log messages for camel-osgi (Java DSL) example") {
+    expect {
       logging.containsMessage(line => line.contains("JavaDSL set body"))
     }
-    expect("log messages for camel-osgi (Spring DSL) example") {
+    expect {
       logging.containsMessage(line => line.contains("MyTransform set body"))
     }
   }
 
   @Test
   def testCamelBlueprintExample : Unit = testWithFeature("examples-camel-blueprint") {
-    expect("log messages for camel-blueprint example") {
+    expect {
       logging.containsMessage(line => line.contains("Blueprint-Example set body"))
     }
   }
+
+  @Test
+  def testCxfJaxRsExample = testWithFeature("examples-cxf-jaxrs", "camel-http") {
+    expect { logging.containsMessage( _.contains("Setting the server's publish address to
be /crm")) }
+    // TODO: the service appears to be started, but the URLs are not accessible
+    // assertTrue(httpGet("http://localhost:8181/cxf/crm/customerservice/customers/123").contains("<Customer><id>123</id>"))
+  }
+
+  @Test
+  def testCxfJaxRsBlueprintExample = testWithFeature("examples-cxf-jaxrs-blueprint", "camel-http4")
{
+    expect { logging.containsMessage( _.contains("Setting the server's publish address to
be /crm")) }
+    assertTrue(requestString("http4://localhost:8181/cxf/crm/customerservice/customers/123").contains("<Customer><id>123</id>"))
+  }
+
+  @Test
+  def testCxfJaxWsBlueprintExample = testWithFeature("examples-cxf-jaxws-blueprint", "camel-http4")
{
+    expect { logging.containsMessage( _.contains("Setting the server's publish address to
be /HelloWorld")) }
+    // TODO: uncomment this once
+    // assertNotNull(requestString("http4://localhost:8181/cxf/HelloWorld?wsdl"))
+  }
+
+  @Test
+  def testCxfOsgi = testWithFeature("examples-cxf-osgi") {
+    expect { logging.containsMessage( _.contains("Setting the server's publish address to
be /HelloWorld")) }
+  }
+
+  @Test
+  def testCxfWsRm = testWithFeature("examples-cxf-ws-rm") {
+    expect { logging.containsMessage( _.contains("Setting the server's publish address to
be /HelloWorld")) }
+  }
+
+  @Test
+  def testCxfWsSecurityBlueprint = testWithFeature("examples-cxf-ws-security-blueprint")
{
+    expect { logging.containsMessage( _.contains("Setting the server's publish address to
be /HelloWorldSecurity")) }
+  }
+
+  @Test
+  def testCxfWsSecurityOsgi = testWithFeature("examples-cxf-ws-security-osgi") {
+    expect { logging.containsMessage( _.contains("Setting the server's publish address to
be /HelloWorldSecurity")) }
+  }
+
+  @Test
+  def testCxfWsSecuritySignature = testWithFeature("examples-cxf-ws-security-signature")
{
+    expect { logging.containsMessage( _.contains("Setting the server's publish address to
be /HelloWorldSecurity")) }
+  }
+
+
 }

Modified: servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala
(original)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala
Fri Apr 26 12:12:48 2013
@@ -59,5 +59,4 @@ trait IntegrationTestConfigurations {
       editConfigurationFilePut("etc/org.ops4j.pax.logging.cfg", "log4j.rootLogger", "DEBUG,stdout,osgi:*"))
   }
 
-
 }

Modified: servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala
(original)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala
Fri Apr 26 12:12:48 2013
@@ -20,12 +20,16 @@ import javax.inject.Inject
 import org.osgi.framework.{ServiceRegistration, BundleContext}
 import java.io.File
 import scala.Some
-import org.junit.After
+import org.junit.{Before, BeforeClass, After}
 import org.ops4j.pax.logging.spi.{PaxLoggingEvent, PaxAppender}
 import collection.mutable.ArrayBuffer
 import java.util.Hashtable
 import org.junit.Assert.fail
-import org.apache.karaf.features.FeaturesService
+import org.apache.karaf.features.{Feature, FeaturesService}
+import scala.collection.JavaConversions.setAsJavaSet
+import java.util
+// allow for postfix notation
+import scala.language.postfixOps
 
 /**
  * Base class for building Apache ServiceMix integration tests
@@ -44,7 +48,7 @@ abstract class IntegrationTestSupport ex
   val registrations = ArrayBuffer.empty[ServiceRegistration[_]]
 
   @After
-  def afterTest : Unit = registrations dropWhile { registration => registration.unregister;
true }
+  def clearLogging = logging.clear
 
   /*
    * A set of convenience vals for referring to directories within the test container
@@ -57,20 +61,22 @@ abstract class IntegrationTestSupport ex
   /**
    * Install a feature and run a block of code.  Afterwards, uninstall the feature again.
    */
-  def testWithFeature(feature: String)(block: => Unit) =
+  def testWithFeature(names: String*)(block: => Unit) =
     try {
-      featuresService.installFeature(feature)
+      val features : Set[Feature] = ( names map { name => featuresService.getFeature(name)
} toSet )
+      //TODO: Get this working without the extra options - enabling bundle refresh here will
mess up the test container
+      featuresService.installFeatures(features, util.EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles))
       block
     } finally {
-      featuresService.uninstallFeature(feature)
+      names foreach { featuresService.uninstallFeature }
     }
 
 
   /**
    * Expect a certain condition to occur within the allotted waiting time.
    */
-  def expect[T](message: String)(block: => Option[T]) : Unit = await(block) match {
-    case None => fail(s"Gave up waiting for ${message}")
+  def expect[T](block: => Option[T]) : Unit = await(block) match {
+    case None => fail(s"Gave up waiting for test condition")
     case _    => //graciously ignore
   }
 

Modified: servicemix/smx5/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/parent/pom.xml?rev=1476158&r1=1476157&r2=1476158&view=diff
==============================================================================
--- servicemix/smx5/trunk/parent/pom.xml (original)
+++ servicemix/smx5/trunk/parent/pom.xml Fri Apr 26 12:12:48 2013
@@ -39,7 +39,7 @@
   <properties>
     <activemq.version>5.8.0</activemq.version>
     <activiti.version>5.10</activiti.version>
-    <camel.version>2.11-SNAPSHOT</camel.version>
+    <camel.version>2.11.0</camel.version>
     <cxf.version>2.7.4</cxf.version>
 
     <felix.obr.version>1.6.6</felix.obr.version>



Mime
View raw message