use of javax.management.ObjectName in project camel by apache.
the class BacklogTracerTest method testBacklogTracerEventMessageDumpAllAsXml.
public void testBacklogTracerEventMessageDumpAllAsXml() 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);
// 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, "dumpAllTracedMessagesAsXml", null, null);
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(6, list.getLength());
}
use of javax.management.ObjectName in project camel by apache.
the class JmxInstrumentationCustomMBeanTest method testManagedEndpoint.
public void testManagedEndpoint() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
assertDefaultDomain();
resolveMandatoryEndpoint("direct:start", DirectEndpoint.class);
ObjectName objName = new ObjectName(domainName + ":type=endpoints,*");
Set<ObjectName> s = mbsc.queryNames(objName, null);
assertEquals(2, s.size());
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedCamelContextPropertiesTest method testGetSetProperties.
public void testGetSetProperties() 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\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on));
String name = (String) mbeanServer.getAttribute(on, "CamelId");
assertEquals("camel-1", name);
// invoke operations
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
mbeanServer.invoke(on, "setProperty", new String[] { Exchange.LOG_DEBUG_BODY_MAX_CHARS, "-1" }, new String[] { "java.lang.String", "java.lang.String" });
mbeanServer.invoke(on, "setProperty", new String[] { Exchange.LOG_DEBUG_BODY_STREAMS, "true" }, new String[] { "java.lang.String", "java.lang.String" });
Object invoke = mbeanServer.invoke(on, "getProperty", new String[] { Exchange.LOG_DEBUG_BODY_MAX_CHARS }, new String[] { "java.lang.String" });
assertEquals("-1", invoke);
invoke = mbeanServer.invoke(on, "getProperty", new String[] { Exchange.LOG_DEBUG_BODY_STREAMS }, new String[] { "java.lang.String" });
assertEquals("true", invoke);
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedCamelContextSuspendResumeTest method testManagedCamelContext.
public void testManagedCamelContext() 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=context,name=\"camel-1\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on));
String name = (String) mbeanServer.getAttribute(on, "CamelId");
assertEquals("camel-1", name);
String uptime = (String) mbeanServer.getAttribute(on, "Uptime");
assertNotNull(uptime);
long uptimeMillis = (Long) mbeanServer.getAttribute(on, "UptimeMillis");
assertTrue(uptimeMillis > 0);
String status = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Started", status);
// invoke operations
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
Object reply = mbeanServer.invoke(on, "requestBody", new Object[] { "direct:foo", "Hello World" }, new String[] { "java.lang.String", "java.lang.Object" });
assertEquals("Bye World", reply);
// suspend Camel
mbeanServer.invoke(on, "suspend", null, null);
status = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Suspended", status);
// resume Camel
mbeanServer.invoke(on, "resume", null, null);
status = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Started", status);
reply = mbeanServer.invoke(on, "requestBody", new Object[] { "direct:foo", "Hello Camel" }, new String[] { "java.lang.String", "java.lang.Object" });
assertEquals("Bye World", reply);
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedCamelContextTest method testManagedCamelContextExplainComponentModel.
public void testManagedCamelContextExplainComponentModel() 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, "explainComponentJson", new Object[] { "seda", false }, new String[] { "java.lang.String", "boolean" });
assertNotNull(json);
assertTrue(json.contains("\"label\": \"core,endpoint\""));
assertTrue(json.contains("\"queueSize\": { \"kind\": \"property\", \"group\": \"advanced\", \"label\": \"advanced\""));
}
Aggregations