camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r991874 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/DefaultDebugger.java test/java/org/apache/camel/processor/interceptor/DebugTest.java
Date Thu, 02 Sep 2010 09:29:53 GMT
Author: davsclaus
Date: Thu Sep  2 09:29:53 2010
New Revision: 991874

URL: http://svn.apache.org/viewvc?rev=991874&view=rev
Log:
Fixed bug when removing breakpoint.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java?rev=991874&r1=991873&r2=991874&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java Thu Sep
 2 09:29:53 2010
@@ -23,6 +23,7 @@ import java.util.EventObject;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
@@ -51,7 +52,7 @@ import org.apache.commons.logging.LogFac
 public class DefaultDebugger implements Debugger, CamelContextAware {
 
     private static final Log LOG = LogFactory.getLog(DefaultDebugger.class);
-    private final List<BreakpointConditions> breakpoints = new ArrayList<BreakpointConditions>();
+    private final List<BreakpointConditions> breakpoints = new CopyOnWriteArrayList<BreakpointConditions>();
     private final int maxConcurrentSingleSteps = 1;
     private final Map<String, Breakpoint> singleSteps = new HashMap<String, Breakpoint>(maxConcurrentSingleSteps);
     private CamelContext camelContext;
@@ -97,7 +98,7 @@ public class DefaultDebugger implements 
     }
 
     public void addBreakpoint(Breakpoint breakpoint) {
-        addBreakpoint(breakpoint, (Condition) null);
+        breakpoints.add(new BreakpointConditions(breakpoint));
     }
 
     public void addBreakpoint(Breakpoint breakpoint, Condition... conditions) {
@@ -154,7 +155,11 @@ public class DefaultDebugger implements 
     }
 
     public void removeBreakpoint(Breakpoint breakpoint) {
-        breakpoints.remove(breakpoint);
+        for (BreakpointConditions condition : breakpoints) {
+            if (condition.getBreakpoint().equals(breakpoint)) {
+                breakpoints.remove(condition);
+            }
+        }
     }
 
     public void suspendAllBreakpoints() {
@@ -357,7 +362,7 @@ public class DefaultDebugger implements 
             onEvent(exchange, event);
 
             if (event instanceof ExchangeCompletedEvent) {
-                // failsafe to ensure we remote single steps when the Exchange is complete
+                // fail safe to ensure we remove single steps when the Exchange is complete
                 singleSteps.remove(exchange.getExchangeId());
             }
         }
@@ -366,14 +371,13 @@ public class DefaultDebugger implements 
             return event instanceof AbstractExchangeEvent;
         }
 
-        @Override
         protected void doStart() throws Exception {
             // noop
         }
 
-        @Override
         protected void doStop() throws Exception {
             // noop
         }
     }
+
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugTest.java?rev=991874&r1=991873&r2=991874&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugTest.java
Thu Sep  2 09:29:53 2010
@@ -147,6 +147,33 @@ public class DebugTest extends ContextTe
         assertEquals("Breakpoint at To[mock:result] with body: Hello Camel", logs.get(0));
     }
 
+    public void testDebugRemoveBreakpoint() throws Exception {
+        context.getDebugger().addBreakpoint(breakpoint);
+
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        assertEquals(7, logs.size());
+
+        // remove the breakpoint
+        context.getDebugger().removeBreakpoint(breakpoint);
+
+        // reset and test again now the breakpoint is removed
+        resetMocks();
+        logs.clear();
+
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello Camel");
+
+        template.sendBody("direct:start", "Hello Camel");
+
+        assertMockEndpointsSatisfied();
+
+        assertEquals(0, logs.size());
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {



Mime
View raw message