Search in sources :

Example 31 with DefaultExchange

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]);
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) Method(java.lang.reflect.Method)

Example 32 with DefaultExchange

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());
    }
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage)

Example 33 with DefaultExchange

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!");
    }
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange)

Example 34 with DefaultExchange

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)
    }
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange)

Example 35 with DefaultExchange

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!");
    }
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange)

Aggregations

DefaultExchange (org.apache.camel.impl.DefaultExchange)473 Exchange (org.apache.camel.Exchange)381 Test (org.junit.Test)254 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)127 CamelContext (org.apache.camel.CamelContext)54 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)39 HashMap (java.util.HashMap)33 Message (org.apache.camel.Message)32 Before (org.junit.Before)32 Tx (org.nhindirect.common.tx.model.Tx)31 ESMClass (org.jsmpp.bean.ESMClass)30 Processor (org.apache.camel.Processor)22 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)22 Expression (org.apache.camel.Expression)21 File (java.io.File)20 DefaultMessage (org.apache.camel.impl.DefaultMessage)20 ArrayList (java.util.ArrayList)18 ByteArrayInputStream (java.io.ByteArrayInputStream)17 URL (java.net.URL)16 Date (java.util.Date)16