use of javax.management.ObjectName in project camel by apache.
the class ManagedWireTapTest method testManageWireTap.
public void testManageWireTap() 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", "foo");
template.sendBodyAndHeader("direct:start", "Bye World", "whereto", "foo");
template.sendBodyAndHeader("direct:start", "Hi World", "whereto", "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 uri = (String) mbeanServer.getAttribute(on, "Uri");
assertEquals("direct:${header.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(11, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Routes a copy of a message (or creates a new message) to a secondary destination while continue routing the original message"));
assertTrue(json.contains(" \"uri\": { \"kind\": \"attribute\", \"required\": \"true\", \"type\": \"string\", \"javaType\": \"java.lang.String\"," + " \"deprecated\": \"false\", \"value\": \"direct:${header.whereto}\""));
}
use of javax.management.ObjectName in project camel by apache.
the class MultiInstanceProcessorTest method testCounters.
@Override
public void testCounters() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:end", MockEndpoint.class);
resultEndpoint.expectedBodiesReceived("<hello>world!</hello>", "<hello>world!</hello>");
sendBody("direct:start", "<hello>world!</hello>");
resultEndpoint.assertIsSatisfied();
verifyCounter(mbsc, new ObjectName(domainName + ":type=routes,*"));
}
use of javax.management.ObjectName in project camel by apache.
the class MultiInstanceProcessorTest method testMBeansRegistered.
/**
* It retrieves a mbean for each "to" processor instance in the query ":type=processor"
*/
@Override
public void testMBeansRegistered() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
assertDefaultDomain();
resolveMandatoryEndpoint("mock:end", MockEndpoint.class);
Set<ObjectName> s = mbsc.queryNames(new ObjectName(domainName + ":type=endpoints,*"), null);
assertEquals("Could not find 2 endpoints: " + s, 2, s.size());
s = mbsc.queryNames(new ObjectName(domainName + ":type=context,*"), null);
assertEquals("Could not find 1 context: " + s, 1, s.size());
s = mbsc.queryNames(new ObjectName(domainName + ":type=processors,*"), null);
assertEquals("Could not find 3 processor: " + s, 3, s.size());
s = mbsc.queryNames(new ObjectName(domainName + ":type=routes,*"), null);
assertEquals("Could not find 1 route: " + s, 1, s.size());
}
use of javax.management.ObjectName in project camel by apache.
the class RemoveRouteDefinitionTest method testStopRoute.
public void testStopRoute() 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.stopRoute("route1");
// route is only stopped so its still in JMX
set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(1, set.size());
}
use of javax.management.ObjectName 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());
}
Aggregations