servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r1466476 - in /servicemix/smx5/trunk: assemblies/apache-servicemix/src/main/filtered-resources/ assemblies/shared/src/main/resources/etc/ itests/ itests/cxf-handler-cfg/ itests/cxf-http-osgi/ itests/cxf-jms-osgi/ itests/cxf-mtom-osgi/ itest...
Date Wed, 10 Apr 2013 13:18:58 GMT
Author: gertv
Date: Wed Apr 10 13:18:57 2013
New Revision: 1466476

URL: http://svn.apache.org/r1466476
Log:
SM-2195: Rewrite features itests using pax-exam-karaf

Added:
    servicemix/smx5/trunk/itests/src/
    servicemix/smx5/trunk/itests/src/test/
    servicemix/smx5/trunk/itests/src/test/resources/
    servicemix/smx5/trunk/itests/src/test/resources/log4j.properties
      - copied, changed from r1466311, servicemix/smx5/trunk/itests/tests/src/test/resources/log4j.properties
    servicemix/smx5/trunk/itests/src/test/scala/
    servicemix/smx5/trunk/itests/src/test/scala/org/
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/Await.scala
    servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/BasicAssemblyTests.scala
    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
Removed:
    servicemix/smx5/trunk/itests/cxf-handler-cfg/
    servicemix/smx5/trunk/itests/cxf-http-osgi/
    servicemix/smx5/trunk/itests/cxf-jms-osgi/
    servicemix/smx5/trunk/itests/cxf-mtom-osgi/
    servicemix/smx5/trunk/itests/cxf-soap-handler-osgi/
    servicemix/smx5/trunk/itests/cxf-ws-security-osgi/
    servicemix/smx5/trunk/itests/test-commons/
    servicemix/smx5/trunk/itests/tests/
Modified:
    servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
    servicemix/smx5/trunk/assemblies/shared/src/main/resources/etc/system.properties
    servicemix/smx5/trunk/itests/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=1466476&r1=1466475&r2=1466476&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
Wed Apr 10 13:18:57 2013
@@ -161,6 +161,9 @@
         <bundle dependency="true">mvn:org.apache.aries.transaction/org.apache.aries.transaction.manager/${aries.transaction.version}</bundle>
         <bundle dependency="true">mvn:org.apache.aries/org.apache.aries.util/${aries.version}</bundle>
 
+        <!-- Camel JMS is required to get ActiveMQ's Camel component started -->
+        <feature version="${camel.version}">camel-jms</feature>
+
         <!-- the following 4 bundles is needed by activemq-console -->
         <bundle dependency="true">mvn:org.fusesource.hawtbuf/hawtbuf/${hawtbuf.version}</bundle>
         <bundle dependency="true">mvn:org.fusesource.hawtbuf/hawtbuf-proto/${hawtbuf.version}</bundle>

Modified: servicemix/smx5/trunk/assemblies/shared/src/main/resources/etc/system.properties
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/assemblies/shared/src/main/resources/etc/system.properties?rev=1466476&r1=1466475&r2=1466476&view=diff
==============================================================================
--- servicemix/smx5/trunk/assemblies/shared/src/main/resources/etc/system.properties (original)
+++ servicemix/smx5/trunk/assemblies/shared/src/main/resources/etc/system.properties Wed Apr
10 13:18:57 2013
@@ -121,3 +121,12 @@ org.apache.cxf.Logger=org.apache.cxf.com
 
 # Workaround for KARAF-1117: Jetty will use a JUL logger.
 org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog
+
+#
+# Settings for the OSGi 4.3 Weaving
+# By default, we will not weave any classes. Change this setting to include classes
+# that you application needs to have woven.
+#
+org.apache.aries.proxy.weaving.enabled=none
+# Classes not to weave - Aries default + Xerces which is known to have issues.
+org.apache.aries.proxy.weaving.disabled=org.objectweb.asm.*,org.slf4j.*,org.apache.log4j.*,javax.*,org.apache.xerces.*
\ No newline at end of file

Modified: servicemix/smx5/trunk/itests/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/pom.xml?rev=1466476&r1=1466475&r2=1466476&view=diff
==============================================================================
--- servicemix/smx5/trunk/itests/pom.xml (original)
+++ servicemix/smx5/trunk/itests/pom.xml Wed Apr 10 13:18:57 2013
@@ -30,18 +30,138 @@
 
     <groupId>org.apache.servicemix.itests</groupId>
     <artifactId>itests</artifactId>
-    <packaging>pom</packaging>
     <name>Apache ServiceMix :: Integration Tests</name>
 
