1
2
3
4
5
6
7
8
9
10
11 package org.mule.example.echo;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.client.MuleClient;
15 import org.mule.tck.FunctionalTestCase;
16 import org.mule.transport.NullPayload;
17 import org.mule.util.IOUtils;
18
19 import java.io.IOException;
20 import java.util.HashMap;
21 import java.util.Map;
22
23 import org.custommonkey.xmlunit.XMLAssert;
24
25
26
27
28 public class CxfEchoTestCase extends FunctionalTestCase
29 {
30 private String expectedGetResponse;
31
32 @Override
33 protected String getConfigResources()
34 {
35 return "echo-cxf-config.xml";
36 }
37
38 @Override
39 protected void doSetUp() throws Exception
40 {
41 try
42 {
43 expectedGetResponse = IOUtils.getResourceAsString("echo-cxf-response.xml", getClass());
44 }
45 catch (IOException ioex)
46 {
47 fail(ioex.getMessage());
48 }
49 }
50
51 public void testGetEcho() throws Exception
52 {
53
54
55
56 MuleClient client = new MuleClient(muleContext);
57 Map<String, String> props = new HashMap<String, String>();
58 props.put("http.method", "GET");
59 MuleMessage result = client.send("http://localhost:65082/services/EchoUMO/echo/text/hello", "", props);
60 assertNotNull(result);
61 assertFalse(result.getPayload() instanceof NullPayload);
62 XMLAssert.assertXMLEqual(expectedGetResponse, result.getPayloadAsString());
63 }
64
65 public void testSoapPostEcho() throws Exception
66 {
67 MuleClient client = new MuleClient(muleContext);
68 MuleMessage result = client.send("cxf:http://localhost:65082/services/EchoUMO?method=echo",
69 "hello", null);
70 assertNotNull(result);
71 assertNull(result.getExceptionPayload());
72 assertFalse(result.getPayload() instanceof NullPayload);
73 assertEquals("hello", result.getPayload());
74 }
75 }