You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2014/12/07 23:18:13 UTC

camel git commit: Add test demonstrating how to force the Camel Context to be published as an OSGi service when the DSL is in use, so that you can get a hold on it while testing through AbstractIntegrationTest#getOsgiService(CamelContext.class

Repository: camel
Updated Branches:
  refs/heads/master 630b4c310 -> 26d52a2ab


Add test demonstrating how to force the Camel Context to be published as an OSGi service when the <endpoint> DSL is in use, so that you can get a hold on it while testing through AbstractIntegrationTest#getOsgiService(CamelContext.class, ...)

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/26d52a2a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/26d52a2a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/26d52a2a

Branch: refs/heads/master
Commit: 26d52a2ab1bc211672fa0fe6d40d23efc779e53b
Parents: 630b4c3
Author: Babak Vahdat <bv...@apache.org>
Authored: Sun Dec 7 23:17:56 2014 +0100
Committer: Babak Vahdat <bv...@apache.org>
Committed: Sun Dec 7 23:17:56 2014 +0100

----------------------------------------------------------------------
 .../osgi/blueprint/BlueprintTracerRefTest.java  | 66 ++++++++++++++++++++
 .../osgi/blueprint/BlueprintTracerTest.java     |  2 +-
 .../camel/itest/osgi/blueprint/blueprint-29.xml | 29 +++++----
 .../camel/itest/osgi/blueprint/blueprint-30.xml | 36 +++++++++++
 4 files changed, 117 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/26d52a2a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerRefTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerRefTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerRefTest.java
new file mode 100644
index 0000000..27e0d3c
--- /dev/null
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerRefTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.blueprint;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.interceptor.DefaultTraceEventMessage;
+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;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Constants;
+
+import static org.ops4j.pax.exam.OptionUtils.combine;
+
+@RunWith(PaxExam.class)
+public class BlueprintTracerRefTest extends BlueprintTracerTest {
+
+    @Test
+    @Override
+    public void testTracer() throws Exception {
+        name = BlueprintTracerRefTest.class.getName();
+
+        super.testTracer();
+    }
+
+    @Configuration
+    public static Option[] configure() throws Exception {
+
+        Option[] options = combine(
+                getDefaultCamelKarafOptions(),
+
+                bundle(TinyBundles.bundle()
+                        .add("OSGI-INF/blueprint/test.xml", BlueprintTracerRefTest.class.getResource("blueprint-30.xml"))
+                        .set(Constants.BUNDLE_SYMBOLICNAME, BlueprintTracerRefTest.class.getName())
+                        .set(Constants.BUNDLE_VERSION, "1.0.0")
+                        .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
+                        .build()).noStart(),
+
+                // do eagerly register the Camel context so that OsgiCamelContextPublisher can publish it early enough as an OSGi service
+                org.ops4j.pax.exam.CoreOptions.systemProperty("registerBlueprintCamelContextEager").value("true"),
+
+                // using the features to install the camel components
+                loadCamelFeatures("camel-blueprint"));
+
+        return options;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/26d52a2a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java
index 25b7282..0bc7234 100644
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/BlueprintTracerTest.java
@@ -33,7 +33,7 @@ import static org.ops4j.pax.exam.OptionUtils.combine;
 @RunWith(PaxExam.class)
 public class BlueprintTracerTest extends OSGiBlueprintTestSupport {
 
-    private String name = BlueprintTracerTest.class.getName();
+    protected String name = BlueprintTracerTest.class.getName();
 
     @Test
     public void testTracer() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/26d52a2a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-29.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-29.xml b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-29.xml
index 7c3b93c..4fa9b56 100644
--- a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-29.xml
+++ b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-29.xml
@@ -15,22 +15,21 @@
     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"
-           xmlns:camel="http://camel.apache.org/schema/blueprint">
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
 
-    <camelContext trace="true" xmlns="http://camel.apache.org/schema/blueprint">
-        <route>
-            <from uri="direct:start"/>
-            <to uri="mock:result"/>
-        </route>
-    </camelContext>
+  <camelContext trace="true" xmlns="http://camel.apache.org/schema/blueprint">
+    <route>
+      <from uri="direct:start" />
+      <to uri="mock:result" />
+    </route>
+  </camelContext>
 
-    <bean id="camelTracer" class="org.apache.camel.processor.interceptor.Tracer">
-        <property name="traceInterceptors" value="true"/>
-        <property name="traceExceptions" value="true"/>
-        <property name="logLevel" value="INFO"/>
-        <property name="logName" value="org.apache.camel.blueprint.log"/>
-        <property name="destinationUri" value="mock:traced"/>
-    </bean>
+  <bean id="camelTracer" class="org.apache.camel.processor.interceptor.Tracer">
+    <property name="traceInterceptors" value="true" />
+    <property name="traceExceptions" value="true" />
+    <property name="logLevel" value="INFO" />
+    <property name="logName" value="org.apache.camel.blueprint.log" />
+    <property name="destinationUri" value="mock:traced" />
+  </bean>
 
 </blueprint>

http://git-wip-us.apache.org/repos/asf/camel/blob/26d52a2a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-30.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-30.xml b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-30.xml
new file mode 100644
index 0000000..965e6dc
--- /dev/null
+++ b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-30.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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+  <camelContext trace="true" xmlns="http://camel.apache.org/schema/blueprint">
+    <endpoint id="traced" uri="mock:traced" />
+    <route>
+      <from uri="direct:start" />
+      <to uri="mock:result" />
+    </route>
+  </camelContext>
+
+  <bean id="camelTracer" class="org.apache.camel.processor.interceptor.Tracer">
+    <property name="traceInterceptors" value="true" />
+    <property name="traceExceptions" value="true" />
+    <property name="logLevel" value="INFO" />
+    <property name="logName" value="org.apache.camel.blueprint.log" />
+    <property name="destination" ref="traced" />
+  </bean>
+
+</blueprint>