You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/04/24 15:34:05 UTC
svn commit: r1471408 - in /camel/trunk/components:
camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java
camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Author: ningjiang
Date: Wed Apr 24 13:34:05 2013
New Revision: 1471408
URL: http://svn.apache.org/r1471408
Log:
CAMEL-6305 Fixed CamelBlueprintTestSupport doesn't call debugBefore() and debugAfter() issue
Modified:
camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Modified: camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java?rev=1471408&r1=1471407&r2=1471408&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java (original)
+++ camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java Wed Apr 24 13:34:05 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/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java?rev=1471408&r1=1471407&r2=1471408&view=diff
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java (original)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java Wed Apr 24 13:34:05 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;
@@ -245,6 +246,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