1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.cxf.payload;
12
13 import org.mule.api.MuleContext;
14 import org.mule.api.MuleException;
15 import org.mule.api.transport.DispatchException;
16 import org.mule.module.client.MuleClient;
17 import org.mule.module.cxf.CxfOutboundMessageProcessor;
18
19 import junit.framework.TestCase;
20
21
22
23
24
25
26
27
28 abstract class AbstractCallAndExpectIllegalArgumentException implements CallAndExpect
29 {
30 private final String outputEndpointName;
31 private final Object payload;
32 private final MuleContext muleContext;
33
34 public AbstractCallAndExpectIllegalArgumentException(String outputEndpointName,
35 Object payload,
36 MuleContext muleContext)
37 {
38 this.outputEndpointName = outputEndpointName;
39 this.payload = payload;
40 this.muleContext = muleContext;
41 }
42
43 public void callEndpointAndExecuteAsserts() throws MuleException
44 {
45 MuleClient client = new MuleClient(muleContext);
46 try
47 {
48 client.send(outputEndpointName, payload, null);
49 TestCase.fail(here() + " should have thrown an exception");
50 }
51 catch (MuleException e)
52 {
53 e.printStackTrace();
54 TestCase.assertTrue(here() + ", exception {" + e + "} must be a "
55 + DispatchException.class.getSimpleName(), e instanceof DispatchException);
56 TestCase.assertTrue(here() + ", exception.getCause() {" + e + "} must be a "
57 + IllegalArgumentException.class.getName(),
58 e.getCause() instanceof IllegalArgumentException);
59 TestCase.assertEquals(here(), expectedIllegalArgumentExceptionMessage(), e.getCause()
60 .getMessage());
61 }
62 }
63
64 private String here()
65 {
66 return "In [" + outputEndpointName + "," + payload + "]";
67 }
68
69 public abstract String expectedIllegalArgumentExceptionMessage();
70 }