You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/07/20 15:06:11 UTC
svn commit: r795813 - in /camel/trunk: ./
examples/camel-example-reportincident/
examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/
examples/camel-example-reportincident/src/main/resources/
examples/camel-examp...
Author: ningjiang
Date: Mon Jul 20 13:06:10 2009
New Revision: 795813
URL: http://svn.apache.org/viewvc?rev=795813&view=rev
Log:
CAMEL-1842 Added OSGi integration test for camel-mail and camel-cxf
Added:
camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/
camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/MailBody.vm (props changed)
- copied unchanged from r795661, camel/trunk/examples/camel-example-reportincident/src/main/resources/MailBody.vm
camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/report_incident.wsdl (props changed)
- copied unchanged from r795661, camel/trunk/examples/camel-example-reportincident/src/main/resources/report_incident.wsdl
camel/trunk/examples/camel-example-reportincident/src/main/resources/org/
camel/trunk/examples/camel-example-reportincident/src/main/resources/org/apache/
camel/trunk/examples/camel-example-reportincident/src/main/resources/org/apache/camel/
camel/trunk/examples/camel-example-reportincident/src/main/resources/org/apache/camel/example/
camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesOSGiTest.java (with props)
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/MailRouteTest.java (with props)
Removed:
camel/trunk/examples/camel-example-reportincident/src/main/resources/MailBody.vm
camel/trunk/examples/camel-example-reportincident/src/main/resources/report_incident.wsdl
Modified:
camel/trunk/examples/camel-example-reportincident/pom.xml
camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml
camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
camel/trunk/parent/pom.xml
camel/trunk/pom.xml
camel/trunk/tests/camel-itest-osgi/pom.xml
camel/trunk/tests/camel-itest-osgi/src/test/resources/log4j.properties
Modified: camel/trunk/examples/camel-example-reportincident/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/pom.xml?rev=795813&r1=795812&r2=795813&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/pom.xml (original)
+++ camel/trunk/examples/camel-example-reportincident/pom.xml Mon Jul 20 13:06:10 2009
@@ -31,89 +31,157 @@
and send as emails to a backing system
</description>
<packaging>war</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-cxf</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-velocity</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-mail</artifactId>
- </dependency>
-
- <!-- cxf -->
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-core</artifactId>
- <version>${cxf-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>${cxf-version}</version>
- </dependency>
-
- <!-- regular http transport -->
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http</artifactId>
- <version>${cxf-version}</version>
- </dependency>
-
- <!-- logging -->
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- </dependency>
-
- <!-- cxf web container for unit testing -->
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>${cxf-version}</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
- <scope>test</scope>
- </dependency>
-
- <!-- unit testing mail using mock -->
- <dependency>
- <groupId>org.jvnet.mock-javamail</groupId>
- <artifactId>mock-javamail</artifactId>
- <version>1.7</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
-
- </dependencies>
+
+ <repositories>
+ <repository>
+ <id>ops4j.releases</id>
+ <url>http://repository.ops4j.org/maven2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>ops4j.snapshots</id>
+ <url>http://repository.ops4j.org/mvn-snapshots</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>aqute.biz</id>
+ <url>http://www.aqute.biz/repo</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>ops4j.releases</id>
+ <url>http://repository.ops4j.org/maven2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <properties>
+ <pax-exam-version>0.6.0</pax-exam-version>
+ <pax-tiny-bundle-version>1.0.0</pax-tiny-bundle-version>
+ </properties>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-velocity</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-mail</artifactId>
+ </dependency>
+
+ <!-- cxf -->
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-core</artifactId>
+ <version>${cxf-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${cxf-version}</version>
+ </dependency>
+
+ <!-- regular http transport -->
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${cxf-version}</version>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+
+ <!-- cxf web container for unit testing -->
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>${cxf-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>${pax-exam-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <version>${pax-exam-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <version>${pax-exam-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit-extender-impl</artifactId>
+ <version>${pax-exam-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.swissbox</groupId>
+ <artifactId>pax-swissbox-tinybundles</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.karaf</groupId>
+ <artifactId>features</artifactId>
+ <version>${version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-osgi</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.tests</groupId>
+ <artifactId>org.apache.camel.tests.mock-javamail_1.7</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
<build>
<plugins>
@@ -127,7 +195,20 @@
<target>1.5</target>
</configuration>
</plugin>
-
+
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-depends-file</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<!-- CXF wsdl2java generator, will plugin to the compile goal -->
<plugin>
<groupId>org.apache.cxf</groupId>
@@ -141,7 +222,7 @@
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
- <wsdl>${basedir}/src/main/resources/report_incident.wsdl</wsdl>
+ <wsdl>${basedir}/src/main/resources/etc/report_incident.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
@@ -167,6 +248,16 @@
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- TODO: temporary disable unit test to let TC not hang -->
+ <exclude>**/*OSGiTest.*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
Modified: camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java?rev=795813&r1=795812&r2=795813&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java (original)
+++ camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java Mon Jul 20 13:06:10 2009
@@ -48,7 +48,7 @@
}
String cxfEndpoint = cxfEndpointAddress
+ "?serviceClass=org.apache.camel.example.reportincident.ReportIncidentEndpoint"
- + "&wsdlURL=report_incident.wsdl";
+ + "&wsdlURL=etc/report_incident.wsdl";
// first part from the webservice -> file backup
from(cxfEndpoint)
@@ -57,7 +57,7 @@
// then set the file name using the FilenameGenerator bean
.setHeader(Exchange.FILE_NAME, BeanLanguage.bean(FilenameGenerator.class, "generateFilename"))
// and create the mail body using velocity template
- .to("velocity:MailBody.vm")
+ .to("velocity:etc/MailBody.vm")
// and store the file
.to("file://target/subfolder")
// return OK as response
Modified: camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml?rev=795813&r1=795812&r2=795813&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml (original)
+++ camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml Mon Jul 20 13:06:10 2009
@@ -31,7 +31,7 @@
<cxf:cxfEndpoint id="reportIncident"
address="http://localhost:9080/camel-example-reportincident/webservices/incident"
- wsdlURL="report_incident.wsdl"
+ wsdlURL="etc/report_incident.wsdl"
serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint">
</cxf:cxfEndpoint>
@@ -46,7 +46,7 @@
<camel:setHeader headerName="CamelFileName">
<camel:method bean="filenameGenerator" method="generateFilename" />
</camel:setHeader>
- <camel:to uri="velocity:MailBody.vm"/>
+ <camel:to uri="velocity:etc/MailBody.vm"/>
<camel:to uri="file://target/subfolder"/>
<camel:transform>
<camel:method bean="myBean" method="getOK" />
Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/MailBody.vm
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/MailBody.vm
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/report_incident.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/report_incident.wsdl
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/report_incident.wsdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/report_incident.wsdl
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/etc/report_incident.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesOSGiTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesOSGiTest.java?rev=795813&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesOSGiTest.java (added)
+++ camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesOSGiTest.java Mon Jul 20 13:06:10 2009
@@ -0,0 +1,118 @@
+/**
+ * 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.camel.example.reportincident;
+
+
+import org.apache.camel.CamelContext;
+
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.osgi.CamelContextFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.jvnet.mock_javamail.Mailbox;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.swissbox.tinybundles.core.TinyBundle;
+import org.ops4j.pax.swissbox.tinybundles.dp.Constants;
+import org.osgi.framework.BundleContext;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.logProfile;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.asURL;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
+/**
+ * Unit test of our routes
+ */
+@RunWith(JUnit4TestRunner.class)
+public class ReportIncidentRoutesOSGiTest extends ReportIncidentRoutesTest {
+ private static final transient Log LOG = LogFactory.getLog(ReportIncidentRoutesOSGiTest.class);
+
+ @Inject
+ protected BundleContext bundleContext;
+
+ protected void startOSGiCamel() throws Exception {
+ CamelContextFactory factory = new CamelContextFactory();
+ factory.setBundleContext(bundleContext);
+ LOG.info("Get the bundleContext is " + bundleContext);
+ camel = factory.createContext();
+ ReportIncidentRoutes routes = new ReportIncidentRoutes();
+ routes.setUsingServletTransport(false);
+ camel.addRoutes(routes);
+ camel.start();
+ }
+
+
+ @Test
+ public void testRendportIncident() throws Exception {
+ startOSGiCamel();
+ runTest();
+ stopCamel();
+ }
+
+ @Configuration
+ public static Option[] configure() {
+ Option[] options = options(
+ // install log service using pax runners profile abstraction (there are more profiles, like DS)
+ logProfile().version("1.3.0"),
+ // install the spring dm profile
+ profile("spring.dm").version("1.2.0"),
+ // this is how you set the default log level when using pax logging (logProfile)
+ org.ops4j.pax.exam.CoreOptions.systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+ org.ops4j.pax.exam.CoreOptions.systemProperty("org.apache.cxf.nofastinfoset").value("false"),
+ org.ops4j.pax.exam.CoreOptions.systemProperty("xml.catalog.staticCatalog").value("false"),
+ // using the features to install the camel components
+ scanFeatures(mavenBundle().groupId("org.apache.camel.karaf").
+ artifactId("features").versionAsInProject().type("xml/features"),
+ "camel-core", "camel-osgi", "camel-spring", "camel-test", "camel-velocity", "camel-cxf", "camel-mail"),
+
+ // Added the mock_java_mail bundle for testing
+ mavenBundle().groupId("org.apache.camel.tests").artifactId("org.apache.camel.tests.mock-javamail_1.7").versionAsInProject(),
+
+ // create a customer bundle start up the report incident bundle
+ bundle(newBundle().addClass(InputReportIncident.class)
+ .addClass(ObjectFactory.class)
+ .addClass(OutputReportIncident.class)
+ .addClass(ReportIncidentRoutesOSGiTest.class)
+ .addClass(ReportIncidentRoutesTest.class)
+ .addClass(ReportIncidentRoutes.class)
+ .addClass(MyBean.class)
+ .addClass(FilenameGenerator.class)
+ .addClass(ReportIncidentEndpoint.class)
+ .addClass(ReportIncidentEndpointService.class)
+ .addResource("etc/report_incident.wsdl", ReportIncidentRoutesTest.class.getResource("/etc/report_incident.wsdl"))
+ .addResource("etc/MailBody.vm", ReportIncidentRoutesTest.class.getResource("/etc/MailBody.vm"))
+ .prepare(withBnd().set(Constants.BUNDLE_SYMBOLICNAME, "CamelExampleReportIncidentBundle")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.camel.example.reportincident,etc")).build(asURL()).toString()),
+
+
+ felix());
+
+ return options;
+ }
+
+}
Propchange: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesOSGiTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesOSGiTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java?rev=795813&r1=795812&r2=795813&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java (original)
+++ camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java Mon Jul 20 13:06:10 2009
@@ -20,12 +20,15 @@
import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.Assert.assertEquals;
+
/**
* Unit test of our routes
*/
-public class ReportIncidentRoutesTest extends TestCase {
+public class ReportIncidentRoutesTest {
// should be the same address as we have in our route
private static final String URL = "http://localhost:9080/camel-example-reportincident/webservices/incident";
@@ -52,10 +55,18 @@
return (ReportIncidentEndpoint) factory.create();
}
+ @Test
public void testRendportIncident() throws Exception {
// start camel
startCamel();
+ runTest();
+
+ // stop camel
+ stopCamel();
+ }
+
+ protected void runTest() throws Exception {
// assert mailbox is empty before starting
Mailbox inbox = Mailbox.get("incident@mycompany.com");
inbox.clear();
@@ -84,8 +95,5 @@
// assert mail box
assertEquals("Should have got 1 mail", 1, inbox.size());
-
- // stop camel
- stopCamel();
}
}
Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=795813&r1=795812&r2=795813&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Mon Jul 20 13:06:10 2009
@@ -443,6 +443,12 @@
<artifactId>camel-manual</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.camel.tests</groupId>
+ <artifactId>org.apache.camel.tests.mock-javamail_1.7</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- testing jars -->
<dependency>
Modified: camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/pom.xml?rev=795813&r1=795812&r2=795813&view=diff
==============================================================================
--- camel/trunk/pom.xml (original)
+++ camel/trunk/pom.xml Mon Jul 20 13:06:10 2009
@@ -97,10 +97,10 @@
<module>parent</module>
<module>camel-core</module>
<module>components</module>
- <module>examples</module>
<module>platforms</module>
<module>tooling</module>
<module>tests</module>
+ <module>examples</module>
<module>apache-camel</module>
</modules>
Modified: camel/trunk/tests/camel-itest-osgi/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/pom.xml?rev=795813&r1=795812&r2=795813&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/pom.xml (original)
+++ camel/trunk/tests/camel-itest-osgi/pom.xml Mon Jul 20 13:06:10 2009
@@ -128,6 +128,21 @@
<artifactId>camel-servlet</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.tests</groupId>
+ <artifactId>org.apache.camel.tests.mock-javamail_1.7</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/MailRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/MailRouteTest.java?rev=795813&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/MailRouteTest.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/MailRouteTest.java Mon Jul 20 13:06:10 2009
@@ -0,0 +1,146 @@
+/**
+ * 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.camel.itest.osgi;
+
+import java.io.InputStream;
+import java.util.HashMap;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.Message.RecipientType;
+
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.jvnet.mock_javamail.Mailbox;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.logProfile;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
+
+@RunWith(JUnit4TestRunner.class)
+public class MailRouteTest extends OSGiIntegrationTestSupport {
+
+ @Test
+ public void testSendAndReceiveMails() throws Exception {
+ Mailbox.clearAll();
+
+ MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
+ resultEndpoint.expectedBodiesReceived("hello world!");
+
+ HashMap<String, Object> headers = new HashMap<String, Object>();
+ headers.put("reply-to", "route-test-reply@localhost");
+ template.sendBodyAndHeaders("smtp://route-test-james@localhost", "hello world!", headers);
+
+ // lets test the first sent worked
+ assertMailboxReceivedMessages("route-test-james@localhost");
+
+ // lets sleep to check that the mail poll does not redeliver duplicate mails
+ Thread.sleep(3000);
+
+ // lets test the receive worked
+ resultEndpoint.assertIsSatisfied();
+
+ // Validate that the headers were preserved.
+ Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
+ String replyTo = (String)exchange.getIn().getHeader("reply-to");
+ assertEquals("route-test-reply@localhost", replyTo);
+
+ assertMailboxReceivedMessages("route-test-copy@localhost");
+ }
+
+ protected void assertMailboxReceivedMessages(String name) throws Exception {
+ Mailbox mailbox = Mailbox.get(name);
+ assertEquals(name + " should have received 1 mail", 1, mailbox.size());
+
+ Message message = mailbox.get(0);
+ assertNotNull(name + " should have received at least one mail!", message);
+ Object content = message.getContent();
+ assertNotNull("The content should not be null!", content);
+ if (content instanceof InputStream) {
+ assertEquals("hello world!", IOConverter.toString((InputStream)content));
+ } else {
+ assertEquals("hello world!", message.getContent());
+ }
+ assertEquals("camel@localhost", message.getFrom()[0].toString());
+ boolean found = false;
+ for (Address adr : message.getRecipients(RecipientType.TO)) {
+ if (name.equals(adr.toString())) {
+ found = true;
+ }
+ }
+ assertTrue("Should have found the recpient to in the mail: " + name, found);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("pop3://route-test-james@localhost?consumer.delay=1000")
+ .to("direct:a");
+
+ // must use fixed to option to send the mail to the given reciever, as we have polled
+ // a mail from a mailbox where it already has the 'old' To as header value
+ // here we send the mail to 2 recievers. notice we can use a plain string with semi colon
+ // to seperate the mail addresses
+ from("direct:a")
+ .setHeader("to", constant("route-test-result@localhost; route-test-copy@localhost"))
+ .to("smtp://localhost");
+
+ from("pop3://route-test-result@localhost?consumer.delay=1000")
+ .convertBodyTo(String.class).to("mock:result");
+ }
+ };
+ }
+
+ @Configuration
+ public static Option[] configure() {
+ Option[] options = options(
+ // install log service using pax runners profile abstraction (there are more profiles, like DS)
+ logProfile().version("1.3.0"),
+ // install the spring dm profile
+ profile("spring.dm").version("1.2.0"),
+ // this is how you set the default log level when using pax logging (logProfile)
+ org.ops4j.pax.exam.CoreOptions.systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ // using the features to install the camel components
+ scanFeatures(mavenBundle().groupId("org.apache.camel.karaf").
+ artifactId("features").versionAsInProject().type("xml/features"),
+ "camel-core", "camel-osgi", "camel-spring", "camel-test", "camel-mail"),
+
+ // Added the mock_java_mail bundle for testing
+ mavenBundle().groupId("org.apache.camel.tests").artifactId("org.apache.camel.tests.mock-javamail_1.7").versionAsInProject(),
+
+ felix());
+
+ return options;
+ }
+
+}
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/MailRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/MailRouteTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/tests/camel-itest-osgi/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/log4j.properties?rev=795813&r1=795812&r2=795813&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/log4j.properties (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/log4j.properties Mon Jul 20 13:06:10 2009
@@ -18,7 +18,7 @@
#
# The logging properties used during tests..
#
-log4j.rootLogger=INFO, stdout
+log4j.rootLogger=INFO, out
# Use the following line to turn on debug output for camel
#log4j.logger.org.apache.camel=DEBUG