use of java.util.HashMap in project camel by apache.
the class ManagedRouteAddRemoveTest method testRouteAddRemoteRouteWithRecipientListAndRouteScopedOnException.
public void testRouteAddRemoteRouteWithRecipientListAndRouteScopedOnException() throws Exception {
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
result.assertIsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=services,*");
// number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
assertEquals(services, names.size());
log.info("Adding 2nd route");
// add a 2nd route
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:bar").routeId("bar").onException(Exception.class).handled(true).recipientList(header("error")).end().end().recipientList(header("bar")).throwException(new IllegalArgumentException("Forced"));
}
});
// and send a message to it
getMockEndpoint("mock:bar").expectedMessageCount(1);
getMockEndpoint("mock:error").expectedMessageCount(1);
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("error", "mock:error");
headers.put("bar", "mock:bar");
template.sendBodyAndHeaders("direct:bar", "Hello World", headers);
assertMockEndpointsSatisfied();
// there should still be the same number of services
names = mbeanServer.queryNames(on, null);
assertEquals(services, names.size());
// now stop and remove the 2nd route
log.info("Stopping 2nd route");
context.stopRoute("bar");
log.info("Removing 2nd route");
boolean removed = context.removeRoute("bar");
assertTrue(removed);
// there should still be the same number of services
names = mbeanServer.queryNames(on, null);
assertEquals(services, names.size());
log.info("Shutting down...");
}
use of java.util.HashMap in project camel by apache.
the class ApiMethodPropertiesHelperTest method testGetExchangeProperties.
@Test
public void testGetExchangeProperties() throws Exception {
final HashMap<String, Object> properties = new HashMap<String, Object>();
final DefaultExchange exchange = new DefaultExchange(new MockEndpoint());
exchange.getIn().setHeader(PROPERTY_1, VALUE_1);
exchange.getIn().setHeader(PROPERTY_2, VALUE_2);
exchange.getIn().setHeader(PROPERTY_3, VALUE_3);
exchange.getIn().setHeader(PROPERTY_4, VALUE_4);
exchange.getIn().setHeader(PROPERTY_5, VALUE_5);
propertiesHelper.getExchangeProperties(exchange, properties);
assertEquals(5, properties.size());
}
use of java.util.HashMap in project camel by apache.
the class IntrospectionSupportTest method testGetPropertiesSkipNull.
public void testGetPropertiesSkipNull() throws Exception {
ExampleBean bean = new ExampleBean();
bean.setName("Claus");
bean.setPrice(10.0);
bean.setId(null);
Map<String, Object> map = new HashMap<String, Object>();
IntrospectionSupport.getProperties(bean, map, null, false);
assertEquals(2, map.size());
assertEquals("Claus", map.get("name"));
String price = map.get("price").toString();
assertTrue(price.startsWith("10"));
}
use of java.util.HashMap in project camel by apache.
the class IntrospectionSupportTest method testGetPropertiesOptionPrefix.
public void testGetPropertiesOptionPrefix() throws Exception {
ExampleBean bean = new ExampleBean();
bean.setName("Claus");
bean.setPrice(10.0);
bean.setId("123");
Map<String, Object> map = new HashMap<String, Object>();
IntrospectionSupport.getProperties(bean, map, "bean.");
assertEquals(3, map.size());
assertEquals("Claus", map.get("bean.name"));
String price = map.get("bean.price").toString();
assertTrue(price.startsWith("10"));
assertEquals("123", map.get("bean.id"));
}
use of java.util.HashMap in project camel by apache.
the class IntrospectionSupportTest method testGetProperties.
public void testGetProperties() throws Exception {
ExampleBean bean = new ExampleBean();
bean.setName("Claus");
bean.setPrice(10.0);
Map<String, Object> map = new HashMap<String, Object>();
IntrospectionSupport.getProperties(bean, map, null);
assertEquals(3, map.size());
assertEquals("Claus", map.get("name"));
String price = map.get("price").toString();
assertTrue(price.startsWith("10"));
assertEquals(null, map.get("id"));
}
Aggregations