1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.soap.axis;
12
13 import org.mule.DefaultMuleMessage;
14 import org.mule.api.MuleMessage;
15 import org.mule.api.transport.DispatchException;
16 import org.mule.module.client.MuleClient;
17 import org.mule.tck.FunctionalTestCase;
18 import org.mule.tck.testmodels.services.TestComponent;
19 import org.mule.tck.testmodels.services.TestComponentException;
20
21 public class AxisExceptionTestCase extends FunctionalTestCase
22 {
23
24 protected String getConfigResources()
25 {
26 return "axis-using-cxf-config.xml";
27 }
28
29 public void testSuccessCall() throws Exception
30 {
31 MuleClient client = new MuleClient();
32 MuleMessage reply = client.send("axis:http://localhost:63381/services/AxisService?method=receive",
33 new DefaultMuleMessage("test"));
34
35 assertNotNull(reply);
36 assertNotNull(reply.getPayload());
37 assertTrue(reply.getPayload() instanceof String);
38 assertEquals("Received: test", reply.getPayloadAsString());
39 }
40
41 public void testExceptionCall() throws Exception
42 {
43 try
44 {
45 MuleClient client = new MuleClient();
46 client.send("axis:http://localhost:63381/services/AxisService?method=throwsException",
47 new DefaultMuleMessage("test"));
48
49 fail("should have thrown exception");
50 }
51 catch (DispatchException dispatchExc)
52 {
53 Throwable t = dispatchExc.getCause();
54
55 assertNotNull(t);
56 assertEquals(TestComponentException.class.getName() + ": "
57 + TestComponentException.MESSAGE_PREFIX + TestComponent.EXCEPTION_MESSAGE,
58 t.getMessage());
59 }
60 }
61
62 public void testExceptionBasedRoutingForAxis() throws Exception
63 {
64 MuleClient client = new MuleClient();
65 MuleMessage reply = client.send("vm://localhost.test", new DefaultMuleMessage("test"));
66
67 assertNotNull(reply);
68 assertNotNull(reply.getPayload());
69 assertTrue(reply.getPayload() instanceof String);
70 assertEquals("Received: test", reply.getPayloadAsString());
71 }
72 }