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 2017/02/20 09:35:09 UTC

camel git commit: Same fix as CAMEL-10856 for camel-opentracing.

Repository: camel
Updated Branches:
  refs/heads/master 7fb7cf900 -> fdde06923


Same fix as CAMEL-10856 for camel-opentracing.


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

Branch: refs/heads/master
Commit: fdde069234c33bcc9c406c705e625be7f811992b
Parents: 7fb7cf9
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Feb 20 10:35:17 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Feb 20 10:35:17 2017 +0100

----------------------------------------------------------------------
 .../camel/opentracing/OpenTracingTracer.java    |  4 +-
 .../opentracing/OpenTracingSimpleRouteTest.java | 51 --------------------
 .../SpringOpenTracingSimpleRouteTest.java       | 50 +++++++++++++++++++
 3 files changed, 53 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fdde0692/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java
index 165978c..a737499 100644
--- a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java
@@ -78,11 +78,13 @@ public class OpenTracingTracer extends ServiceSupport implements RoutePolicyFact
 
     @Override
     public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, RouteDefinition route) {
+        // ensure this opentracing tracer gets initialized when Camel starts
+        init(camelContext);
         return new OpenTracingRoutePolicy(routeId);
     }
 
     /**
-     * Registers this {@link OpenTracingTracer} on the {@link CamelContext}.
+     * Registers this {@link OpenTracingTracer} on the {@link CamelContext} if not already registered.
      */
     public void init(CamelContext camelContext) {
         if (!camelContext.hasService(this)) {

http://git-wip-us.apache.org/repos/asf/camel/blob/fdde0692/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.java
deleted file mode 100644
index 56b35a3..0000000
--- a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.java
+++ /dev/null
@@ -1,51 +0,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.
- */
-package org.apache.camel.opentracing;
-
-import java.util.concurrent.TimeUnit;
-
-import io.opentracing.mock.MockTracer;
-import org.apache.camel.builder.NotifyBuilder;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class OpenTracingSimpleRouteTest extends CamelSpringTestSupport {
-
-    @Override
-    protected AbstractApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/opentracing/OpenTracingSimpleRouteTest.xml");
-    }
-
-    @Test
-    @org.junit.Ignore
-    public void testRoute() throws Exception {
-        NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
-
-        for (int i = 0; i < 5; i++) {
-            template.sendBody("seda:dude", "Hello World");
-        }
-
-        assertTrue(notify.matches(30, TimeUnit.SECONDS));
-
-        MockTracer tracer = (MockTracer) context().getRegistry().lookupByName("mockTracer");
-
-        // Four spans per invocation, one for client, two for dude route (server and client to), one for car route
-        assertEquals(20, tracer.finishedSpans().size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/fdde0692/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/SpringOpenTracingSimpleRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/SpringOpenTracingSimpleRouteTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/SpringOpenTracingSimpleRouteTest.java
new file mode 100644
index 0000000..362d41d
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/SpringOpenTracingSimpleRouteTest.java
@@ -0,0 +1,50 @@
+/**
+ * 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.opentracing;
+
+import java.util.concurrent.TimeUnit;
+
+import io.opentracing.mock.MockTracer;
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringOpenTracingSimpleRouteTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/opentracing/OpenTracingSimpleRouteTest.xml");
+    }
+
+    @Test
+    public void testRoute() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
+
+        for (int i = 0; i < 5; i++) {
+            template.sendBody("seda:dude", "Hello World");
+        }
+
+        assertTrue(notify.matches(30, TimeUnit.SECONDS));
+
+        MockTracer tracer = (MockTracer) context().getRegistry().lookupByName("mockTracer");
+
+        // Four spans per invocation, one for client, two for dude route (server and client to), one for car route
+        assertEquals(20, tracer.finishedSpans().size());
+    }
+}