use of javax.management.ObjectName in project camel by apache.
the class ManagedInflightStatisticsTest method testManageStatisticsFailed.
public void testManageStatisticsFailed() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(1, set.size());
ObjectName on = set.iterator().next();
Long inflight = (Long) mbeanServer.getAttribute(on, "ExchangesInflight");
assertEquals(0, inflight.longValue());
Long ts = (Long) mbeanServer.getAttribute(on, "OldestInflightDuration");
assertNull(ts);
String id = (String) mbeanServer.getAttribute(on, "OldestInflightExchangeId");
assertNull(id);
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMessageCount(1);
// start some exchanges.
template.asyncSendBody("direct:start", 1000L);
Thread.sleep(500);
try {
template.sendBody("direct:start", "Kaboom");
fail("Should have thrown exception");
} catch (Exception e) {
// expected
}
inflight = (Long) mbeanServer.getAttribute(on, "ExchangesInflight");
assertEquals(1, inflight.longValue());
ts = (Long) mbeanServer.getAttribute(on, "OldestInflightDuration");
assertNotNull(ts);
id = (String) mbeanServer.getAttribute(on, "OldestInflightExchangeId");
assertNotNull(id);
assertMockEndpointsSatisfied();
// Lets wait for all the exchanges to complete.
Thread.sleep(500);
inflight = (Long) mbeanServer.getAttribute(on, "ExchangesInflight");
assertEquals(0, inflight.longValue());
ts = (Long) mbeanServer.getAttribute(on, "OldestInflightDuration");
assertNull(ts);
id = (String) mbeanServer.getAttribute(on, "OldestInflightExchangeId");
assertNull(id);
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedListComponentsTest method testListComponents.
public void testListComponents() 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=20-camel-1,type=context,name=\"camel-1\"");
// list all components found in classpath
TabularData data = (TabularData) mbeanServer.invoke(on, "listComponents", null, null);
assertTrue("There should be more than 20 components", data.size() > 20);
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedLoadBalancerTest method testLoadBalancer.
public void testLoadBalancer() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
getMockEndpoint("mock:a").expectedBodiesReceived("Hello World", "Hi World");
getMockEndpoint("mock:b").expectedBodiesReceived("Bye World");
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
template.sendBody("direct:start", "Hi World");
assertMockEndpointsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://a\"");
Long queueSize = (Long) mbeanServer.invoke(name, "queueSize", null, null);
assertEquals(2, queueSize.intValue());
name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://b\"");
queueSize = (Long) mbeanServer.invoke(name, "queueSize", null, null);
assertEquals(1, queueSize.intValue());
name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"myBalancer\"");
mbeanServer.isRegistered(name);
Long total = (Long) mbeanServer.getAttribute(name, "ExchangesTotal");
assertEquals(3, total.intValue());
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedCamelContextTest method testManagedCamelContextRemoveEndpoint.
public void testManagedCamelContextRemoveEndpoint() 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=19-camel-1,type=context,name=\"camel-1\"");
assertNull(context.hasEndpoint("seda:bar"));
// create a new endpoint
Object reply = mbeanServer.invoke(on, "createEndpoint", new Object[] { "seda:bar" }, new String[] { "java.lang.String" });
assertEquals(Boolean.TRUE, reply);
assertNotNull(context.hasEndpoint("seda:bar"));
ObjectName seda = ObjectName.getInstance("org.apache.camel:context=19-camel-1,type=endpoints,name=\"seda://bar\"");
boolean registered = mbeanServer.isRegistered(seda);
assertTrue("Should be registered " + seda, registered);
// remove it
Object num = mbeanServer.invoke(on, "removeEndpoints", new Object[] { "seda:*" }, new String[] { "java.lang.String" });
assertEquals(1, num);
assertNull(context.hasEndpoint("seda:bar"));
registered = mbeanServer.isRegistered(seda);
assertFalse("Should not be registered " + seda, registered);
// remove it again
num = mbeanServer.invoke(on, "removeEndpoints", new Object[] { "seda:*" }, new String[] { "java.lang.String" });
assertEquals(0, num);
assertNull(context.hasEndpoint("seda:bar"));
registered = mbeanServer.isRegistered(seda);
assertFalse("Should not be registered " + seda, registered);
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedCamelContextTest method testManagedCamelContextExplainEipModel.
public void testManagedCamelContextExplainEipModel() 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=19-camel-1,type=context,name=\"camel-1\"");
// get the json
String json = (String) mbeanServer.invoke(on, "explainEipJson", new Object[] { "aggregate", false }, new String[] { "java.lang.String", "boolean" });
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Aggregates many messages into a single message\""));
assertTrue(json.contains("\"label\": \"eip,routing\""));
assertTrue(json.contains("\"correlationExpression\": { \"kind\": \"expression\", \"displayName\": \"Correlation Expression\", \"required\": true, \"type\": \"object\""));
assertTrue(json.contains("\"discardOnCompletionTimeout\": { \"kind\": \"attribute\", \"displayName\": \"Discard On Completion Timeout\", \"required\": false, \"type\": \"boolean\""));
}
Aggregations