You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/09/16 10:56:39 UTC
svn commit: r997644 - in /camel/trunk/tests/camel-itest-osgi/src/test:
java/org/apache/camel/itest/osgi/freemarker/
java/org/apache/camel/itest/osgi/quartz/
java/org/apache/camel/itest/osgi/validator/
java/org/apache/camel/itest/osgi/xslt/ resources/or...
Author: davsclaus
Date: Thu Sep 16 08:56:38 2010
New Revision: 997644
URL: http://svn.apache.org/viewvc?rev=997644&view=rev
Log:
CAMEL-3126: Added more osgi tests.
Added:
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java
- copied, changed from r997621, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityTest.java
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/quartz/
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/quartz/QuartzCronRouteTest.java (contents, props changed)
- copied, changed from r997621, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/file/FileRouteTest.java
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/validator/
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/validator/ValidatorRouteTest.java
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xslt/
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xslt/XsltRouteTest.java (contents, props changed)
- copied, changed from r997621, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/file/FileRouteTest.java
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/freemarker/
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/freemarker/example.ftl
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/validator/
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/validator/schema.xsd
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/xslt/
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/xslt/example.xsl
Copied: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java (from r997621, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java?p2=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java&p1=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityTest.java&r1=997621&r2=997644&rev=997644&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityTest.java (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java Thu Sep 16 08:56:38 2010
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.itest.osgi.velocity;
+package org.apache.camel.itest.osgi.freemarker;
import org.apache.camel.Exchange;
import org.apache.camel.InvalidPayloadException;
@@ -36,12 +36,12 @@ import static org.ops4j.pax.exam.contain
import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
@RunWith(JUnit4TestRunner.class)
-public class VelocityTest extends OSGiIntegrationTestSupport {
+public class FreemarkerTest extends OSGiIntegrationTestSupport {
@Test
public void testReceivesResponse() throws Exception {
- assertRespondsWith("foo", "<header>foo</header><hello>foo</hello>");
- assertRespondsWith("bar", "<header>bar</header><hello>bar</hello>");
+ assertRespondsWith("foo", "<hello>foo</hello>");
+ assertRespondsWith("bar", "<hello>bar</hello>");
}
protected void assertRespondsWith(final String value, String expectedBody) throws InvalidPayloadException {
@@ -58,8 +58,7 @@ public class VelocityTest extends OSGiIn
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from("direct:a").
- to("velocity:org/apache/camel/itest/osgi/velocity/example.vm");
+ from("direct:a").to("freemarker:org/apache/camel/itest/osgi/freemarker/example.ftl");
}
};
}
@@ -74,7 +73,7 @@ public class VelocityTest extends OSGiIn
// using the features to install the camel components
scanFeatures(getCamelKarafFeatureUrl(),
- "camel-core", "camel-spring", "camel-test", "camel-velocity"),
+ "camel-core", "camel-spring", "camel-test", "camel-freemarker"),
workingDirectory("target/paxrunner/"),
Copied: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/quartz/QuartzCronRouteTest.java (from r997621, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/file/FileRouteTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/quartz/QuartzCronRouteTest.java?p2=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/quartz/QuartzCronRouteTest.java&p1=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/file/FileRouteTest.java&r1=997621&r2=997644&rev=997644&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/file/FileRouteTest.java (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/quartz/QuartzCronRouteTest.java Thu Sep 16 08:56:38 2010
@@ -14,27 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.itest.osgi.file;
+package org.apache.camel.itest.osgi.quartz;
-import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
import org.junit.Test;
import org.junit.runner.RunWith;
+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.equinox;
+import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.options;
+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.exam.container.def.PaxRunnerOptions.workingDirectory;
+
@RunWith(JUnit4TestRunner.class)
-public class FileRouteTest extends OSGiIntegrationTestSupport {
+public class QuartzCronRouteTest extends OSGiIntegrationTestSupport {
@Test
- public void testFileRoute() throws Exception {
+ public void testQuartzCronRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Hello World");
- // should be moved to .camel when done
- mock.expectedFileExists("target/data/.camel/hello.txt");
-
- template.sendBodyAndHeader("file:target/data", "Hello World", Exchange.FILE_NAME, "hello.txt");
+ mock.expectedMinimumMessageCount(3);
assertMockEndpointsSatisfied();
}
@@ -44,12 +48,28 @@ public class FileRouteTest extends OSGiI
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- // delete the data directory
- deleteDirectory("target/data");
-
- from("file:target/data").convertBodyTo(String.class).to("mock:result");
+ from("quartz://myGroup/myTimerName?cron=0/2+*+*+*+*+?").to("mock:result");
}
};
}
+ @Configuration
+ public static Option[] configure() {
+ Option[] options = options(
+ // 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(getCamelKarafFeatureUrl(),
+ "camel-core", "camel-spring", "camel-test", "camel-quartz"),
+
+ workingDirectory("target/paxrunner/"),
+
+ felix(), equinox());
+
+ return options;
+ }
+
}
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/quartz/QuartzCronRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/quartz/QuartzCronRouteTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/validator/ValidatorRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/validator/ValidatorRouteTest.java?rev=997644&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/validator/ValidatorRouteTest.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/validator/ValidatorRouteTest.java Thu Sep 16 08:56:38 2010
@@ -0,0 +1,71 @@
+/**
+ * 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.validator;
+
+import org.apache.camel.ValidationException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+@RunWith(JUnit4TestRunner.class)
+public class ValidatorRouteTest extends OSGiIntegrationTestSupport {
+
+ @Test
+ public void testValidMessage() throws Exception {
+ getMockEndpoint("mock:valid").expectedMessageCount(1);
+ getMockEndpoint("mock:invalid").expectedMessageCount(0);
+ getMockEndpoint("mock:finally").expectedMessageCount(1);
+
+ template.sendBody("direct:start",
+ "<mail xmlns='http://foo.com/bar'><subject>Hey</subject><body>Hello world!</body></mail>");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testInvalidMessage() throws Exception {
+ getMockEndpoint("mock:valid").expectedMessageCount(0);
+ getMockEndpoint("mock:invalid").expectedMessageCount(1);
+ getMockEndpoint("mock:finally").expectedMessageCount(1);
+
+ template.sendBody("direct:start",
+ "<mail xmlns='http://foo.com/bar'><body>Hello world!</body></mail>");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .doTry()
+ .to("validator:org/apache/camel/itest/osgi/validator/schema.xsd")
+ .to("mock:valid")
+ .doCatch(ValidationException.class)
+ .to("mock:invalid")
+ .doFinally()
+ .to("mock:finally")
+ .end();
+ }
+ };
+ }
+
+}
Copied: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xslt/XsltRouteTest.java (from r997621, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/file/FileRouteTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xslt/XsltRouteTest.java?p2=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xslt/XsltRouteTest.java&p1=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/file/FileRouteTest.java&r1=997621&r2=997644&rev=997644&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/file/FileRouteTest.java (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xslt/XsltRouteTest.java Thu Sep 16 08:56:38 2010
@@ -14,9 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.itest.osgi.file;
+package org.apache.camel.itest.osgi.xslt;
-import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
@@ -25,29 +24,28 @@ import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
@RunWith(JUnit4TestRunner.class)
-public class FileRouteTest extends OSGiIntegrationTestSupport {
+public class XsltRouteTest extends OSGiIntegrationTestSupport {
@Test
- public void testFileRoute() throws Exception {
+ public void testXsltRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Hello World");
- // should be moved to .camel when done
- mock.expectedFileExists("target/data/.camel/hello.txt");
+ mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+ mock.message(0).body().isInstanceOf(String.class);
- template.sendBodyAndHeader("file:target/data", "Hello World", Exchange.FILE_NAME, "hello.txt");
+ template.sendBody("direct:start", "<hello>world!</hello>");
assertMockEndpointsSatisfied();
}
@Override
- protected RouteBuilder createRouteBuilder() {
+ protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- // delete the data directory
- deleteDirectory("target/data");
-
- from("file:target/data").convertBodyTo(String.class).to("mock:result");
+ from("direct:start")
+ .to("xslt:org/apache/camel/itest/osgi/xslt/example.xsl")
+ .to("log:result")
+ .to("mock:result");
}
};
}
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xslt/XsltRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xslt/XsltRouteTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/freemarker/example.ftl
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/freemarker/example.ftl?rev=997644&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/freemarker/example.ftl (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/freemarker/example.ftl Thu Sep 16 08:56:38 2010
@@ -0,0 +1,19 @@
+<#--
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+-->
+<hello>${headers.cheese}</hello>
\ No newline at end of file
Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/validator/schema.xsd
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/validator/schema.xsd?rev=997644&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/validator/schema.xsd (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/validator/schema.xsd Thu Sep 16 08:56:38 2010
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ 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.
+-->
+<xs:schema elementFormDefault="qualified" version="1.0"
+ targetNamespace="http://foo.com/bar"
+ xmlns:tns="http://foo.com/bar"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+
+ <xs:element name="mail">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="subject" type="xs:string"/>
+ <xs:element name="body" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
+
Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/xslt/example.xsl
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/xslt/example.xsl?rev=997644&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/xslt/example.xsl (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/xslt/example.xsl Thu Sep 16 08:56:38 2010
@@ -0,0 +1,26 @@
+<?xml version = "1.0"?>
+<!--
+ 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.
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/">
+ <goodbye>
+ <xsl:value-of select="/hello"/>
+ </goodbye>
+ </xsl:template>
+
+</xsl:stylesheet>