[CAMEL-8000]: Fixed test

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

Branch: refs/heads/master
Commit: cdee7809bf801faf504d06047d5763d57bc4067f
Parents: 6c488d3
Author: Claus Ibsen <davscl...@apache.org>
Authored: Fri Nov 7 18:06:58 2014 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Fri Nov 7 18:06:58 2014 +0100

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultCamelContextRegistry.java   | 8 ++++++++
 .../java/org/apache/camel/spi/CamelContextRegistryTest.java  | 4 ++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cdee7809/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextRegistry.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextRegistry.java
 
b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextRegistry.java
index f9170af..e578a5f 100644
--- 
a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextRegistry.java
+++ 
b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContextRegistry.java
@@ -35,6 +35,14 @@ public final class DefaultCamelContextRegistry implements 
CamelContextRegistry {
     private final Set<CamelContext> contexts = new 
LinkedHashSet<CamelContext>();
     private final Set<Listener> listeners = new LinkedHashSet<Listener>();
 
+    /**
+     * Clear all contexts and listeners, such as for testing purpose.
+     */
+    public synchronized void clear() {
+        contexts.clear();
+        listeners.clear();
+    }
+
     synchronized void afterCreate(CamelContext camelContext) {
         registerContext(camelContext);
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/cdee7809/camel-core/src/test/java/org/apache/camel/spi/CamelContextRegistryTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/spi/CamelContextRegistryTest.java 
b/camel-core/src/test/java/org/apache/camel/spi/CamelContextRegistryTest.java
index d35a98b..eec9263 100644
--- 
a/camel-core/src/test/java/org/apache/camel/spi/CamelContextRegistryTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/spi/CamelContextRegistryTest.java
@@ -22,6 +22,7 @@ import java.util.List;
 import junit.framework.TestCase;
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultCamelContextRegistry;
 
 public class CamelContextRegistryTest extends TestCase {
 
@@ -41,6 +42,9 @@ public class CamelContextRegistryTest extends TestCase {
     }
 
     public void testContainerSet() throws Exception {
+        // need to clear the listener for testing
+        ((DefaultCamelContextRegistry) CamelContextRegistry.INSTANCE).clear();
+
         MyListener listener = new MyListener();
 
         CamelContext camel1 = new DefaultCamelContext();

Reply via email to