You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/03/31 10:53:31 UTC
[7/7] camel git commit: CAMEL-8562: Added unit test to verify route
endpoints is stopped when a route is remove.
CAMEL-8562: Added unit test to verify route endpoints is stopped when a route is remove.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/52202511
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/52202511
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/52202511
Branch: refs/heads/camel-2.15.x
Commit: 5220251143f312a592a6ed5c0eff0b83280e2b3b
Parents: 2ec52d9
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Mar 31 10:52:41 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Mar 31 10:55:41 2015 +0200
----------------------------------------------------------------------
.../camel/impl/RemoveRouteStopEndpointTest.java | 152 +++++++++++++++++++
1 file changed, 152 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/52202511/camel-core/src/test/java/org/apache/camel/impl/RemoveRouteStopEndpointTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/RemoveRouteStopEndpointTest.java b/camel-core/src/test/java/org/apache/camel/impl/RemoveRouteStopEndpointTest.java
new file mode 100644
index 0000000..0f80f8c
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/RemoveRouteStopEndpointTest.java
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.support.ServiceSupport;
+
+public class RemoveRouteStopEndpointTest extends ContextTestSupport {
+
+ public void testEndpointRegistryStopRouteEndpoints() throws Exception {
+ Endpoint seda = context.hasEndpoint("seda://foo");
+ assertNotNull(seda);
+ Endpoint log = context.hasEndpoint("log://bar");
+ assertNotNull(log);
+ assertTrue("Should be started", ((ServiceSupport) seda).isStarted());
+ assertTrue("Should be started", ((ServiceSupport) log).isStarted());
+
+ assertTrue(context.hasEndpoint("seda:foo") != null);
+ assertTrue(context.hasEndpoint("seda:bar") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertTrue(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertTrue(context.hasEndpoint("seda://stop") != null);
+ assertTrue(context.hasEndpoint("mock://stop") != null);
+
+ // stop and remove bar route
+ context.stopRoute("bar");
+ context.removeRoute("bar");
+
+ assertTrue(context.hasEndpoint("seda://foo") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("seda://bar") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertTrue(context.hasEndpoint("seda://stop") != null);
+ assertTrue(context.hasEndpoint("mock://stop") != null);
+
+ assertTrue("Should be started", ((ServiceSupport) seda).isStarted());
+ assertTrue("Should be stopped", ((ServiceSupport) log).isStopped());
+
+ // stop and remove baz route
+ context.stopRoute("baz");
+ context.removeRoute("baz");
+
+ assertTrue(context.hasEndpoint("seda://foo") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("seda://bar") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertFalse(context.hasEndpoint("seda://stop") != null);
+ assertFalse(context.hasEndpoint("mock://stop") != null);
+ // stop and remove foo route
+ context.stopRoute("foo");
+ context.removeRoute("foo");
+
+ assertFalse(context.hasEndpoint("seda://foo") != null);
+ assertFalse(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("seda://bar") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertFalse(context.hasEndpoint("mock://result") != null);
+ assertFalse(context.hasEndpoint("seda://stop") != null);
+ assertFalse(context.hasEndpoint("mock://stop") != null);
+
+ assertFalse("Should not be started", ((ServiceSupport) seda).isStarted());
+ assertFalse("Should not be started", ((ServiceSupport) log).isStarted());
+ }
+
+ public void testEndpointRegistryStopRouteEndpointsContextStop() throws Exception {
+ Endpoint seda = context.hasEndpoint("seda://foo");
+ assertNotNull(seda);
+ Endpoint log = context.hasEndpoint("log://bar");
+ assertNotNull(log);
+ assertTrue("Should be started", ((ServiceSupport) seda).isStarted());
+ assertTrue("Should be started", ((ServiceSupport) log).isStarted());
+
+ assertTrue(context.hasEndpoint("seda://foo") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertTrue(context.hasEndpoint("seda://bar") != null);
+ assertTrue(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertTrue(context.hasEndpoint("seda://stop") != null);
+ assertTrue(context.hasEndpoint("mock://stop") != null);
+
+ // stop and remove bar route
+ context.stopRoute("bar");
+ context.removeRoute("bar");
+
+ assertTrue("Should be started", ((ServiceSupport) seda).isStarted());
+ assertTrue("Should be stopped", ((ServiceSupport) log).isStopped());
+
+ assertTrue(context.hasEndpoint("seda:foo") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("seda://bar") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertTrue(context.hasEndpoint("seda://stop") != null);
+ assertTrue(context.hasEndpoint("mock://stop") != null);
+
+ // stop and remove baz route
+ context.stopRoute("baz");
+ context.removeRoute("baz");
+
+ assertTrue(context.hasEndpoint("seda://foo") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("seda://bar") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertFalse(context.hasEndpoint("seda://stop") != null);
+ assertFalse(context.hasEndpoint("mock://stop") != null);
+
+ // stop camel which should stop the endpoint
+
+ context.stop();
+
+ assertFalse("Should not be started", ((ServiceSupport) seda).isStarted());
+ assertFalse("Should not be started", ((ServiceSupport) log).isStarted());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("seda:foo").routeId("foo")
+ .to("log:foo").to("mock:result");
+
+ from("seda:bar").routeId("bar")
+ .to("log:bar").to("log:bar").to("mock:result");
+
+ from("seda:stop").routeId("baz")
+ .to("mock:stop");
+ }
+ };
+ }
+
+}