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