KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > extensibility > model > WSDLMultipleExtensibilityElementsTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * WSDLMultipleExtensibilityElementsTest.java
22  *
23  * Created on January 23, 2007, 4:08 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.wsdl.ui.extensibility.model;
30
31 import java.net.URL JavaDoc;
32 import java.util.List JavaDoc;
33 import javax.xml.namespace.QName JavaDoc;
34 import org.netbeans.modules.xml.wsdl.ui.TestLookup;
35 import org.openide.filesystems.XMLFileSystem;
36 import org.openide.util.Lookup;
37
38 import junit.framework.*;
39 /**
40  *
41  * @author radval
42  */

43 public class WSDLMultipleExtensibilityElementsTest extends TestCase {
44     
45     static {
46         try {
47            System.setProperty("org.openide.util.Lookup", TestLookup.class.getName());
48            Lookup l = Lookup.getDefault();
49            if(l instanceof TestLookup) {
50                XMLFileSystem x = new XMLFileSystem();
51                URL JavaDoc url1 = WSDLMultipleExtensibilityElementsTest.class.getResource("/org/netbeans/modules/wsdlextensions/ftp/resources/layer.xml");
52                URL JavaDoc url2 = WSDLMultipleExtensibilityElementsTest.class.getResource("/org/netbeans/modules/wsdlextensions/jms/resources/layer.xml");
53                x.setXmlUrls(new URL JavaDoc[]{url1, url2});
54                
55                ((TestLookup) l).setup(x);
56            }
57         } catch(Exception JavaDoc ex) {
58             ex.printStackTrace();
59         }
60     }
61     
62     /** Creates a new instance of WSDLMultipleExtensibilityElementsTest */
63     public WSDLMultipleExtensibilityElementsTest() {
64     }
65     
66     protected void setUp() throws Exception JavaDoc {
67     }
68
69     protected void tearDown() throws Exception JavaDoc {
70     }
71     
72     public void testGetWSDLExtensibilityElements() throws Exception JavaDoc {
73         System.out.println("getWSDLExtensibilityElements");
74         
75         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
76         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
77         assertNotNull(result);
78         
79         assertNotNull(result.getAllExtensionSchemas());
80         assertTrue(result.getAllExtensionSchemas().length == 2);
81         
82     }
83     
84     public void testBinding() throws Exception JavaDoc {
85         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
86         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
87         
88         //binding
89
WSDLExtensibilityElement bindingElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING);
90         assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING, bindingElement.getName());
91         
92         List JavaDoc<WSDLExtensibilityElementInfoContainer> containers = bindingElement.getAllWSDLExtensibilityElementInfoContainers();
93         assertEquals(0, containers.size());
94         
95         List JavaDoc<WSDLExtensibilityElementInfo> exInfos = bindingElement.getAllWSDLExtensibilityElementInfos();
96         assertEquals(2, exInfos.size());
97         
98         WSDLExtensibilityElementInfo ftpBindingExInfo = exInfos.get(0);
99         assertNotNull(ftpBindingExInfo.getElement());
100         assertNotNull(ftpBindingExInfo.getPrefix());
101         assertNotNull(ftpBindingExInfo.getSchema());
102         assertEquals("binding", ftpBindingExInfo.getElementName());
103         assertEquals("FTPBinding", ftpBindingExInfo.getDataObject().getName());
104         
105         QName JavaDoc ftpBinding = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "binding");
106         WSDLExtensibilityElementInfo ftpBindingElmentExInfo = bindingElement.getWSDLExtensibilityElementInfos(ftpBinding);
107         assertNotNull(ftpBindingElmentExInfo);
108         
109         WSDLExtensibilityElementInfo jmsBindingExInfo = exInfos.get(1);
110         assertNotNull(jmsBindingExInfo.getElement());
111         assertNotNull(jmsBindingExInfo.getPrefix());
112         assertNotNull(jmsBindingExInfo.getSchema());
113         assertEquals("binding", jmsBindingExInfo.getElementName());
114         assertEquals("JMSBinding", jmsBindingExInfo.getDataObject().getName());
115         
116         QName JavaDoc jmsBinding = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "binding");
117         WSDLExtensibilityElementInfo jmsBindingElementExInfo = bindingElement.getWSDLExtensibilityElementInfos(jmsBinding);
118         assertNotNull(jmsBindingElementExInfo);
119         
120     }
121     
122     public void testBindingOperation() throws Exception JavaDoc {
123         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
124         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
125         
126         //binding operation
127
WSDLExtensibilityElement bindingOperationElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION);
128         assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION, bindingOperationElement.getName());
129         
130         List JavaDoc<WSDLExtensibilityElementInfoContainer> bindingOperationElementContainers = bindingOperationElement.getAllWSDLExtensibilityElementInfoContainers();
131         assertEquals(0, bindingOperationElementContainers.size());
132         
133         List JavaDoc<WSDLExtensibilityElementInfo> bindingOperationExInfos = bindingOperationElement.getAllWSDLExtensibilityElementInfos();
134         assertEquals(2, bindingOperationExInfos.size());
135         
136         WSDLExtensibilityElementInfo ftpBindingOperationExInfo = bindingOperationExInfos.get(0);
137         assertNotNull(ftpBindingOperationExInfo.getElement());
138         assertNotNull(ftpBindingOperationExInfo.getPrefix());
139         assertNotNull(ftpBindingOperationExInfo.getSchema());
140         assertEquals("operation", ftpBindingOperationExInfo.getElementName());
141         assertEquals("FTPBindingOperation", ftpBindingOperationExInfo.getDataObject().getName());
142         
143         QName JavaDoc ftpBindingOperation = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "operation");
144         WSDLExtensibilityElementInfo ftpBindingOperationElementExInfo = bindingOperationElement.getWSDLExtensibilityElementInfos(ftpBindingOperation);
145         assertNotNull(ftpBindingOperationElementExInfo);
146
147
148         WSDLExtensibilityElementInfo jmsBindingOperationExInfo = bindingOperationExInfos.get(1);
149         assertNotNull(jmsBindingOperationExInfo.getElement());
150         assertNotNull(jmsBindingOperationExInfo.getPrefix());
151         assertNotNull(jmsBindingOperationExInfo.getSchema());
152         assertEquals("operation", jmsBindingOperationExInfo.getElementName());
153         assertEquals("JMSBindingOperation", jmsBindingOperationExInfo.getDataObject().getName());
154         
155         QName JavaDoc jmsBindingOperation = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "operation");
156         WSDLExtensibilityElementInfo jmsBindingOperationElementExInfo = bindingOperationElement.getWSDLExtensibilityElementInfos(jmsBindingOperation);
157         assertNotNull(jmsBindingOperationElementExInfo);
158
159     }
160     
161     public void testBindingOpearationInput() throws Exception JavaDoc {
162         
163         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
164         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
165         
166         //binding operation input
167
WSDLExtensibilityElement bindingOperationInputElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT);
168         assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT, bindingOperationInputElement.getName());
169         
170         List JavaDoc<WSDLExtensibilityElementInfoContainer> bindingOperationInputElementContainers = bindingOperationInputElement.getAllWSDLExtensibilityElementInfoContainers();
171         assertEquals(0, bindingOperationInputElementContainers.size());
172         
173         List JavaDoc<WSDLExtensibilityElementInfo> bindingOperationInputExInfos = bindingOperationInputElement.getAllWSDLExtensibilityElementInfos();
174         assertEquals(4, bindingOperationInputExInfos.size());
175         
176         WSDLExtensibilityElementInfo ftpBindingOperationInputExInfo1 = bindingOperationInputExInfos.get(0);
177         assertNotNull(ftpBindingOperationInputExInfo1.getElement());
178         assertNotNull(ftpBindingOperationInputExInfo1.getPrefix());
179         assertNotNull(ftpBindingOperationInputExInfo1.getSchema());
180         assertEquals("message", ftpBindingOperationInputExInfo1.getElementName());
181         assertEquals("FTPBindingMessage", ftpBindingOperationInputExInfo1.getDataObject().getName());
182         
183         QName JavaDoc ftpBindingOperationInput1 = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "message");
184         WSDLExtensibilityElementInfo ftpBindingOperationInputElementExInfo1 = bindingOperationInputElement.getWSDLExtensibilityElementInfos(ftpBindingOperationInput1);
185         assertNotNull(ftpBindingOperationInputElementExInfo1);
186         
187         WSDLExtensibilityElementInfo ftpBindingOperationInputExInfo2 = bindingOperationInputExInfos.get(1);
188         assertNotNull(ftpBindingOperationInputExInfo2.getElement());
189         assertNotNull(ftpBindingOperationInputExInfo2.getPrefix());
190         assertNotNull(ftpBindingOperationInputExInfo2.getSchema());
191         assertEquals("messageActivePassive", ftpBindingOperationInputExInfo2.getElementName());
192         assertEquals("FTPBindingMessageActivePassive", ftpBindingOperationInputExInfo2.getDataObject().getName());
193         
194         QName JavaDoc ftpBindingOperationInput2 = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "messageActivePassive");
195         WSDLExtensibilityElementInfo ftpBindingOperationInputElementExInfo2 = bindingOperationInputElement.getWSDLExtensibilityElementInfos(ftpBindingOperationInput2);
196         assertNotNull(ftpBindingOperationInputElementExInfo2);
197         
198         WSDLExtensibilityElementInfo ftpBindingOperationInputExInfo3 = bindingOperationInputExInfos.get(2);
199         assertNotNull(ftpBindingOperationInputExInfo3.getElement());
200         assertNotNull(ftpBindingOperationInputExInfo3.getPrefix());
201         assertNotNull(ftpBindingOperationInputExInfo3.getSchema());
202         assertEquals("transfer", ftpBindingOperationInputExInfo3.getElementName());
203         assertEquals("FTPBindingTransfer", ftpBindingOperationInputExInfo3.getDataObject().getName());
204         
205         QName JavaDoc ftpBindingOperationInput3 = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "transfer");
206         WSDLExtensibilityElementInfo ftpBindingOperationInputElementExInfo3 = bindingOperationInputElement.getWSDLExtensibilityElementInfos(ftpBindingOperationInput3);
207         assertNotNull(ftpBindingOperationInputElementExInfo3);
208         
209         WSDLExtensibilityElementInfo jmsBindingOperationInputExInfo1 = bindingOperationInputExInfos.get(3);
210         assertNotNull(jmsBindingOperationInputExInfo1.getElement());
211         assertNotNull(jmsBindingOperationInputExInfo1.getPrefix());
212         assertNotNull(jmsBindingOperationInputExInfo1.getSchema());
213         assertEquals("message", jmsBindingOperationInputExInfo1.getElementName());
214         assertEquals("JMSBindingOperationInput", jmsBindingOperationInputExInfo1.getDataObject().getName());
215         
216         QName JavaDoc jmsBindingOperationInput1 = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "message");
217         WSDLExtensibilityElementInfo jmsBindingOperationInputElementExInfo1 = bindingOperationInputElement.getWSDLExtensibilityElementInfos(jmsBindingOperationInput1);
218         assertNotNull(jmsBindingOperationInputElementExInfo1);
219         
220     }
221     
222     public void testBindingOperationOutput() throws Exception JavaDoc {
223         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
224         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
225         
226         //binding operation output
227
WSDLExtensibilityElement bindingOperationOutputElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT);
228         assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT, bindingOperationOutputElement.getName());
229         
230         List JavaDoc<WSDLExtensibilityElementInfoContainer> bindingOperationOutputElementContainers = bindingOperationOutputElement.getAllWSDLExtensibilityElementInfoContainers();
231         assertEquals(0, bindingOperationOutputElementContainers.size());
232         
233         List JavaDoc<WSDLExtensibilityElementInfo> bindingOperationOutputExInfos = bindingOperationOutputElement.getAllWSDLExtensibilityElementInfos();
234         assertEquals(4, bindingOperationOutputExInfos.size());
235         
236         WSDLExtensibilityElementInfo ftpBindingOperationInputExInfo1 = bindingOperationOutputExInfos.get(0);
237         assertNotNull(ftpBindingOperationInputExInfo1.getElement());
238         assertNotNull(ftpBindingOperationInputExInfo1.getPrefix());
239         assertNotNull(ftpBindingOperationInputExInfo1.getSchema());
240         assertEquals("message", ftpBindingOperationInputExInfo1.getElementName());
241         assertEquals("FTPBindingMessage", ftpBindingOperationInputExInfo1.getDataObject().getName());
242         
243         QName JavaDoc ftpBindingOperationInput1 = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "message");
244         WSDLExtensibilityElementInfo ftpBindingOperationInputElementExInfo1 = bindingOperationOutputElement.getWSDLExtensibilityElementInfos(ftpBindingOperationInput1);
245         assertNotNull(ftpBindingOperationInputElementExInfo1);
246         
247         WSDLExtensibilityElementInfo ftpBindingOperationInputExInfo2 = bindingOperationOutputExInfos.get(1);
248         assertNotNull(ftpBindingOperationInputExInfo2.getElement());
249         assertNotNull(ftpBindingOperationInputExInfo2.getPrefix());
250         assertNotNull(ftpBindingOperationInputExInfo2.getSchema());
251         assertEquals("messageActivePassive", ftpBindingOperationInputExInfo2.getElementName());
252         assertEquals("FTPBindingMessageActivePassive", ftpBindingOperationInputExInfo2.getDataObject().getName());
253         
254         QName JavaDoc ftpBindingOperationInput2 = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "messageActivePassive");
255         WSDLExtensibilityElementInfo ftpBindingOperationInputElementExInfo2 = bindingOperationOutputElement.getWSDLExtensibilityElementInfos(ftpBindingOperationInput2);
256         assertNotNull(ftpBindingOperationInputElementExInfo2);
257         
258         WSDLExtensibilityElementInfo ftpBindingOperationInputExInfo3 = bindingOperationOutputExInfos.get(2);
259         assertNotNull(ftpBindingOperationInputExInfo3.getElement());
260         assertNotNull(ftpBindingOperationInputExInfo3.getPrefix());
261         assertNotNull(ftpBindingOperationInputExInfo3.getSchema());
262         assertEquals("transfer", ftpBindingOperationInputExInfo3.getElementName());
263         assertEquals("FTPBindingTransfer", ftpBindingOperationInputExInfo3.getDataObject().getName());
264         
265         QName JavaDoc ftpBindingOperationInput3 = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "transfer");
266         WSDLExtensibilityElementInfo ftpBindingOperationInputElementExInfo3 = bindingOperationOutputElement.getWSDLExtensibilityElementInfos(ftpBindingOperationInput3);
267         assertNotNull(ftpBindingOperationInputElementExInfo3);
268         
269         WSDLExtensibilityElementInfo jmsBindingOperationInputExInfo1 = bindingOperationOutputExInfos.get(3);
270         assertNotNull(jmsBindingOperationInputExInfo1.getElement());
271         assertNotNull(jmsBindingOperationInputExInfo1.getPrefix());
272         assertNotNull(jmsBindingOperationInputExInfo1.getSchema());
273         assertEquals("message", jmsBindingOperationInputExInfo1.getElementName());
274         assertEquals("JMSBindingOperationOutput", jmsBindingOperationInputExInfo1.getDataObject().getName());
275         
276         QName JavaDoc jmsBindingOperationInput1 = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "message");
277         WSDLExtensibilityElementInfo jmsBindingOperationInputElementExInfo1 = bindingOperationOutputElement.getWSDLExtensibilityElementInfos(jmsBindingOperationInput1);
278         assertNotNull(jmsBindingOperationInputElementExInfo1);
279         
280 // WSDLExtensibilityElementInfo bindingOperationOutputExInfo = bindingOperationOutputExInfos.get(0);
281
// assertNotNull(bindingOperationOutputExInfo.getElement());
282
// assertNotNull(bindingOperationOutputExInfo.getPrefix());
283
// assertNotNull(bindingOperationOutputExInfo.getSchema());
284
// assertEquals("message", bindingOperationOutputExInfo.getElementName());
285
// assertEquals("JMSBindingOperationOutput", bindingOperationOutputExInfo.getDataObject().getName());
286
//
287
// QName jmsBindingOperationInput = new QName("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "message");
288
// WSDLExtensibilityElementInfo jmsBindingOperationInputExInfo = bindingOperationOutputElement.getWSDLExtensibilityElementInfos(jmsBindingOperationInput);
289
// assertNotNull(jmsBindingOperationInputExInfo);
290

