1
2
3
4
5
6
7 package org.mule.test.integration.routing.nested;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.module.client.MuleClient;
11 import org.mule.tck.junit4.FunctionalTestCase;
12
13 import org.junit.Test;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertNotNull;
17 import static org.junit.Assert.assertNull;
18 import static org.junit.Assert.assertTrue;
19
20 public class BindingReturnTypeTestCase extends FunctionalTestCase
21 {
22
23 private static final String PROCESSED = "Processed";
24 private static final int MAGIC_NUMBER = 0xC0DE;
25
26 @Override
27 protected String getConfigResources()
28 {
29 return "org/mule/test/integration/routing/nested/binding-returns-message.xml";
30 }
31
32 @Test
33 public void testInvokeBinding() throws Exception
34 {
35 MuleClient client = new MuleClient(muleContext);
36 MuleMessage response = client.send("vm://invoker.in", TEST_MESSAGE, null);
37 assertNotNull(response);
38 assertNull(response.getExceptionPayload());
39
40 assertTrue(response.getInboundProperty(PROCESSED, false));
41
42 String expected = "Hello " + TEST_MESSAGE + " " + MAGIC_NUMBER;
43 assertEquals(expected, response.getPayload());
44 }
45
46 public static class Component
47 {
48 private BindingInterface binding;
49
50 public Object invoke(String s)
51 {
52 MuleMessage result = binding.process(s, new Integer(MAGIC_NUMBER));
53 result.setOutboundProperty(PROCESSED, Boolean.TRUE);
54 return result;
55 }
56
57 public void setBindingInterface(BindingInterface hello)
58 {
59 this.binding = hello;
60 }
61
62 public BindingInterface getBindingInterface()
63 {
64 return binding;
65 }
66 }
67
68 public interface BindingInterface
69 {
70 MuleMessage process(String s, Integer v);
71 }
72
73 }
74
75