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.module.client.MuleClient;
16 import org.mule.tck.junit4.FunctionalTestCase;
17 import org.mule.tck.junit4.rule.DynamicPort;
18
19 import org.junit.Rule;
20 import org.junit.Test;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertTrue;
25 import static org.junit.Assert.fail;
26
27 public class AxisExceptionTestCase extends FunctionalTestCase
28 {
29
30 @Rule
31 public DynamicPort dynamicPort1 = new DynamicPort("port1");
32
33 @Rule
34 public DynamicPort dynamicPort2 = new DynamicPort("port2");
35
36 @Override
37 protected String getConfigResources()
38 {
39 return "axis-using-cxf-config.xml";
40 }
41
42 @Test
43 public void testSuccessCall() throws Exception
44 {
45 MuleClient client = new MuleClient(muleContext);
46 MuleMessage reply = client.send("axis:http://localhost:" + dynamicPort1.getNumber() + "/services/AxisService?method=receive",
47 new DefaultMuleMessage("test", muleContext));
48
49 assertNotNull(reply);
50 assertNotNull(reply.getPayload());
51 assertTrue(reply.getPayload() instanceof String);
52 assertEquals("Received: test", reply.getPayloadAsString());
53 }
54
55
56 @Test
57 public void testExceptionCall() throws Exception
58 {
59 MuleClient client = new MuleClient(muleContext);
60 try
61 {
62 client.send("axis:http://localhost:" + dynamicPort1.getNumber() + "/services/AxisService?method=throwsException", new DefaultMuleMessage("test", muleContext));
63 fail("should have thrown exception");
64 }
65 catch (Exception e)
66 {
67
68 }
69 }
70
71 @Test
72 public void testExceptionBasedRoutingForAxis() throws Exception
73 {
74 MuleClient client = new MuleClient(muleContext);
75 MuleMessage reply = client.send("vm://localhost.test", new DefaultMuleMessage("test", muleContext));
76
77 assertNotNull(reply);
78 assertNotNull(reply.getPayload());
79 assertTrue(reply.getPayload() instanceof String);
80 assertEquals("Received: test", reply.getPayloadAsString());
81 }
82
83 }