1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.cxf.jaxws;
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
18 import org.apache.commons.httpclient.HttpClient;
19 import org.apache.commons.httpclient.HttpMethod;
20 import org.apache.commons.httpclient.methods.GetMethod;
21
22 public class CxfJaxWsTestCase extends FunctionalTestCase
23 {
24 public void testEchoService() throws Exception
25 {
26 String url = "cxf:http://localhost:63081/services/Echo?method=echo";
27
28 MuleClient client = new MuleClient(muleContext);
29 MuleMessage result = client.send(url, "Hello!", null);
30 assertEquals("Hello!", result.getPayload());
31 }
32
33 public void testOneWay() throws Exception
34 {
35 String url = "cxf:http://localhost:63081/services/async?method=send";
36
37 MuleClient client = new MuleClient(muleContext);
38 MuleMessage result = client.send(url, "Hello!", null);
39 assertEquals(NullPayload.getInstance(), result.getPayload());
40 }
41
42 public void testHttpCall() throws Exception
43 {
44 HttpClient client = new HttpClient();
45
46
47
48
49 HttpMethod httpMethod = new GetMethod("http://localhost:63081/services/Echo/echo/text/hello");
50
51 assertEquals(200, client.executeMethod(httpMethod));
52
53
54
55 assertEquals(
56 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
57 "<soap:Body>" +
58 "<ns2:echoResponse xmlns:ns2=\"http://testmodels.cxf.module.mule.org/\">" +
59 "<text>hello</text>" +
60 "</ns2:echoResponse>" +
61 "</soap:Body>" +
62 "</soap:Envelope>", httpMethod.getResponseBodyAsString());
63 }
64
65 public void testWebServiceContext() throws Exception
66 {
67 String url = "cxf:http://localhost:63081/services/Echo?method=ensureWebSerivceContextIsSet";
68
69 MuleClient client = new MuleClient(muleContext);
70 MuleMessage result = client.send(url, TEST_MESSAGE, null);
71 assertEquals(TEST_MESSAGE, result.getPayload());
72 }
73
74 @Override
75 protected String getConfigResources()
76 {
77 return "jaxws-conf.xml";
78 }
79 }