-    <modules>
-        <module>test-commons</module>
-        <module>cxf-http-osgi</module>
-        <module>cxf-ws-security-osgi</module>
-        <module>cxf-jms-osgi</module>
-        <module>cxf-soap-handler-osgi</module>
-        <module>cxf-handler-cfg</module>
-        <module>cxf-mtom-osgi</module>
-        <module>tests</module>
-    </modules>
+  <properties>
+    <pax-exam-version>2.6.0</pax-exam-version>
+  </properties>
+
+    <dependencies>
+      <dependency>
+        <groupId>org.scala-lang</groupId>
+        <artifactId>scala-library</artifactId>
+        <version>${scala.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.scala-library</artifactId>
+        <version>${scala.bundle.version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.karaf.tooling.exam</groupId>
+        <artifactId>org.apache.karaf.tooling.exam.container</artifactId>
+        <version>${karaf.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>4.11</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-log4j12</artifactId>
+        <scope>test</scope>
+      </dependency>
+
+      <dependency>
+        <groupId>org.ops4j.pax.logging</groupId>
+        <artifactId>pax-logging-service</artifactId>
+        <scope>test</scope>
+      </dependency>
+
+      <dependency>
+        <groupId>org.ops4j.pax.exam</groupId>
+        <artifactId>pax-exam-junit4</artifactId>
+        <version>${pax-exam-version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.karaf.features</groupId>
+        <artifactId>org.apache.karaf.features.core</artifactId>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicemix</groupId>
+        <artifactId>apache-servicemix</artifactId>
+        <version>${project.version}</version>
+        <type>tar.gz</type>
+        <exclusions>
+          <exclusion>
+            <groupId>org.apache.karaf</groupId>
+            <artifactId>apache-karaf</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicemix</groupId>
+        <artifactId>apache-servicemix-minimal</artifactId>
+        <version>${project.version}</version>
+        <type>zip</type>
+        <exclusions>
+          <exclusion>
+            <groupId>org.apache.karaf</groupId>
+            <artifactId>apache-karaf</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.servicemix</groupId>
+        <artifactId>apache-servicemix-full</artifactId>
+        <version>${project.version}</version>
+        <type>zip</type>
+        <exclusions>
+          <exclusion>
+            <groupId>org.apache.karaf</groupId>
+            <artifactId>apache-karaf</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+    </dependencies>
+
+  <build>
+    <plugins>
+      <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>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.14</version>
+        <configuration>
+          <redirectTestOutputToFile>true</redirectTestOutputToFile>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.scala-tools</groupId>
+        <artifactId>maven-scala-plugin</artifactId>
+        <version>2.15.2</version>
+        <executions>
+          <execution>
+            <id>compile</id>
+            <goals>
+              <goal>compile</goal>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+
+  </build>
 
 </project>

Copied: servicemix/smx5/trunk/itests/src/test/resources/log4j.properties (from r1466311, servicemix/smx5/trunk/itests/tests/src/test/resources/log4j.properties)
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/src/test/resources/log4j.properties?p2=servicemix/smx5/trunk/itests/src/test/resources/log4j.properties&p1=servicemix/smx5/trunk/itests/tests/src/test/resources/log4j.properties&r1=1466311&r2=1466476&rev=1466476&view=diff
==============================================================================
--- servicemix/smx5/trunk/itests/tests/src/test/resources/log4j.properties (original)
+++ servicemix/smx5/trunk/itests/src/test/resources/log4j.properties Wed Apr 10 13:18:57 2013
@@ -1,34 +1,33 @@
-#
-#    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.
-#
-################################################################################
-
-log4j.rootLogger=DEBUG, stdout
-
-log4j.logger.org.springframework.osgi=DEBUG
-log4j.logger.org.apache.camel=DEBUG
-log4j.logger.org.apache.servicemix=DEBUG
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
-
-log4j.appender.out=org.apache.log4j.FileAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-log4j.appender.out.file=target/servicemix-test.log
-log4j.appender.out.append=true
-
+#
+#    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.
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, stdout, out
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/itests.log
+log4j.appender.out.append=true

Added: servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/Await.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/Await.scala?rev=1466476&view=auto
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/Await.scala (added)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/Await.scala Wed
Apr 10 13:18:57 2013
@@ -0,0 +1,36 @@
+/**
+ * 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
+
+/**
+ * Convenience trait to wait for a certain condition to occur by retrying it a few times,
+ * using an exponential back-off delay scheme
+ */
+trait Await {
+
+  val INITIAL_DELAY = 125;
+  val MAXIMUM_DELAY = 8000;
+
+  def await[T](condition: => Option[T]) : Option[T] = await(condition, INITIAL_DELAY)
+
+  private[this] def await[T](condition: => Option[T], delay: Long) : Option[T] =
+    if (delay > MAXIMUM_DELAY) None else condition match {
+      case result @ Some(_) => result
+      case None             => Thread.sleep(delay); await(condition, delay * 2);
+    }
+
+}

Added: servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/BasicAssemblyTests.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/BasicAssemblyTests.scala?rev=1466476&view=auto
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/BasicAssemblyTests.scala
(added)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/BasicAssemblyTests.scala
Wed Apr 10 13:18:57 2013
@@ -0,0 +1,82 @@
+/**
+ * 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.junit.Test;
+import org.junit.runner.RunWith;
+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.EagerSingleStagedReactorFactory
+
+import org.junit.Assert._
+import io.Source
+import org.osgi.framework.Bundle
+
+/**
+ * A set of quick sanity checks to be run for all three types of container packaging we offer
(default, minimal and full)
+ */
+trait BasicAssemblyTests { self: IntegrationTestSupport =>
+
+  def isActive(bundle: Bundle) = Bundle.ACTIVE == bundle.getState
+  def isResolved(bundle: Bundle) = Bundle.RESOLVED == bundle.getState
+  def isFragment(bundle: Bundle) = bundle.getHeaders("Fragement-Host").isEmpty
+
+
+  @Test
+  def testInitialBundlesStarted = {
+    val failed = context.getBundles filterNot { bundle => isActive(bundle) || (isResolved(bundle)
&& isFragment(bundle))}
+    assertTrue(s"There should be no failed bundles - found ${failed.mkString}", failed.isEmpty)
+  }
+
+  @Test
+  def noErrorsInTheLog = {
+    val errors = Source.fromFile(logFile).getLines filter { line =>
+      line.toLowerCase.contains("error") || line.toLowerCase.contains("exception")
+    }
+    assertTrue(s"There should be no errors in the log file - found ${errors.mkString}", errors.isEmpty)
+  }
+
+}
+
+@RunWith(classOf[JUnit4TestRunner])
+@ExamReactorStrategy(Array(classOf[EagerSingleStagedReactorFactory]))
+class MinimalAssemblyTest extends IntegrationTestSupport with BasicAssemblyTests {
+
+  @Configuration
+  def config() = servicemixTestConfiguration("minimal") ++ scalaTestConfiguration
+
+
+}
+
+@RunWith(classOf[JUnit4TestRunner])
+@ExamReactorStrategy(Array(classOf[EagerSingleStagedReactorFactory]))
+class DefaultAssemblyTest extends IntegrationTestSupport with BasicAssemblyTests {
+
+  @Configuration
+  def config() = servicemixTestConfiguration() ++ scalaTestConfiguration
+
+}
+
+@RunWith(classOf[JUnit4TestRunner])
+@ExamReactorStrategy(Array(classOf[EagerSingleStagedReactorFactory]))
+class FullAssemblyTest extends IntegrationTestSupport with BasicAssemblyTests {
+
+  @Configuration
+  def config() = servicemixTestConfiguration("full") ++ scalaTestConfiguration
+
+}
\ No newline at end of file

Added: 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=1466476&view=auto
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTest.scala
(added)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTest.scala
Wed Apr 10 13:18:57 2013
@@ -0,0 +1,68 @@
+/**
+ * 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.junit.runner.RunWith;
+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.EagerSingleStagedReactorFactory
+import org.junit.{Ignore, Test}
+
+/**
+ * Tests cases for the examples
+ */
+@RunWith(classOf[JUnit4TestRunner])
+@ExamReactorStrategy(Array(classOf[EagerSingleStagedReactorFactory]))
+class ExamplesIntegrationTest extends IntegrationTestSupport {
+
+  @Configuration
+  def config() = servicemixTestConfiguration() ++ scalaTestConfiguration
+
+  @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") {
+      logging.containsMessage(line => line.contains("ActiveMQ-Blueprint-Example set body"))
+    }
+  }
+
+  @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") {
+      logging.containsEvent( _.getLoggerName == "ServeDrink" )
+    }
+  }
+
+  @Test
+  def testCamelOsgiExample : Unit = testWithFeature("examples-camel-osgi") {
+    expect("log messages for camel-osgi (Java DSL) example") {
+      logging.containsMessage(line => line.contains("JavaDSL set body"))
+    }
+    expect("log messages for camel-osgi (Spring DSL) example") {
+      logging.containsMessage(line => line.contains("MyTransform set body"))
+    }
+  }
+
+  @Test
+  def testCamelBlueprintExample : Unit = testWithFeature("examples-camel-blueprint") {
+    expect("log messages for camel-blueprint example") {
+      logging.containsMessage(line => line.contains("Blueprint-Example set body"))
+    }
+  }
+}

