1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.cxf;
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.http.HttpConnector;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 public class ProxyTestCase extends FunctionalTestCase
22 {
23 String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
24 + "<soap:Body><test xmlns=\"http://foo\"> foo </test>" + "</soap:Body>" + "</soap:Envelope>";
25
26
27 public void testServerWithEcho() throws Exception
28 {
29 MuleClient client = new MuleClient();
30 MuleMessage result = client.send("http://localhost:63081/services/Echo", msg, null);
31 String resString = result.getPayloadAsString();
32
33 assertTrue(resString.indexOf("<test xmlns=\"http://foo\"> foo </test>") != -1);
34 }
35
36 public void testServerClientProxy() throws Exception
37 {
38 String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
39 + "<soap:Body> <test xmlns=\"http://foo\"></test>" + "</soap:Body>" + "</soap:Envelope>";
40
41 MuleClient client = new MuleClient();
42 MuleMessage result = client.send("http://localhost:63081/services/proxy", msg, null);
43 String resString = result.getPayloadAsString();
44 assertTrue(resString.indexOf("<test xmlns=\"http://foo\"") != -1);
45 }
46
47 public void testServerClientProxyWithTransform() throws Exception
48 {
49 String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
50 + "<soap:Body> <test xmlns=\"http://foo\"></test>" + "</soap:Body>" + "</soap:Envelope>";
51
52 MuleClient client = new MuleClient();
53 MuleMessage result = client.send("http://localhost:63081/services/proxyWithTransform", msg, null);
54 String resString = result.getPayloadAsString();
55 assertTrue(resString.indexOf("<transformed xmlns=\"http://foo\">") != -1);
56 }
57
58 public void testProxyWithDatabinding() throws Exception
59 {
60 String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
61 + "<soap:Body><greetMe xmlns=\"http://apache.org/hello_world_soap_http/types\"><requestType>Dan</requestType></greetMe>" +
62 "</soap:Body>" + "</soap:Envelope>";
63
64 MuleClient client = new MuleClient();
65 MuleMessage result = client.send("http://localhost:63081/services/greeterProxy", msg, null);
66 String resString = result.getPayloadAsString();
67 assertTrue(resString.indexOf("greetMeResponse") != -1);
68 }
69
70 public void testSoapActionRouting() throws Exception
71 {
72 String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
73 + "<soap:Body> <test xmlns=\"http://foo\"></test>" + "</soap:Body>" + "</soap:Envelope>";
74
75 Map<String, Object> httpHeaders = new HashMap<String, Object>();
76
77 Map<String, Object> props = new HashMap<String, Object>();
78 props.put(HttpConnector.HTTP_CUSTOM_HEADERS_MAP_PROPERTY, httpHeaders);
79 props.put("SOAPAction", "http://acme.com/transform");
80
81 MuleClient client = new MuleClient();
82 MuleMessage result = client.send("http://localhost:63081/services/routeBasedOnSoapAction", msg, props);
83 String resString = result.getPayloadAsString();
84 System.out.println(resString);
85 assertTrue(resString.indexOf("<transformed xmlns=\"http://foo\">") != -1);
86 }
87
88 protected String getConfigResources()
89 {
90 return "proxy-conf.xml";
91 }
92
93 }