camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1476016 - in /camel/branches/camel-2.10.x: ./ components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Date Fri, 26 Apr 2013 01:38:35 GMT
Author: ningjiang
Date: Fri Apr 26 01:38:35 2013
New Revision: 1476016

URL: http://svn.apache.org/r1476016
Log:
CAMEL-6305 Fixed CamelBlueprintTestSupport doesn't call debugBefore() and debugAfter() issue
Merged revisions 1471468 via svnmerge from 
https://svn.apache.org/repos/asf/camel/branches/camel-2.11.x

................
  r1471468 | ningjiang | 2013-04-24 23:13:10 +0800 (Wed, 24 Apr 2013) | 10 lines
  
  Merged revisions 1471408 via svnmerge from 
  https://svn.apache.org/repos/asf/camel/trunk
  
  ........
    r1471408 | ningjiang | 2013-04-24 21:34:05 +0800 (Wed, 24 Apr 2013) | 1 line
    
    CAMEL-6305 Fixed CamelBlueprintTestSupport doesn't call debugBefore() and debugAfter()
issue
  ........
................

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java
    camel/branches/camel-2.10.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1471408
  Merged /camel/branches/camel-2.11.x:r1471468

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java?rev=1476016&r1=1476015&r2=1476016&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java
Fri Apr 26 01:38:35 2013
@@ -16,6 +16,10 @@
  */
 package org.apache.camel.test.blueprint;
 
+import org.junit.Assert;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.model.ProcessorDefinition;
 import org.junit.Test;
 
 // START SNIPPET: example
@@ -23,15 +27,20 @@ import org.junit.Test;
 // and add your unit tests methods as shown below.
 public class DebugBlueprintTest extends CamelBlueprintTestSupport {
 
+    public boolean wasDebugBeforeCalled = false;
+    public boolean wasDebugAfterCalled = false;
+
+
     // override this method, and return the location of our Blueprint XML file to be used
for testing
     @Override
     protected String getBlueprintDescriptor() {
         return "org/apache/camel/test/blueprint/camelContext.xml";
     }
-
+   
     // here we have regular Junit @Test method
     @Test
     public void testRoute() throws Exception {
+
         // set mock expectations
         getMockEndpoint("mock:a").expectedMessageCount(1);
 
@@ -40,7 +49,29 @@ public class DebugBlueprintTest extends 
 
         // assert mocks
         assertMockEndpointsSatisfied();
+        Assert.assertTrue(wasDebugBeforeCalled);
+        Assert.assertTrue(wasDebugAfterCalled);
+    }
+
+
+    @Override
+    public boolean isUseDebugger() {
+        // must enable debugger
+        return true;
+    }
+
+
+    @Override
+    protected void debugBefore(Exchange exchange, org.apache.camel.Processor processor, ProcessorDefinition<?>
definition, String id, String label) {
+        log.info("Before " + definition + " with body " + exchange.getIn().getBody());
+        wasDebugBeforeCalled = true;
     }
 
+
+    @Override
+    protected void debugAfter(Exchange exchange, org.apache.camel.Processor processor, ProcessorDefinition<?>
definition, String id, String label, long timeTaken) {
+        log.info("After " + definition + " with body " + exchange.getIn().getBody());
+        wasDebugAfterCalled = true;
+    }
 }
-// END SNIPPET: example
+// END SNIPPET: example
\ No newline at end of file

Modified: camel/branches/camel-2.10.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java?rev=1476016&r1=1476015&r2=1476016&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Fri Apr 26 01:38:35 2013
@@ -34,6 +34,7 @@ import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.Service;
+import org.apache.camel.ServiceStatus;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.component.properties.PropertiesComponent;
@@ -254,6 +255,11 @@ public abstract class CamelTestSupport e
 
         // set debugger if enabled
         if (isUseDebugger()) {
+            if (context.getStatus().equals(ServiceStatus.Started)) {
+                log.info("Cannot setting the Debugger to the starting CamelConetxt, stop
the CamelContext now.");
+                // we need to stop the context first to setup the debugger
+                context.stop();
+            }
             context.setDebugger(new DefaultDebugger());
             context.getDebugger().addBreakpoint(breakpoint);
             // note: when stopping CamelContext it will automatic remove the breakpoint



Mime
View raw message