1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.soap.xfire;
12
13 import org.mule.extras.client.MuleClient;
14 import org.mule.tck.FunctionalTestCase;
15 import org.mule.umo.UMOMessage;
16 import org.mule.util.IOUtils;
17
18 import com.ibm.wsdl.xml.WSDLReaderImpl;
19
20 import javax.wsdl.Definition;
21 import javax.wsdl.extensions.soap.SOAPBinding;
22 import javax.wsdl.xml.WSDLReader;
23 import javax.xml.namespace.QName;
24
25 import org.custommonkey.xmlunit.XMLUnit;
26
27 public class XFireBasicTestCase extends FunctionalTestCase
28 {
29 private String echoWsdl;
30
31 protected void doPostFunctionalSetUp() throws Exception
32 {
33 super.doPostFunctionalSetUp();
34 echoWsdl = IOUtils.getResourceAsString("xfire-echo-service.wsdl", getClass());
35 XMLUnit.setIgnoreWhitespace(true);
36 }
37
38 public void testEchoService() throws Exception
39 {
40 MuleClient client = new MuleClient();
41 UMOMessage result = client.send("xfire:http://localhost:63081/services/echoService?method=echo", "Hello!", null);
42 assertEquals("Hello!", result.getPayload());
43 }
44 public void testEchoServiceSynchronous() throws Exception
45 {
46 MuleClient client = new MuleClient();
47 UMOMessage result = client.send("xfire:http://localhost:63083/services/echoService3?method=echo", "Hello!", null);
48 assertEquals("Hello!", result.getPayload());
49 }
50
51 public void testNoLocalBinding() throws Exception
52 {
53 WSDLReader wsdlReader = new WSDLReaderImpl();
54 Definition wsdlDefinition = wsdlReader.readWSDL("http://localhost:63084/services/echoService4?wsdl");
55 assertEquals(1, wsdlDefinition.getAllBindings().size());
56 SOAPBinding soapBinding = (SOAPBinding) wsdlDefinition.getBinding(new QName("http://www.muleumo.org", "echoService4HttpBinding")).getExtensibilityElements().get(0);
57 assertEquals("http://schemas.xmlsoap.org/soap/http", soapBinding.getTransportURI());
58 MuleClient client = new MuleClient();
59 UMOMessage result = client.send("xfire:http://localhost:63084/services/echoService4?method=echo", "Hello!", null);
60 assertEquals("Hello!", result.getPayload());
61 }
62
63 public void testEchoWsdl() throws Exception
64 {
65 MuleClient client = new MuleClient();
66 UMOMessage result = client.receive("http://localhost:63081/services/echoService?wsdl", 5000);
67 assertNotNull(result.getPayload());
68 XMLUnit.compareXML(echoWsdl, result.getPayload().toString());
69 }
70
71 protected String getConfigResources()
72 {
73 return "xfire-basic-conf.xml";
74 }
75 }
76