use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class BeanInfoAMoreComplexOverloadedTest method testRequestB.
public void testRequestB() throws Exception {
BeanInfo beanInfo = new BeanInfo(context, Bean.class);
Message message = new DefaultMessage();
message.setBody(new RequestB());
Exchange exchange = new DefaultExchange(context);
exchange.setIn(message);
MethodInvocation methodInvocation = beanInfo.createInvocation(new Bean(), exchange);
Method method = methodInvocation.getMethod();
assertEquals("doSomething", method.getName());
assertEquals(RequestB.class, method.getGenericParameterTypes()[0]);
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class BeanInfoAMoreComplexOverloadedTest method testAmbigious.
public void testAmbigious() throws Exception {
BeanInfo beanInfo = new BeanInfo(context, Bean.class);
Message message = new DefaultMessage();
message.setBody("Hello World");
Exchange exchange = new DefaultExchange(context);
exchange.setIn(message);
try {
beanInfo.createInvocation(new Bean(), exchange);
fail("Should have thrown an exception");
} catch (AmbiguousMethodCallException e) {
assertEquals(2, e.getMethods().size());
}
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class BeanInfoInheritanceTest method testInheritance.
public void testInheritance() throws Exception {
BeanInfo beanInfo = new BeanInfo(context, Y.class);
DefaultExchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(new Request());
try {
MethodInvocation mi = beanInfo.createInvocation(null, exchange);
assertNotNull(mi);
assertEquals("process", mi.getMethod().getName());
assertEquals("Y", mi.getMethod().getDeclaringClass().getSimpleName());
} catch (AmbiguousMethodCallException e) {
fail("This should not be ambiguous!");
}
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class BeanInfoInheritanceTest method testInheritanceAndOverload.
public void testInheritanceAndOverload() throws Exception {
BeanInfo beanInfo = new BeanInfo(context, Z.class);
DefaultExchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(new Request());
try {
beanInfo.createInvocation(null, exchange);
fail("This should be ambiguous!");
} catch (AmbiguousMethodCallException e) {
// expected (currently not supported in camel)
}
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class BeanInfoWithBridgedMethodTest method testBridgedMethod.
public void testBridgedMethod() throws Exception {
BeanInfo beanInfo = new BeanInfo(context, MyService.class);
DefaultExchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(new Request(1));
try {
MyService myService = new MyService();
MethodInvocation mi = beanInfo.createInvocation(null, exchange);
assertEquals("MyService", mi.getMethod().getDeclaringClass().getSimpleName());
assertEquals(2, mi.getMethod().invoke(myService, new Request(1)));
} catch (AmbiguousMethodCallException e) {
fail("This should not be ambiguous!");
}
}
Aggregations