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 2012/01/04 06:21:41 UTC
svn commit: r1227046 -
/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java
Author: davsclaus
Date: Wed Jan 4 05:21:41 2012
New Revision: 1227046
URL: http://svn.apache.org/viewvc?rev=1227046&view=rev
Log:
CAMEL-4842: Removing route should remove producer cache from JMX, as well from services to close list on CamelContext, to not eat up memory.
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java?rev=1227046&r1=1227045&r2=1227046&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java Wed Jan 4 05:21:41 2012
@@ -40,7 +40,7 @@ public class ManagedRouteAddRemoveTest e
};
}
- public void testRouteAddRemoteRoute() throws Exception {
+ public void testRouteAddRemoteRouteWithTo() throws Exception {
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
@@ -88,4 +88,100 @@ public class ManagedRouteAddRemoveTest e
log.info("Shutting down...");
}
+ public void testRouteAddRemoteRouteWithRecipientList() throws Exception {
+ MockEndpoint result = getMockEndpoint("mock:result");
+ result.expectedMessageCount(1);
+ template.sendBody("direct:start", "Hello World");
+ result.assertIsSatisfied();
+
+ MBeanServer mbeanServer = getMBeanServer();
+ ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+
+ // number of producer caches
+ Set<ObjectName> names = mbeanServer.queryNames(on, null);
+ assertEquals(1, names.size());
+
+ log.info("Adding 2nd route");
+
+ // add a 2nd route
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:bar").routeId("bar").recipientList(header("bar"));
+ }
+ });
+
+ // and send a message to it
+ MockEndpoint bar = getMockEndpoint("mock:bar");
+ bar.expectedMessageCount(1);
+ template.sendBodyAndHeader("direct:bar", "Hello World", "bar", "mock:bar");
+ bar.assertIsSatisfied();
+
+ // there should be one more producer cache
+ names = mbeanServer.queryNames(on, null);
+ assertEquals(2, names.size());
+
+ log.info("Removing 2nd route");
+
+ // now remove the 2nd route
+ context.stopRoute("bar");
+ boolean removed = context.removeRoute("bar");
+ assertTrue(removed);
+
+ // the producer cache should have been removed
+ on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ names = mbeanServer.queryNames(on, null);
+ assertEquals(1, names.size());
+
+ log.info("Shutting down...");
+ }
+
+ public void testRouteAddRemoteRouteWithRoutingSlip() throws Exception {
+ MockEndpoint result = getMockEndpoint("mock:result");
+ result.expectedMessageCount(1);
+ template.sendBody("direct:start", "Hello World");
+ result.assertIsSatisfied();
+
+ MBeanServer mbeanServer = getMBeanServer();
+ ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+
+ // number of producer caches
+ Set<ObjectName> names = mbeanServer.queryNames(on, null);
+ assertEquals(1, names.size());
+
+ log.info("Adding 2nd route");
+
+ // add a 2nd route
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:bar").routeId("bar").routingSlip(header("bar"));
+ }
+ });
+
+ // and send a message to it
+ MockEndpoint bar = getMockEndpoint("mock:bar");
+ bar.expectedMessageCount(1);
+ template.sendBodyAndHeader("direct:bar", "Hello World", "bar", "mock:bar");
+ bar.assertIsSatisfied();
+
+ // there should be one more producer cache
+ names = mbeanServer.queryNames(on, null);
+ assertEquals(2, names.size());
+
+ log.info("Removing 2nd route");
+
+ // now remove the 2nd route
+ context.stopRoute("bar");
+ boolean removed = context.removeRoute("bar");
+ assertTrue(removed);
+
+ // the producer cache should have been removed
+ on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ names = mbeanServer.queryNames(on, null);
+ assertEquals(1, names.size());
+
+ log.info("Shutting down...");
+ }
+
}
\ No newline at end of file