KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > wsdl > SOAPActionTest


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
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.apache.wsdl;
18
19 import org.apache.axis2.wsdl.WSDLVersionWrapper;
20 import org.apache.axis2.wsdl.builder.WOMBuilderFactory;
21 import org.apache.wsdl.extensions.ExtensionConstants;
22 import org.apache.wsdl.extensions.SOAPOperation;
23
24 import javax.wsdl.Definition;
25 import javax.xml.namespace.QName JavaDoc;
26 import java.io.FileInputStream JavaDoc;
27 import java.io.InputStream JavaDoc;
28 import java.util.Iterator JavaDoc;
29
30 /**
31  * @author chathura@opensource.lk
32  *
33  */

34 public class SOAPActionTest extends AbstractTestCase {
35
36     private WSDLDescription womDescription = null;
37
38     private Definition wsdl4jDefinition = null;
39
40     public SOAPActionTest(String JavaDoc args) {
41         super(args);
42     }
43
44     protected void setUp() throws Exception JavaDoc {
45         super.setUp();
46         WSDLVersionWrapper wsdlVersionWrapper = null;
47         if (null == this.womDescription) {
48             InputStream JavaDoc in = new FileInputStream JavaDoc(
49                     getTestResourceFile("InteropTestDocLit2.wsdl"));
50             wsdlVersionWrapper = WOMBuilderFactory.getBuilder(
51                     WOMBuilderFactory.WSDL11).build(in);
52             this.womDescription = wsdlVersionWrapper.getDescription();
53
54         }
55         if (null == wsdl4jDefinition) {
56             this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition();
57         }
58     }
59
60     public void testSOAPActionPopulation() {
61         WSDLBindingOperation bindingOperation = womDescription
62                 .getFirstBinding().getBindingOperation(
63                         new QName JavaDoc(
64                                 "http://soapinterop.org/WSDLInteropTestDocLit",
65                                 "echoVoid"));
66         Iterator JavaDoc iterator = bindingOperation.getExtensibilityElements()
67                 .iterator();
68         while (iterator.hasNext()) {
69             WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator
70                     .next();
71             SOAPOperation soapOperation = null;
72             if (ExtensionConstants.SOAP_OPERATION.equals(element.getType())) {
73                 soapOperation = (SOAPOperation) element;
74             }
75             if (soapOperation == null) {
76                 fail();
77             } else {
78                 assertEquals(soapOperation.getSoapAction(),
79                         "http://soapinterop.org/");
80             }
81         }
82     }
83
84 }
Popular Tags