291     }
292     
293     public void testBindingOperationFault() throws Exception JavaDoc {
294         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
295         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
296         
297         //binding operation fault
298
WSDLExtensibilityElement bindingOperationFaultElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_FAULT);
299         assertNull(bindingOperationFaultElement);
300
301     }
302     
303     public void testServicePort() throws Exception JavaDoc {
304         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
305         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
306         
307         //binding operation output
308
WSDLExtensibilityElement servicePortElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_SERVICE_PORT);
309         assertEquals(WSDLExtensibilityElements.ELEMENT_SERVICE_PORT, servicePortElement.getName());
310         
311         List JavaDoc<WSDLExtensibilityElementInfoContainer> servicePortElementContainers = servicePortElement.getAllWSDLExtensibilityElementInfoContainers();
312         assertEquals(0, servicePortElementContainers.size());
313         
314         List JavaDoc<WSDLExtensibilityElementInfo> servicePortExInfos = servicePortElement.getAllWSDLExtensibilityElementInfos();
315         assertEquals(2, servicePortExInfos.size());
316         
317         WSDLExtensibilityElementInfo ftpServicePortExInfo = servicePortExInfos.get(0);
318         assertNotNull(ftpServicePortExInfo.getElement());
319         assertNotNull(ftpServicePortExInfo.getPrefix());
320         assertNotNull(ftpServicePortExInfo.getSchema());
321         assertEquals("address", ftpServicePortExInfo.getElementName());
322         assertEquals("FTPServicePort", ftpServicePortExInfo.getDataObject().getName());
323         
324         QName JavaDoc ftpServicePort = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/ftp/", "address");
325         WSDLExtensibilityElementInfo ftpServicePortElementExInfo = servicePortElement.getWSDLExtensibilityElementInfos(ftpServicePort);
326         assertNotNull(ftpServicePortElementExInfo);
327         
328         WSDLExtensibilityElementInfo servicePortExInfo = servicePortExInfos.get(1);
329         assertNotNull(servicePortExInfo.getElement());
330         assertNotNull(servicePortExInfo.getPrefix());
331         assertNotNull(servicePortExInfo.getSchema());
332         assertEquals("address", servicePortExInfo.getElementName());
333         assertEquals("JMSServicePort", servicePortExInfo.getDataObject().getName());
334         
335         QName JavaDoc jmsServicePort = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "address");
336         WSDLExtensibilityElementInfo jmsServicePortElementExInfo = servicePortElement.getWSDLExtensibilityElementInfos(jmsServicePort);
337         assertNotNull(jmsServicePortElementExInfo);
338
339     }
340 }
341
Popular Tags