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