camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/3] camel git commit: CAMEL-9259: Fixed enableTrace on Camel Main. Thanks to Charles Moulliard for spotting this
Date Tue, 27 Oct 2015 11:41:38 GMT
CAMEL-9259: Fixed enableTrace on Camel Main. Thanks to Charles Moulliard for spotting this


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

Branch: refs/heads/camel-2.15.x
Commit: 7b84f410e7ada3fd98127816279543c66167539d
Parents: 4e10ede
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Oct 27 12:43:45 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Oct 27 12:44:24 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/main/MainSupport.java    |  6 +++---
 .../test/java/org/apache/camel/main/MainTest.java  | 17 +++++++++--------
 2 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7b84f410/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/main/MainSupport.java b/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
index 4fb30fe..f4dbb0d 100644
--- a/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
@@ -306,9 +306,6 @@ public abstract class MainSupport extends ServiceSupport {
 
     public void enableTrace() {
         this.trace = true;
-        for (CamelContext context : camelContexts) {
-            context.setTracing(true);
-        }
     }
 
     public void setRoutesOutputFile(String routesOutputFile) {
@@ -470,6 +467,9 @@ public abstract class MainSupport extends ServiceSupport {
     }
 
     protected void postProcessCamelContext(CamelContext camelContext) throws Exception {
+        if (trace) {
+            camelContext.setTracing(true);
+        }
         // try to load the route builders from the routeBuilderClasses
         loadRouteBuilders(camelContext);
         for (RouteBuilder routeBuilder : routeBuilders) {

http://git-wip-us.apache.org/repos/asf/camel/blob/7b84f410/camel-core/src/test/java/org/apache/camel/main/MainTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/main/MainTest.java b/camel-core/src/test/java/org/apache/camel/main/MainTest.java
index 0acfd53..132c5dc 100644
--- a/camel-core/src/test/java/org/apache/camel/main/MainTest.java
+++ b/camel-core/src/test/java/org/apache/camel/main/MainTest.java
@@ -19,11 +19,9 @@ package org.apache.camel.main;
 import java.util.List;
 
 import junit.framework.TestCase;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.DefaultCamelContext;
 
 /**
  * @version 
@@ -34,19 +32,21 @@ public class MainTest extends TestCase {
         // lets make a simple route
         Main main = new Main();
         main.addRouteBuilder(new MyRouteBuilder());
+        main.enableTrace();
         main.bind("foo", new Integer(31));
         main.start();
 
-        main.getCamelTemplate().sendBody("direct:start", "<message>1</message>");
-        
         List<CamelContext> contextList = main.getCamelContexts();
         assertNotNull(contextList);
         assertEquals("Did not get the expected count of Camel contexts", 1, contextList.size());
         CamelContext camelContext = contextList.get(0);
-        assertEquals("Could not find the registry bound object", 31, ((DefaultCamelContext)
camelContext).getRegistry().lookupByName("foo"));
+        assertEquals("Could not find the registry bound object", 31, camelContext.getRegistry().lookupByName("foo"));
 
         MockEndpoint endpoint = camelContext.getEndpoint("mock:results", MockEndpoint.class);
         endpoint.expectedMinimumMessageCount(1);
+
+        main.getCamelTemplate().sendBody("direct:start", "<message>1</message>");
+
         endpoint.assertIsSatisfied();
 
         main.stop();
@@ -57,9 +57,7 @@ public class MainTest extends TestCase {
         // let the main load the MyRouteBuilder
         main.parseArguments(new String[]{"-r", "org.apache.camel.main.MainTest$MyRouteBuilder"});
         main.start();
-        
-        main.getCamelTemplate().sendBody("direct:start", "<message>1</message>");
-        
+
         List<CamelContext> contextList = main.getCamelContexts();
         assertNotNull(contextList);
         assertEquals("Did not get the expected count of Camel contexts", 1, contextList.size());
@@ -67,6 +65,9 @@ public class MainTest extends TestCase {
         
         MockEndpoint endpoint = camelContext.getEndpoint("mock:results", MockEndpoint.class);
         endpoint.expectedMinimumMessageCount(1);
+
+        main.getCamelTemplate().sendBody("direct:start", "<message>1</message>");
+
         endpoint.assertIsSatisfied();
         main.stop();
     }


Mime
View raw message