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 2016/04/18 13:57:03 UTC
camel git commit: Work on a new camel-itest-osgi that uses
camel-test-karaf for testing.
Repository: camel
Updated Branches:
refs/heads/master 046d99e3f -> d334cbe88
Work on a new camel-itest-osgi that uses camel-test-karaf for testing.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d334cbe8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d334cbe8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d334cbe8
Branch: refs/heads/master
Commit: d334cbe8880173c7aafa5c5979426011989e4b1e
Parents: 046d99e
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Apr 18 13:56:56 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Apr 18 13:56:56 2016 +0200
----------------------------------------------------------------------
.../camel/test/karaf/AbstractFeatureTest.java | 15 ++++++
.../org/apache/camel/itest/CamelSpringTest.java | 57 ++++++++++++++++++++
.../org/apache/camel/itest/CamelSpringTest.xml | 36 +++++++++++++
3 files changed, 108 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d334cbe8/components/camel-test-karaf/src/main/java/org/apache/camel/test/karaf/AbstractFeatureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-karaf/src/main/java/org/apache/camel/test/karaf/AbstractFeatureTest.java b/components/camel-test-karaf/src/main/java/org/apache/camel/test/karaf/AbstractFeatureTest.java
index 6e5cddf..238804e 100644
--- a/components/camel-test-karaf/src/main/java/org/apache/camel/test/karaf/AbstractFeatureTest.java
+++ b/components/camel-test-karaf/src/main/java/org/apache/camel/test/karaf/AbstractFeatureTest.java
@@ -119,6 +119,21 @@ public abstract class AbstractFeatureTest {
return answer;
}
+ protected Bundle installSpringAsBundle(String name, URL url, boolean start) throws BundleException {
+ TinyBundle bundle = TinyBundles.bundle();
+ bundle.add("META-INF/spring/spring-" + name.toLowerCase(Locale.ENGLISH) + ".xml", url);
+ bundle.set("Manifest-Version", "2")
+ .set("Bundle-ManifestVersion", "2")
+ .set("Bundle-SymbolicName", name)
+ .set("Bundle-Version", "1.0.0");
+ Bundle answer = bundleContext.installBundle(name, bundle.build());
+
+ if (start) {
+ answer.start();
+ }
+ return answer;
+ }
+
protected void installCamelFeature(String mainFeature) throws Exception {
if (!mainFeature.startsWith("camel-")) {
mainFeature = "camel-" + mainFeature;
http://git-wip-us.apache.org/repos/asf/camel/blob/d334cbe8/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/CamelSpringTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/CamelSpringTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/CamelSpringTest.java
new file mode 100644
index 0000000..29eb766
--- /dev/null
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/CamelSpringTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest;
+
+import java.net.URL;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.karaf.AbstractFeatureTest;
+import org.apache.camel.test.karaf.CamelKarafTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+
+@RunWith(PaxExam.class)
+public class CamelSpringTest extends AbstractFeatureTest {
+
+ @Test
+ public void testCamelSpring() throws Exception {
+ URL url = ObjectHelper.loadResourceAsURL("org/apache/camel/itest/CamelSpringTest.xml", CamelSpringTest.class.getClassLoader());
+ installSpringAsBundle("CamelSpringTest", url, true);
+
+ // lookup Camel from OSGi
+ CamelContext camel = getOsgiService(bundleContext, CamelContext.class);
+
+ // test camel
+ MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
+ mock.expectedBodiesReceived("Bye World");
+
+ camel.createProducerTemplate().sendBody("direct:start", "World");
+
+ mock.assertIsSatisfied();
+ }
+
+ @Configuration
+ public Option[] configure() {
+ return CamelKarafTestSupport.configure("camel-spring-dm");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/d334cbe8/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/CamelSpringTest.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/CamelSpringTest.xml b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/CamelSpringTest.xml
new file mode 100644
index 0000000..6459046
--- /dev/null
+++ b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/CamelSpringTest.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+ <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct:start"/>
+ <transform>
+ <simple>Bye ${body}</simple>
+ </transform>
+ <to uri="mock:result"/>
+ </route>
+
+ </camelContext>
+
+</beans>