KickJava   Java API By Example, From Geeks To Geeks.

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


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.Schema;
23 import org.w3c.dom.Element JavaDoc;
24 import org.w3c.dom.Node JavaDoc;
25 import org.w3c.dom.NodeList JavaDoc;
26
27 import javax.wsdl.Definition;
28 import java.io.FileInputStream JavaDoc;
29 import java.io.InputStream JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 /**
33  * @author chathura@opensource.lk
34  *
35  */

36 public class CreateSchemaTest extends AbstractTestCase {
37
38     private WSDLDescription womDescription;
39
40     private Definition wsdl4jDefinition;
41
42     public CreateSchemaTest(String JavaDoc arg) {
43         super(arg);
44     }
45
46     protected void setUp() throws Exception JavaDoc {
47         WSDLVersionWrapper wsdlVersionWrapper = null;
48         if (null == this.womDescription) {
49             InputStream JavaDoc in = new FileInputStream JavaDoc(getTestResourceFile("BookQuote.wsdl"));
50             wsdlVersionWrapper = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in);
51             this.womDescription = wsdlVersionWrapper.getDescription();
52         }
53         if (null == wsdl4jDefinition) {
54             this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition();
55         }
56     }
57
58     public void testInsertedMultipartType() {
59         WSDLTypes types = womDescription.getTypes();
60         assertNotNull(types);
61         Iterator JavaDoc iterator = types.getExtensibilityElements().iterator();
62         WSDLExtensibilityElement element = null;
63         while (iterator.hasNext()) {
64             element = (WSDLExtensibilityElement) iterator.next();
65             if (ExtensionConstants.SCHEMA.equals(element.getType()))
66                 break;
67         }
68         assertNotNull(element);
69         Schema schema = (Schema) element;
70         NodeList JavaDoc childNodes = schema.getElelment().getChildNodes();
71         Element JavaDoc insertedElementForMessageReference = null;
72         for (int i = 0; i < childNodes.getLength(); i++) {
73             Node JavaDoc item = childNodes.item(i);
74             if (item instanceof Element JavaDoc
75                     && "complexType".equals(((Element JavaDoc) item).getTagName())
76                     && "BookQuote_getBookPrice".equals(((Element JavaDoc) item)
77                             .getAttribute("name"))) {
78                 insertedElementForMessageReference = (Element JavaDoc) item;
79             }
80         }
81
82         assertNotNull(insertedElementForMessageReference);
83
84     }
85
86 }
Popular Tags