1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.client;
12
13 import org.mule.api.ExceptionPayload;
14 import org.mule.api.MuleMessage;
15 import org.mule.api.endpoint.MalformedEndpointException;
16 import org.mule.api.transformer.TransformerException;
17 import org.mule.api.transformer.TransformerMessagingException;
18 import org.mule.module.client.MuleClient;
19 import org.mule.module.client.RemoteDispatcher;
20 import org.mule.tck.FunctionalTestCase;
21 import org.mule.tck.exceptions.FunctionalTestException;
22
23 import java.util.Date;
24
25 public class RemoteExceptionTestCase extends FunctionalTestCase
26 {
27
28 protected String getConfigResources()
29 {
30 return "org/mule/test/integration/client/remote-exception-config.xml";
31 }
32
33 public void testClientTransformerException() throws Exception
34 {
35 MuleClient client = new MuleClient(muleContext);
36 RemoteDispatcher dispatcher = client.getRemoteDispatcher("tcp://localhost:25551");
37 MuleMessage result = dispatcher.sendRemote("vm://test.queue.1", new Date(), null);
38 assertNotNull(result);
39 ExceptionPayload exceptionPayload = result.getExceptionPayload();
40 assertNotNull(exceptionPayload);
41 assertTrue(exceptionPayload.getException() instanceof TransformerMessagingException);
42 assertTrue(exceptionPayload.getRootException() instanceof Exception);
43 }
44
45 public void testClientMalformedEndpointException() throws Exception
46 {
47 MuleClient client = new MuleClient(muleContext);
48 RemoteDispatcher dispatcher = client.getRemoteDispatcher("tcp://localhost:25551");
49 MuleMessage result = dispatcher.sendRemote("test.queue.2", new Date(), null);
50 assertNotNull(result);
51 ExceptionPayload exceptionPayload = result.getExceptionPayload();
52 assertNotNull(exceptionPayload);
53 assertTrue(exceptionPayload.getRootException() instanceof MalformedEndpointException);
54 }
55
56 public void testClientComponentException() throws Exception
57 {
58 MuleClient client = new MuleClient(muleContext);
59 RemoteDispatcher dispatcher = client.getRemoteDispatcher("tcp://localhost:25551");
60 MuleMessage result = dispatcher.sendRemote("vm://test.queue.2", new Date(), null);
61 assertNotNull(result);
62 ExceptionPayload exceptionPayload = result.getExceptionPayload();
63 assertNotNull(exceptionPayload);
64 assertTrue(exceptionPayload.getRootException().getClass().getName(),
65 exceptionPayload.getRootException() instanceof FunctionalTestException);
66 assertEquals("Functional Test Service Exception", exceptionPayload.getRootException().getMessage());
67 }
68
69 }