use of javax.management.openmbean.TabularData in project camel by apache.
the class ManagedCircuitBreakerLoadBalancerTest method testManageCircuitBreakerLoadBalancer.
public void testManageCircuitBreakerLoadBalancer() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
getMockEndpoint("mock:foo").whenExchangeReceived(1, new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new SQLException("Forced");
}
});
MockEndpoint foo = getMockEndpoint("mock:foo");
foo.expectedBodiesReceived("Hello World", "Bye World");
try {
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");
fail("Should fail");
} catch (Exception e) {
assertIsInstanceOf(SQLException.class, e.getCause());
assertEquals("Forced", e.getCause().getMessage());
}
template.sendBodyAndHeader("direct:start", "Bye World", "foo", "123");
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);
Integer size = (Integer) mbeanServer.getAttribute(on, "Size");
assertEquals(1, size.intValue());
Long half = (Long) mbeanServer.getAttribute(on, "HalfOpenAfter");
assertEquals(5000, half.longValue());
Integer attempts = (Integer) mbeanServer.getAttribute(on, "Threshold");
assertEquals(2, attempts.intValue());
String exceptions = (String) mbeanServer.getAttribute(on, "Exceptions");
assertEquals("java.io.IOException,java.sql.SQLException", exceptions);
String cbState = (String) mbeanServer.getAttribute(on, "CircuitBreakerState");
assertEquals("closed", cbState);
String dump = (String) mbeanServer.invoke(on, "dumpState", null, null);
assertTrue(dump.startsWith("State closed, failures 0, closed since"));
TabularData data = (TabularData) mbeanServer.invoke(on, "exceptionStatistics", null, null);
assertNotNull(data);
assertEquals(2, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { false }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(2, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { true }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(5, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Balances message processing among a number of nodes"));
}
use of javax.management.openmbean.TabularData in project camel by apache.
the class ManagedConvertBodyTest method testManageConvertBody.
public void testManageConvertBody() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MockEndpoint foo = getMockEndpoint("mock:foo");
foo.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");
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, "Type");
assertEquals("byte[]", uri);
TabularData data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { false }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(2, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { true }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(4, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Converts the message body to another type"));
assertTrue(json.contains("byte[]"));
}
use of javax.management.openmbean.TabularData in project camel by apache.
the class ManagedFailoverLoadBalancerTest method testManageFailoverLoadBalancer.
public void testManageFailoverLoadBalancer() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
getMockEndpoint("mock:foo").whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new IOException("Forced");
}
});
MockEndpoint bar = getMockEndpoint("mock:bar");
bar.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");
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);
Integer size = (Integer) mbeanServer.getAttribute(on, "Size");
assertEquals(2, size.intValue());
Boolean roundRobin = (Boolean) mbeanServer.getAttribute(on, "RoundRobin");
assertEquals(true, roundRobin.booleanValue());
Boolean sticky = (Boolean) mbeanServer.getAttribute(on, "Sticky");
assertEquals(true, sticky.booleanValue());
Integer attempts = (Integer) mbeanServer.getAttribute(on, "MaximumFailoverAttempts");
assertEquals(3, attempts.intValue());
String exceptions = (String) mbeanServer.getAttribute(on, "Exceptions");
assertEquals("java.io.IOException,java.sql.SQLException", exceptions);
String id = (String) mbeanServer.getAttribute(on, "LastGoodProcessorId");
assertEquals("bar", id);
TabularData data = (TabularData) mbeanServer.invoke(on, "exceptionStatistics", 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(5, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Balances message processing among a number of nodes"));
}
use of javax.management.openmbean.TabularData 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.openmbean.TabularData in project camel by apache.
the class ManagedRecipientListTest method testManageRecipientList.
public void testManageRecipientList() 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", "mock:foo");
template.sendBodyAndHeader("direct:start", "Bye World", "whereto", "mock:foo");
template.sendBodyAndHeader("direct:start", "Hi World", "whereto", "mock: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);
Boolean parallel = (Boolean) mbeanServer.getAttribute(on, "ParallelProcessing");
assertEquals(false, parallel.booleanValue());
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(2, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { true }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(18, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Routes messages to a number of dynamically specified recipients (dynamic to)"));
}
Aggregations