KickJava   Java API By Example, From Geeks To Geeks.

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


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  * WSDLJmsExtensibilityElementsTest.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.util.List JavaDoc;
32 import javax.xml.namespace.QName JavaDoc;
33 import junit.framework.*;
34 import org.netbeans.modules.xml.wsdl.ui.TestLookup;
35 import org.openide.filesystems.XMLFileSystem;
36 import org.openide.util.Lookup;
37
38 /**
39  *
40  * @author radval
41  */

42 public class WSDLJmsExtensibilityElementsTest extends TestCase {
43     
44     static {
45         try {
46            System.setProperty("org.openide.util.Lookup", TestLookup.class.getName());
47            Lookup l = Lookup.getDefault();
48            if(l instanceof TestLookup) {
49                XMLFileSystem x = new XMLFileSystem(WSDLExtensibilityElementsFactoryTest.class.getResource("/org/netbeans/modules/wsdlextensions/jms/resources/layer.xml"));
50               
51                ((TestLookup) l).setup(x);
52            }
53         } catch(Exception JavaDoc ex) {
54             ex.printStackTrace();
55         }
56     }
57     
58     /** Creates a new instance of WSDLJmsExtensibilityElementsTest */
59     public WSDLJmsExtensibilityElementsTest() {
60     }
61     
62     protected void setUp() throws Exception JavaDoc {
63     }
64
65     protected void tearDown() throws Exception JavaDoc {
66     }
67     
68     
69     public void testGetWSDLExtensibilityElements() throws Exception JavaDoc {
70         System.out.println("getWSDLExtensibilityElements");
71         
72         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
73         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
74         assertNotNull(result);
75         
76         assertNotNull(result.getAllExtensionSchemas());
77         assertTrue(result.getAllExtensionSchemas().length == 1);
78         
79     }
80     
81     public void testBinding() throws Exception JavaDoc {
82         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
83         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
84         
85         //binding
86
WSDLExtensibilityElement bindingElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING);
87         assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING, bindingElement.getName());
88         
89         List JavaDoc<WSDLExtensibilityElementInfoContainer> containers = bindingElement.getAllWSDLExtensibilityElementInfoContainers();
90         assertEquals(0, containers.size());
91         
92         List JavaDoc<WSDLExtensibilityElementInfo> exInfos = bindingElement.getAllWSDLExtensibilityElementInfos();
93         assertEquals(1, exInfos.size());
94         
95         WSDLExtensibilityElementInfo exInfo = exInfos.get(0);
96         assertNotNull(exInfo.getElement());
97         assertNotNull(exInfo.getPrefix());
98         assertNotNull(exInfo.getSchema());
99         assertEquals("binding", exInfo.getElementName());
100         assertEquals("JMSBinding", exInfo.getDataObject().getName());
101         
102         QName JavaDoc jmsBinding = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "binding");
103         WSDLExtensibilityElementInfo jmsBindingExInfo = bindingElement.getWSDLExtensibilityElementInfos(jmsBinding);
104         assertNotNull(jmsBindingExInfo);
105         
106     }
107     
108     public void testBindingOperation() throws Exception JavaDoc {
109         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
110         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
111         
112         //binding operation
113
WSDLExtensibilityElement bindingOperationElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION);
114         assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION, bindingOperationElement.getName());
115         
116         List JavaDoc<WSDLExtensibilityElementInfoContainer> bindingOperationElementContainers = bindingOperationElement.getAllWSDLExtensibilityElementInfoContainers();
117         assertEquals(0, bindingOperationElementContainers.size());
118         
119         List JavaDoc<WSDLExtensibilityElementInfo> bindingOperationExInfos = bindingOperationElement.getAllWSDLExtensibilityElementInfos();
120         assertEquals(1, bindingOperationExInfos.size());
121         
122         WSDLExtensibilityElementInfo bindingOperationExInfo = bindingOperationExInfos.get(0);
123         assertNotNull(bindingOperationExInfo.getElement());
124         assertNotNull(bindingOperationExInfo.getPrefix());
125         assertNotNull(bindingOperationExInfo.getSchema());
126         assertEquals("operation", bindingOperationExInfo.getElementName());
127         assertEquals("JMSBindingOperation", bindingOperationExInfo.getDataObject().getName());
128         
129         QName JavaDoc jmsBindingOperation = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "operation");
130         WSDLExtensibilityElementInfo jmsBindingOperationExInfo = bindingOperationElement.getWSDLExtensibilityElementInfos(jmsBindingOperation);
131         assertNotNull(jmsBindingOperationExInfo);
132
133     }
134     
135     public void testBindingOpearationInput() throws Exception JavaDoc {
136         
137         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
138         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
139         
140         //binding operation input
141
WSDLExtensibilityElement bindingOperationInputElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT);
142         assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT, bindingOperationInputElement.getName());
143         
144         List JavaDoc<WSDLExtensibilityElementInfoContainer> bindingOperationInputElementContainers = bindingOperationInputElement.getAllWSDLExtensibilityElementInfoContainers();
145         assertEquals(0, bindingOperationInputElementContainers.size());
146         
147         List JavaDoc<WSDLExtensibilityElementInfo> bindingOperationInputExInfos = bindingOperationInputElement.getAllWSDLExtensibilityElementInfos();
148         assertEquals(1, bindingOperationInputExInfos.size());
149         
150         WSDLExtensibilityElementInfo bindingOperationInputExInfo = bindingOperationInputExInfos.get(0);
151         assertNotNull(bindingOperationInputExInfo.getElement());
152         assertNotNull(bindingOperationInputExInfo.getPrefix());
153         assertNotNull(bindingOperationInputExInfo.getSchema());
154         assertEquals("message", bindingOperationInputExInfo.getElementName());
155         assertEquals("JMSBindingOperationInput", bindingOperationInputExInfo.getDataObject().getName());
156         
157         QName JavaDoc jmsBindingOperationInput = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "message");
158         WSDLExtensibilityElementInfo jmsBindingOperationInputExInfo = bindingOperationInputElement.getWSDLExtensibilityElementInfos(jmsBindingOperationInput);
159         assertNotNull(jmsBindingOperationInputExInfo);
160
161     }
162     
163     public void testBindingOperationOutput() throws Exception JavaDoc {
164         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
165         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
166         
167         //binding operation output
168
WSDLExtensibilityElement bindingOperationOutputElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT);
169         assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT, bindingOperationOutputElement.getName());
170         
171         List JavaDoc<WSDLExtensibilityElementInfoContainer> bindingOperationOutputElementContainers = bindingOperationOutputElement.getAllWSDLExtensibilityElementInfoContainers();
172         assertEquals(0, bindingOperationOutputElementContainers.size());
173         
174         List JavaDoc<WSDLExtensibilityElementInfo> bindingOperationOutputExInfos = bindingOperationOutputElement.getAllWSDLExtensibilityElementInfos();
175         assertEquals(1, bindingOperationOutputExInfos.size());
176         
177         WSDLExtensibilityElementInfo bindingOperationOutputExInfo = bindingOperationOutputExInfos.get(0);
178         assertNotNull(bindingOperationOutputExInfo.getElement());
179         assertNotNull(bindingOperationOutputExInfo.getPrefix());
180         assertNotNull(bindingOperationOutputExInfo.getSchema());
181         assertEquals("message", bindingOperationOutputExInfo.getElementName());
182         assertEquals("JMSBindingOperationOutput", bindingOperationOutputExInfo.getDataObject().getName());
183         
184         QName JavaDoc jmsBindingOperationInput = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "message");
185         WSDLExtensibilityElementInfo jmsBindingOperationInputExInfo = bindingOperationOutputElement.getWSDLExtensibilityElementInfos(jmsBindingOperationInput);
186         assertNotNull(jmsBindingOperationInputExInfo);
187
188     }
189     
190     public void testBindingOperationFault() throws Exception JavaDoc {
191         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
192         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
193         
194         //binding operation fault
195
WSDLExtensibilityElement bindingOperationFaultElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_FAULT);
196         assertNull(bindingOperationFaultElement);
197
198     }
199     
200     public void testServicePort() throws Exception JavaDoc {
201         WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance();
202         WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements();
203         
204         //binding operation output
205
WSDLExtensibilityElement servicePortElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_SERVICE_PORT);
206         assertEquals(WSDLExtensibilityElements.ELEMENT_SERVICE_PORT, servicePortElement.getName());
207         
208         List JavaDoc<WSDLExtensibilityElementInfoContainer> servicePortElementContainers = servicePortElement.getAllWSDLExtensibilityElementInfoContainers();
209         assertEquals(0, servicePortElementContainers.size());
210         
211         List JavaDoc<WSDLExtensibilityElementInfo> servicePortExInfos = servicePortElement.getAllWSDLExtensibilityElementInfos();
212         assertEquals(1, servicePortExInfos.size());
213         
214         WSDLExtensibilityElementInfo servicePortExInfo = servicePortExInfos.get(0);
215         assertNotNull(servicePortExInfo.getElement());
216         assertNotNull(servicePortExInfo.getPrefix());
217         assertNotNull(servicePortExInfo.getSchema());
218         assertEquals("address", servicePortExInfo.getElementName());
219         assertEquals("JMSServicePort", servicePortExInfo.getDataObject().getName());
220         
221         QName JavaDoc jmsBindingOperationInput = new QName JavaDoc("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "address");
222         WSDLExtensibilityElementInfo jmsBindingOperationInputExInfo = servicePortElement.getWSDLExtensibilityElementInfos(jmsBindingOperationInput);
223         assertNotNull(jmsBindingOperationInputExInfo);
224
225     }
226     
227 }
228
Popular Tags