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 javax.wsdl.Definition;
20 import javax.wsdl.Message;
21 import javax.wsdl.Operation;
22 import javax.wsdl.PortType;
23 import javax.wsdl.factory.WSDLFactory;
24 import javax.xml.namespace.QName;
25
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
29
30 public class SuffixBasedPortTypesProviderTest {
31
32 private SuffixBasedPortTypesProvider provider;
33
34 private Definition definition;
35
36 @Before
37 public void setUp() throws Exception {
38 provider = new SuffixBasedPortTypesProvider();
39 WSDLFactory factory = WSDLFactory.newInstance();
40 definition = factory.newDefinition();
41 }
42
43 @Test
44 public void testAddPortTypes() throws Exception {
45 String namespace = "http://springframework.org/spring-ws";
46 definition.addNamespace("tns", namespace);
47 definition.setTargetNamespace(namespace);
48
49 Message message = definition.createMessage();
50 message.setQName(new QName(namespace, "OperationRequest"));
51 definition.addMessage(message);
52
53 message = definition.createMessage();
54 message.setQName(new QName(namespace, "OperationResponse"));
55 definition.addMessage(message);
56
57 message = definition.createMessage();
58 message.setQName(new QName(namespace, "OperationFault"));
59 definition.addMessage(message);
60
61 provider.setPortTypeName("PortType");
62 provider.addPortTypes(definition);
63
64 PortType portType = definition.getPortType(new QName(namespace, "PortType"));
65 Assert.assertNotNull("No port type created", portType);
66
67 Operation operation = portType.getOperation("Operation", "OperationRequest", "OperationResponse");
68 Assert.assertNotNull("No operation created", operation);
69 Assert.assertNotNull("No input created", operation.getInput());
70 Assert.assertNotNull("No output created", operation.getOutput());
71 Assert.assertFalse("No fault created", operation.getFaults().isEmpty());
72 }
73 }