use of javax.management.MBeanServer in project camel by apache.
the class ManagedRouteRemoveContextScopedErrorHandlerTest method testRemove.
public void testRemove() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = getRouteObjectName(mbeanServer);
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
template.sendBody("seda:foo", "Hello World");
assertMockEndpointsSatisfied();
// should be started
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be started", ServiceStatus.Started.name(), state);
// and one context scoped error handler
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=errorhandlers,*"), null);
assertEquals(1, set.size());
// stop
mbeanServer.invoke(on, "stop", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be stopped", ServiceStatus.Stopped.name(), state);
// remove
mbeanServer.invoke(on, "remove", null, null);
// should not be registered anymore
boolean registered = mbeanServer.isRegistered(on);
assertFalse("Route mbean should have been unregistered", registered);
// and no more routes
set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(0, set.size());
// but still 1 context scoped error handler
set = mbeanServer.queryNames(new ObjectName("*:type=errorhandlers,*"), null);
assertEquals(1, set.size());
}
use of javax.management.MBeanServer in project camel by apache.
the class ManagedRouteRemoveRouteAndContextScopedErrorHandlerTest method testRemoveFoo.
public void testRemoveFoo() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = getRouteObjectName(mbeanServer, "foo");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
template.sendBody("seda:foo", "Hello World");
assertMockEndpointsSatisfied();
// should be started
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be started", ServiceStatus.Started.name(), state);
// and 1 context scoped and 1 route scoped error handler
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=errorhandlers,*"), null);
assertEquals(2, set.size());
// stop
mbeanServer.invoke(on, "stop", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be stopped", ServiceStatus.Stopped.name(), state);
// remove
mbeanServer.invoke(on, "remove", null, null);
// should not be registered anymore
boolean registered = mbeanServer.isRegistered(on);
assertFalse("Route mbean should have been unregistered", registered);
// and only the other route
set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(1, set.size());
// and the route scoped error handler should be removed
set = mbeanServer.queryNames(new ObjectName("*:type=errorhandlers,*"), null);
assertEquals(1, set.size());
// should be the context scoped logging error handler
assertTrue("Should be context scoped error handler: " + set, set.iterator().next().toString().contains("Logging"));
}
use of javax.management.MBeanServer in project camel by apache.
the class ManagedRouteRemoveTest method testRemove.
public void testRemove() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = getRouteObjectName(mbeanServer);
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
template.sendBodyAndHeader("file://target/managed", "Hello World", Exchange.FILE_NAME, "hello.txt");
assertMockEndpointsSatisfied();
// should be started
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be started", ServiceStatus.Started.name(), state);
// stop
mbeanServer.invoke(on, "stop", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be stopped", ServiceStatus.Stopped.name(), state);
// remove
mbeanServer.invoke(on, "remove", null, null);
// should not be registered anymore
boolean registered = mbeanServer.isRegistered(on);
assertFalse("Route mbean should have been unregistered", registered);
// and no more routes
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(0, set.size());
}
use of javax.management.MBeanServer in project camel by apache.
the class ManagedRouteRemoveWireTapTest method testRemove.
public void testRemove() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=routes,name=\"foo\"");
getMockEndpoint("mock:result").expectedMessageCount(1);
getMockEndpoint("mock:tap").expectedMessageCount(1);
template.sendBody("seda:foo", "Hello World");
assertMockEndpointsSatisfied();
// should be started
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be started", ServiceStatus.Started.name(), state);
// and a number of thread pools
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=threadpools,*"), null);
boolean wireTap = false;
for (ObjectName name : set) {
if (name.toString().contains("wireTap")) {
wireTap = true;
break;
}
}
assertTrue("Should have a wire tap thread pool", wireTap);
// stop
mbeanServer.invoke(on, "stop", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be stopped", ServiceStatus.Stopped.name(), state);
// remove
mbeanServer.invoke(on, "remove", null, null);
// should not be registered anymore
boolean registered = mbeanServer.isRegistered(on);
assertFalse("Route mbean should have been unregistered", registered);
// and a thread pool less
set = mbeanServer.queryNames(new ObjectName("*:type=threadpools,*"), null);
wireTap = false;
for (ObjectName name : set) {
if (name.toString().contains("wireTap")) {
wireTap = true;
break;
}
}
assertFalse("Should not have a wire tap thread pool", wireTap);
}
use of javax.management.MBeanServer in project camel by apache.
the class ManagedRoutingSlipTest method testManageRoutingSlip.
public void testManageRoutingSlip() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MockEndpoint foo = getMockEndpoint("mock:foo");
foo.expectedMessageCount(2);
MockEndpoint bar = getMockEndpoint("mock:bar");
bar.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", "Hello World", "whereTo", "direct:foo,direct:foo,direct:bar");
assertMockEndpointsSatisfied();
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mysend\"");
// should be on route1
String routeId = (String) mbeanServer.getAttribute(on, "RouteId");
assertEquals("route1", routeId);
String camelId = (String) mbeanServer.getAttribute(on, "CamelId");
assertEquals("camel-1", camelId);
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals(ServiceStatus.Started.name(), state);
String lan = (String) mbeanServer.getAttribute(on, "ExpressionLanguage");
assertEquals("header", lan);
String uri = (String) mbeanServer.getAttribute(on, "Expression");
assertEquals("whereTo", uri);
TabularData data = (TabularData) mbeanServer.invoke(on, "extendedInformation", null, null);
assertNotNull(data);
assertEquals(2, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { false }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(3, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { true }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(6, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Routes a message through a series of steps that are pre-determined (the slip)"));
}
Aggregations