1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.soap.xfire;
12
13 import org.mule.extras.client.MuleClient;
14 import org.mule.providers.soap.xfire.testmodels.CustomFault;
15 import org.mule.providers.soap.xfire.testmodels.XFireEnabledFaultMessage;
16 import org.mule.tck.FunctionalTestCase;
17
18 import org.codehaus.xfire.fault.XFireFault;
19
20
21 public class XFireComponentExceptionStrategyTestCase extends FunctionalTestCase
22 {
23 public void testDefaultComponentExceptionStrategy() throws Exception
24 {
25 MuleClient client = new MuleClient();
26
27 try
28 {
29 client.send("xfire:http://localhost:63181/services/XFireDefault?method=testXFireException", "TEST", null);
30 }
31 catch (org.mule.umo.provider.DispatchException ex)
32 {
33 final Throwable t = ex.getCause();
34 assertNotNull("Cause should've been filled in.", t);
35 assertTrue(t instanceof XFireFault);
36 }
37 }
38
39 public void testHandledException() throws Exception
40 {
41 MuleClient client = new MuleClient();
42
43 try
44 {
45 client.send("xfire:http://localhost:63181/services/XFireWithExceptionStrategy?method=testXFireException", "TEST", null);
46 }
47 catch (org.mule.umo.provider.DispatchException ex)
48 {
49 final Throwable t = ex.getCause();
50 assertNotNull("Cause should've been filled in.", t);
51 assertTrue(t instanceof XFireEnabledFaultMessage);
52 XFireEnabledFaultMessage xfireMsg = (XFireEnabledFaultMessage) t;
53 CustomFault fault = xfireMsg.getFaultInfo();
54 assertNotNull(fault);
55 assertEquals("Custom Exception Message", fault.getDescription());
56 }
57 }
58
59
60 public void testUnhandledException() throws Exception
61 {
62 MuleClient client = new MuleClient();
63
64 try
65 {
66 client.send("xfire:http://localhost:63181/services/XFireWithExceptionStrategy?method=testNonXFireException", "TEST", null);
67 }
68 catch (org.mule.umo.provider.DispatchException ex)
69 {
70 final Throwable t = ex.getCause();
71 assertNotNull("Cause should've been filled in.", t);
72 assertTrue(t instanceof XFireFault);
73 }
74 }
75
76
77 protected String getConfigResources()
78 {
79 return "xfire-exception-strategy-conf.xml";
80 }
81 }