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