1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.wsdl.wsdl11.provider;
18
19 import java.util.Properties;
20 import javax.wsdl.Binding;
21 import javax.wsdl.Definition;
22 import javax.wsdl.Fault;
23 import javax.wsdl.Input;
24 import javax.wsdl.Operation;
25 import javax.wsdl.OperationType;
26 import javax.wsdl.Output;
27 import javax.wsdl.Port;
28 import javax.wsdl.PortType;
29 import javax.wsdl.Service;
30 import javax.wsdl.factory.WSDLFactory;
31 import javax.xml.namespace.QName;
32
33 import junit.framework.TestCase;
34
35 public class SoapProviderTest extends TestCase {
36
37 private SoapProvider provider;
38
39 private Definition definition;
40
41 protected void setUp() throws Exception {
42 provider = new SoapProvider();
43 WSDLFactory factory = WSDLFactory.newInstance();
44 definition = factory.newDefinition();
45 }
46
47 public void testPopulateBinding() throws Exception {
48 String namespace = "http://springframework.org/spring-ws";
49 definition.addNamespace("tns", namespace);
50 definition.setTargetNamespace(namespace);
51
52 PortType portType = definition.createPortType();
53 portType.setQName(new QName(namespace, "PortType"));
54 portType.setUndefined(false);
55 definition.addPortType(portType);
56 Operation operation = definition.createOperation();
57 operation.setName("Operation");
58 operation.setUndefined(false);
59 operation.setStyle(OperationType.REQUEST_RESPONSE);
60 portType.addOperation(operation);
61 Input input = definition.createInput();
62 input.setName("Input");
63 operation.setInput(input);
64 Output output = definition.createOutput();
65 output.setName("Output");
66 operation.setOutput(output);
67 Fault fault = definition.createFault();
68 fault.setName("Fault");
69 operation.addFault(fault);
70
71 Properties soapActions = new Properties();
72 soapActions.setProperty("Operation", namespace + "/Action");
73 provider.setSoapActions(soapActions);
74
75 provider.setServiceName("Service");
76
77 String locationUri = "http://localhost:8080/services";
78 provider.setLocationUri(locationUri);
79
80 provider.setCreateSoap11Binding(true);
81 provider.setCreateSoap12Binding(true);
82
83 provider.addBindings(definition);
84 provider.addServices(definition);
85
86 Binding binding = definition.getBinding(new QName(namespace, "PortTypeSoap11"));
87 assertNotNull("No SOAP 1.1 binding created", binding);
88 binding = definition.getBinding(new QName(namespace, "PortTypeSoap12"));
89 assertNotNull("No SOAP 1.2 binding created", binding);
90
91 Service service = definition.getService(new QName(namespace, "Service"));
92 assertNotNull("No Service created", service);
93 assertEquals("Invalid amount of ports", 2, service.getPorts().size());
94
95 Port port = service.getPort("PortTypeSoap11");
96 assertNotNull("No SOAP 1.1 port created", port);
97 port = service.getPort("PortTypeSoap12");
98 assertNotNull("No SOAP 1.2 port created", port);
99 }
100
101
102 }