1   /*
2    * Copyright ${YEAR} the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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 junit.framework.TestCase;
27  
28  public class SuffixBasedPortTypesProviderTest extends TestCase {
29  
30      private SuffixBasedPortTypesProvider provider;
31  
32      private Definition definition;
33  
34      protected void setUp() throws Exception {
35          provider = new SuffixBasedPortTypesProvider();
36          WSDLFactory factory = WSDLFactory.newInstance();
37          definition = factory.newDefinition();
38      }
39  
40      public void testAddPortTypes() throws Exception {
41          String namespace = "http://springframework.org/spring-ws";
42          definition.addNamespace("tns", namespace);
43          definition.setTargetNamespace(namespace);
44  
45          Message message = definition.createMessage();
46          message.setQName(new QName(namespace, "OperationRequest"));
47          definition.addMessage(message);
48  
49          message = definition.createMessage();
50          message.setQName(new QName(namespace, "OperationResponse"));
51          definition.addMessage(message);
52  
53          message = definition.createMessage();
54          message.setQName(new QName(namespace, "OperationFault"));
55          definition.addMessage(message);
56  
57          provider.setPortTypeName("PortType");
58          provider.addPortTypes(definition);
59  
60          PortType portType = definition.getPortType(new QName(namespace, "PortType"));
61          assertNotNull("No port type created", portType);
62  
63          Operation operation = portType.getOperation("Operation", "OperationRequest", "OperationResponse");
64          assertNotNull("No operation created", operation);
65          assertNotNull("No input created", operation.getInput());
66          assertNotNull("No output created", operation.getOutput());
67          assertFalse("No fault created", operation.getFaults().isEmpty());
68      }
69  }