use of javax.management.MBeanServer in project camel by apache.
the class RemoveRouteDefinitionTest method testShutdownRoute.
@SuppressWarnings("deprecation")
public void testShutdownRoute() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(1, set.size());
ObjectName on = set.iterator().next();
boolean registered = mbeanServer.isRegistered(on);
assertEquals("Should be registered", true, registered);
RouteDefinition definition = context.getRouteDefinition("route1");
List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
routeDefinitions.add(definition);
context.shutdownRoute("route1");
// route is shutdown (= also removed), so its not longer in JMX
set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(0, set.size());
}
use of javax.management.MBeanServer in project camel by apache.
the class RemoveRouteDefinitionTest method testStopAndRemoveRoute.
public void testStopAndRemoveRoute() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(1, set.size());
ObjectName on = set.iterator().next();
boolean registered = mbeanServer.isRegistered(on);
assertEquals("Should be registered", true, registered);
RouteDefinition definition = context.getRouteDefinition("route1");
List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
routeDefinitions.add(definition);
// must stop before we can remove
context.stopRoute("route1");
context.removeRoute("route1");
// route is removed, so its not longer in JMX
set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(0, set.size());
}
use of javax.management.MBeanServer in project camel by apache.
the class TwoManagedCamelContextAutoAssignedNameClashTest method testTwoManagedCamelContextClash.
public void testTwoManagedCamelContextClash() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
camel1 = createCamelContext();
camel1.start();
assertTrue("Should be started", camel1.getStatus().isStarted());
MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer();
ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + camel1.getManagementName() + ",type=context,name=\"camel-1\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on));
// now cheat and reset the counter so we can test for a clash
DefaultCamelContextNameStrategy.setCounter(0);
camel2 = createCamelContext();
camel2.start();
ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=" + camel2.getManagementName() + ",type=context,name=\"camel-1\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on2));
assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on));
assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on2));
}
use of javax.management.MBeanServer in project camel by apache.
the class TwoManagedCamelContextClashTest method testTwoManagedCamelContextNoClashCustomPattern.
public void testTwoManagedCamelContextNoClashCustomPattern() throws Exception {
camel1 = createCamelContext("foo", "killer-#counter#");
camel2 = createCamelContext("foo", "killer-#counter#");
camel1.start();
assertTrue("Should be started", camel1.getStatus().isStarted());
MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer();
ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + camel1.getManagementName() + ",type=context,name=\"foo\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on));
// the pattern has a counter so no clash
camel2.start();
ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=" + camel2.getManagementName() + ",type=context,name=\"foo\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on2));
assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on));
assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on2));
}
use of javax.management.MBeanServer in project camel by apache.
the class TwoManagedCamelContextTest method testTwoManagedCamelContext.
public void testTwoManagedCamelContext() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
camel1 = createCamelContext("foo");
camel2 = createCamelContext("bar");
camel1.start();
camel2.start();
MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer();
ObjectName on = ObjectName.getInstance("org.apache.camel:context=foo,type=context,name=\"foo\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on));
ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=bar,type=context,name=\"bar\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on2));
camel1.stop();
camel2.stop();
assertFalse("Should be unregistered", mbeanServer.isRegistered(on));
assertFalse("Should be unregistered", mbeanServer.isRegistered(on2));
}
Aggregations