1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.cxf;
12
13 import org.mule.api.MessagingException;
14 import org.mule.module.client.MuleClient;
15 import org.mule.module.cxf.testmodels.CustomFault;
16 import org.mule.module.cxf.testmodels.CxfEnabledFaultMessage;
17 import org.mule.tck.FunctionalTestCase;
18
19 import org.apache.cxf.binding.soap.SoapFault;
20 import org.apache.cxf.interceptor.Fault;
21
22 public class CxfComponentExceptionStrategyTestCase extends FunctionalTestCase
23 {
24 public void testDefaultComponentExceptionStrategy() throws Exception
25 {
26 MuleClient client = new MuleClient(muleContext);
27 try
28 {
29 client.send("cxf:http://localhost:63181/services/CxfDefault?method=testCxfException", "TEST", null);
30 fail("Exception expected");
31 }
32 catch (MessagingException e)
33 {
34 assertTrue(e.getCause().getCause() instanceof SoapFault);
35 }
36 }
37
38
39
40
41
42
43 public void xtestHandledException() throws Exception
44 {
45 MuleClient client = new MuleClient(muleContext);
46
47 try
48 {
49 client.send("cxf:http://localhost:63181/services/CxfWithExceptionStrategy?method=testCxfException", "TEST", null);
50 fail("Exception expected");
51 }
52 catch (MessagingException e)
53 {
54 Throwable t = e.getCause().getCause();
55 assertTrue(t instanceof CxfEnabledFaultMessage);
56 CustomFault fault = ((CxfEnabledFaultMessage) t).getFaultInfo();
57 assertNotNull(fault);
58 assertEquals("Custom Exception Message", fault.getDescription());
59 }
60 }
61
62 public void testUnhandledException() throws Exception
63 {
64 MuleClient client = new MuleClient(muleContext);
65 try
66 {
67 client.send("cxf:http://localhost:63181/services/CxfWithExceptionStrategy?method=testNonCxfException", "TEST", null);
68 fail("Exception expected");
69 }
70 catch (MessagingException e)
71 {
72 assertTrue(e.getCause().getCause() instanceof Fault);
73 }
74 }
75
76 protected String getConfigResources()
77 {
78 return "exception-strategy-conf.xml";
79 }
80 }