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