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.providers.soap.AbstractSoapUrlEndpointFunctionalTestCase;
16
17 import java.util.HashMap;
18 import java.util.Iterator;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.dom4j.Document;
23 import org.dom4j.DocumentHelper;
24 import org.dom4j.Element;
25
26 public class CxfConnectorHttpFunctionalTestCase extends AbstractSoapUrlEndpointFunctionalTestCase
27 {
28
29 protected String getTransportProtocol()
30 {
31 return "http";
32 }
33
34 protected String getSoapProvider()
35 {
36 return "cxf";
37 }
38
39 @Override
40 public void testRequest() throws Throwable
41 {
42
43 }
44
45
46
47
48 @SuppressWarnings("unchecked")
49 public void testBinding() throws Exception
50 {
51 String url = "http://localhost:62108/";
52 String folder = "mule/";
53 String componentName = "mycomponent";
54 String fullPath = url + folder + componentName;
55
56 MuleClient client = new MuleClient();
57 Map<String, Object> props = new HashMap<String, Object>();
58 props.put("http.method", "GET");
59 MuleMessage reply = client.send(fullPath + "?wsdl", folder + componentName + "?wsdl", props);
60
61 assertNotNull(reply);
62 assertNotNull(reply.getPayload());
63
64 Document document = DocumentHelper.parseText(reply.getPayloadAsString());
65 List nodes;
66
67 nodes = document.selectNodes("//wsdl:definitions/wsdl:service");
68
69 Element element = (Element) nodes.get(0);
70 assertEquals("TestServiceComponent", element.attribute("name").getStringValue());
71
72 nodes = document.selectNodes("//wsdl:definitions/wsdl:service/wsdl:port");
73
74 for (Iterator i = nodes.iterator(); i.hasNext();)
75 {
76 element = (Element) i.next();
77
78 if ((element.attribute("name").getStringValue().compareTo(componentName + "MulePort") == 0)
79 || (element.attribute("name").getStringValue().compareTo(componentName + "LocalPort") == 0))
80 {
81 Element tempElement = (Element) element.elements().get(0);
82 String mulePort = tempElement.attribute("location").getStringValue();
83 assertEquals(fullPath, mulePort);
84 }
85 }
86 }
87
88 public String getConfigResources()
89 {
90 return getTransportProtocol() + "-mule-config.xml";
91 }
92
93 }