Added: 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=1466476&view=auto
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala
(added)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala
Wed Apr 10 13:18:57 2013
@@ -0,0 +1,63 @@
+/**
+ * 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 scala.Array
+import org.ops4j.pax.exam.CoreOptions._
+import org.apache.karaf.tooling.exam.options.KarafDistributionOption._
+import scala.Some
+import java.io.File
+
+/**
+ * Pax-Exam-Karaf configurations for integration testing
+ */
+trait IntegrationTestConfigurations {
+
+  /**
+   * The default integration test configuration, using Scala and the Apache ServiceMix default
assembly
+   */
+  def defaultIntegrationTestConfiguration = servicemixTestConfiguration() ++ scalaTestConfiguration
+
+  /**
+   * Add support for Scala-based integration tests
+   */
+  def scalaTestConfiguration =
+    Array(mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.scala-library").versionAsInProject())
+
+  /**
+   * Add an Apache ServiceMix container configuration
+   */
+  def servicemixTestConfiguration(variant: String = null) = {
+    val name = Option(variant).getOrElse("default")
+    val artifact = Option(variant) match {
+      case Some(value) => s"apache-servicemix-${value}"
+      case None        => "apache-servicemix"
+    }
+
+    Array(
+      karafDistributionConfiguration().
+        frameworkUrl(
+        maven().groupId("org.apache.servicemix").artifactId(artifact).`type`("tar.gz").versionAsInProject()).
+        karafVersion("2.3.1").name("Apache ServiceMix (${name})").
+        unpackDirectory(new File(s"target/pax-exam/${artifact}")),
+      keepRuntimeFolder(),
+      // TODO: investigate why we need this to get Pax Logging going again
+      editConfigurationFilePut("etc/org.ops4j.pax.logging.cfg", "log4j.rootLogger", "DEBUG,stdout,osgi:*"))
+  }
+
+
+}

Added: 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=1466476&view=auto
==============================================================================
--- servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala
(added)
+++ servicemix/smx5/trunk/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala
Wed Apr 10 13:18:57 2013
@@ -0,0 +1,111 @@
+/**
+ * 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 javax.inject.Inject
+import org.osgi.framework.{ServiceRegistration, BundleContext}
+import java.io.File
+import scala.Some
+import org.junit.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
+
+/**
+ * Base class for building Apache ServiceMix integration tests
+ */
+abstract class IntegrationTestSupport extends Await with IntegrationTestConfigurations {
+
+  @Inject
+  var context: BundleContext = null;
+
+  @Inject
+  var featuresService: FeaturesService = null
+
+  /*
+   * List of services to be unregistered after the test
+   */
+  val registrations = ArrayBuffer.empty[ServiceRegistration[_]]
+
+  @After
+  def afterTest : Unit = registrations dropWhile { registration => registration.unregister;
true }
+
+  /*
+   * A set of convenience vals for referring to directories within the test container
+   */
+  lazy val servicemixHomeFolder = new File(System.getProperty("servicemix.home"))
+  lazy val dataFolder = new File(servicemixHomeFolder, "data")
+  lazy val logFolder = new File(dataFolder, "log")
+  lazy val logFile : File = new File(logFolder, "servicemix.log")
+
+  /**
+   * Install a feature and run a block of code.  Afterwards, uninstall the feature again.
+   */
+  def testWithFeature(feature: String)(block: => Unit) =
+    try {
+      featuresService.installFeature(feature)
+      block
+    } finally {
+      featuresService.uninstallFeature(feature)
+    }
+
+
+  /**
+   * 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}")
+    case _    => //graciously ignore
+  }
+
+  /**
+   * Registers and return a logging appender
+   */
+  lazy val logging = {
+    val appender = new PaxLoggingAppender
+
+    val props = new Hashtable[String, String]()
+    props.put("org.ops4j.pax.logging.appender.name", "ITestLogAppender")
+
+    Option(context.registerService(classOf[PaxAppender], appender, props)) match {
+      case Some(registration) => (registrations += registration)
+      case None => throw new RuntimeException("Error setting up logging appender for testing")
+    }
+
+    appender
+  }
+
+  /**
+   * Simple PaxAppender implementation that buffers logging events for the integration
+   */
+  class PaxLoggingAppender extends PaxAppender {
+
+    val buffer = ArrayBuffer.empty[PaxLoggingEvent]
+
+    def doAppend(event: PaxLoggingEvent) =  buffer += event
+
+    def clear = buffer.clear
+
+    def containsMessage(predicate: String => Boolean) : Option[String] = containsEvent(event
=> predicate(event.getMessage)) map ( _.getMessage )
+
+    def containsEvent(predicate: PaxLoggingEvent => Boolean) : Option[PaxLoggingEvent]
= buffer find (predicate)
+
+  }
+
+}



Mime
View raw message