use of javax.management.ObjectName in project camel by apache.
the class ManagedCBRTest method testManagedCBR.
// CAMEL-4044: mbeans not registered for children of choice
public void testManagedCBR() 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=\"route\"");
assertTrue("MBean '" + on + "' not registered", mbeanServer.isRegistered(on));
on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"task-a\"");
assertTrue("MBean '" + on + "' not registered", mbeanServer.isRegistered(on));
on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"choice\"");
assertTrue("MBean '" + on + "' not registered", mbeanServer.isRegistered(on));
on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"task-b\"");
assertTrue("MBean '" + on + "' not registered", mbeanServer.isRegistered(on));
on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"task-c\"");
assertTrue("MBean '" + on + "' not registered", mbeanServer.isRegistered(on));
on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"task-d\"");
assertTrue("MBean '" + on + "' not registered", mbeanServer.isRegistered(on));
on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"task-e\"");
assertTrue("MBean '" + on + "' not registered", mbeanServer.isRegistered(on));
on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"task-done\"");
assertTrue("MBean '" + on + "' not registered", mbeanServer.isRegistered(on));
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedCamelContextDumpRoutesCoverageAsXml method testRouteCoverageStats.
public void testRouteCoverageStats() 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();
ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\"");
getMockEndpoint("mock:foo").expectedMessageCount(1);
getMockEndpoint("mock:bar").expectedMessageCount(2);
template.asyncSendBody("direct:start", "Hello World");
template.asyncSendBody("direct:bar", "Hi World");
template.asyncSendBody("direct:bar", "Bye World");
assertMockEndpointsSatisfied();
String xml = (String) mbeanServer.invoke(on, "dumpRoutesCoverageAsXml", null, null);
log.info(xml);
assertTrue(xml.contains("exchangesTotal=\"3\""));
assertTrue(xml.contains("exchangesTotal=\"2\""));
// should be valid XML
Document doc = context.getTypeConverter().convertTo(Document.class, xml);
assertNotNull(doc);
}
use of javax.management.ObjectName in project camel by apache.
the class BacklogTracerTest method testBacklogTracerNotRemoveOnDump.
@SuppressWarnings("unchecked")
public void testBacklogTracerNotRemoveOnDump() throws Exception {
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = new ObjectName("org.apache.camel:context=camel-1,type=tracer,name=BacklogTracer");
assertNotNull(on);
mbeanServer.isRegistered(on);
Boolean removeOnDump = (Boolean) mbeanServer.getAttribute(on, "RemoveOnDump");
assertEquals(Boolean.TRUE, removeOnDump);
// disable it
mbeanServer.setAttribute(on, new Attribute("RemoveOnDump", Boolean.FALSE));
Boolean enabled = (Boolean) mbeanServer.getAttribute(on, "Enabled");
assertEquals("Should not be enabled", Boolean.FALSE, enabled);
// enable it
mbeanServer.setAttribute(on, new Attribute("Enabled", Boolean.TRUE));
getMockEndpoint("mock:foo").expectedMessageCount(2);
getMockEndpoint("mock:bar").expectedMessageCount(2);
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
assertMockEndpointsSatisfied();
List<BacklogTracerEventMessage> events = (List<BacklogTracerEventMessage>) mbeanServer.invoke(on, "dumpAllTracedMessages", null, null);
assertNotNull(events);
assertEquals(6, events.size());
// and if we get again they are still there
events = (List<BacklogTracerEventMessage>) mbeanServer.invoke(on, "dumpAllTracedMessages", null, null);
assertNotNull(events);
assertEquals(6, events.size());
// send in another message
resetMocks();
getMockEndpoint("mock:foo").expectedMessageCount(1);
getMockEndpoint("mock:bar").expectedMessageCount(1);
template.sendBody("direct:start", "Hi World");
assertMockEndpointsSatisfied();
// and now we should have 3 more messages
events = (List<BacklogTracerEventMessage>) mbeanServer.invoke(on, "dumpAllTracedMessages", null, null);
assertNotNull(events);
assertEquals(9, events.size());
}
use of javax.management.ObjectName in project camel by apache.
the class BacklogTracerTest method testBacklogTracerEventMessage.
@SuppressWarnings("unchecked")
public void testBacklogTracerEventMessage() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = new ObjectName("org.apache.camel:context=camel-1,type=tracer,name=BacklogTracer");
assertNotNull(on);
assertTrue(mbeanServer.isRegistered(on));
Boolean enabled = (Boolean) mbeanServer.getAttribute(on, "Enabled");
assertEquals("Should not be enabled", Boolean.FALSE, enabled);
Integer size = (Integer) mbeanServer.getAttribute(on, "BacklogSize");
assertEquals("Should be 1000", 1000, size.intValue());
Boolean removeOnDump = (Boolean) mbeanServer.getAttribute(on, "RemoveOnDump");
assertEquals(Boolean.TRUE, removeOnDump);
// enable it
mbeanServer.setAttribute(on, new Attribute("Enabled", Boolean.TRUE));
getMockEndpoint("mock:foo").expectedMessageCount(2);
getMockEndpoint("mock:bar").expectedMessageCount(2);
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
assertMockEndpointsSatisfied();
List<Exchange> exchanges = getMockEndpoint("mock:foo").getReceivedExchanges();
List<BacklogTracerEventMessage> events = (List<BacklogTracerEventMessage>) mbeanServer.invoke(on, "dumpTracedMessages", new Object[] { "foo" }, new String[] { "java.lang.String" });
assertNotNull(events);
assertEquals(2, events.size());
BacklogTracerEventMessage event1 = events.get(0);
assertEquals("foo", event1.getToNode());
assertEquals(" <message exchangeId=\"" + exchanges.get(0).getExchangeId() + "\">\n" + " <body type=\"java.lang.String\">Hello World</body>\n" + " </message>", event1.getMessageAsXml());
BacklogTracerEventMessage event2 = events.get(1);
assertEquals("foo", event2.getToNode());
assertEquals(" <message exchangeId=\"" + exchanges.get(1).getExchangeId() + "\">\n" + " <body type=\"java.lang.String\">Bye World</body>\n" + " </message>", event2.getMessageAsXml());
}
use of javax.management.ObjectName in project camel by apache.
the class BacklogTracerTest method testBacklogTracerEventMessageAsXml.
public void testBacklogTracerEventMessageAsXml() throws Exception {
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = new ObjectName("org.apache.camel:context=camel-1,type=tracer,name=BacklogTracer");
assertNotNull(on);
mbeanServer.isRegistered(on);
Boolean enabled = (Boolean) mbeanServer.getAttribute(on, "Enabled");
assertEquals("Should not be enabled", Boolean.FALSE, enabled);
Integer size = (Integer) mbeanServer.getAttribute(on, "BacklogSize");
assertEquals("Should be 1000", 1000, size.intValue());
// enable it
mbeanServer.setAttribute(on, new Attribute("Enabled", Boolean.TRUE));
getMockEndpoint("mock:foo").expectedMessageCount(2);
getMockEndpoint("mock:bar").expectedMessageCount(2);
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
assertMockEndpointsSatisfied();
String events = (String) mbeanServer.invoke(on, "dumpTracedMessagesAsXml", new Object[] { "foo" }, new String[] { "java.lang.String" });
assertNotNull(events);
log.info(events);
// should be valid XML
Document dom = context.getTypeConverter().convertTo(Document.class, events);
assertNotNull(dom);
NodeList list = dom.getElementsByTagName("backlogTracerEventMessage");
assertEquals(2, list.getLength());
}
Aggregations