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.api.MuleRuntimeException;
15 import org.mule.config.i18n.MessageFactory;
16 import org.mule.module.client.MuleClient;
17 import org.mule.tck.FunctionalTestCase;
18
19 public class BindingExceptionOnInterfaceMethodTestCase extends FunctionalTestCase
20 {
21
22 private static final String PREFIX = "Exception in service component: ";
23
24 @Override
25 protected String getConfigResources()
26 {
27 return "org/mule/test/integration/routing/nested/binding-exception-on-interface-method.xml";
28 }
29
30 public void testExceptionOnBinding() throws Exception
31 {
32 MuleClient client = new MuleClient(muleContext);
33 MuleMessage reply = client.send("vm://invoker.in", TEST_MESSAGE, null);
34 assertNotNull(reply);
35 String payload = reply.getPayloadAsString();
36 assertTrue(payload.contains("MuleRuntimeException"));
37 assertTrue(payload.contains(PREFIX));
38 }
39
40 public static class Component
41 {
42 private BindigInterface binding;
43
44 public String invoke(String payload)
45 {
46 try
47 {
48 binding.process(payload, Integer.valueOf(0xC0DE));
49 }
50 catch (MuleRuntimeException muleException)
51 {
52 return PREFIX + muleException.toString();
53 }
54
55 return "ERROR, should not have come here";
56 }
57
58 public BindigInterface getBinding()
59 {
60 return binding;
61 }
62
63 public void setBinding(BindigInterface binding)
64 {
65 this.binding = binding;
66 }
67 }
68
69 public static class ExceptionThrowingService
70 {
71 public String process(String s, Integer v)
72 {
73 throw new MuleRuntimeException(MessageFactory.createStaticMessage("Boom"));
74 }
75 }
76
77 public interface BindigInterface
78 {
79 String process(String s, Integer v) throws MuleRuntimeException;
80 }
81
82 }
83
84