1 19 20 28 29 package org.netbeans.modules.xml.wsdl.ui.extensibility.model; 30 31 import java.net.URL ; 32 import java.util.List ; 33 import javax.xml.namespace.QName ; 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 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 url1 = WSDLMultipleExtensibilityElementsTest.class.getResource("/org/netbeans/modules/wsdlextensions/ftp/resources/layer.xml"); 52 URL url2 = WSDLMultipleExtensibilityElementsTest.class.getResource("/org/netbeans/modules/wsdlextensions/jms/resources/layer.xml"); 53 x.setXmlUrls(new URL []{url1, url2}); 54 55 ((TestLookup) l).setup(x); 56 } 57 } catch(Exception ex) { 58 ex.printStackTrace(); 59 } 60 } 61 62 63 public WSDLMultipleExtensibilityElementsTest() { 64 } 65 66 protected void setUp() throws Exception { 67 } 68 69 protected void tearDown() throws Exception { 70 } 71 72 public void testGetWSDLExtensibilityElements() throws Exception { 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 { 85 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 86 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 87 88 WSDLExtensibilityElement bindingElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING); 90 assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING, bindingElement.getName()); 91 92 List <WSDLExtensibilityElementInfoContainer> containers = bindingElement.getAllWSDLExtensibilityElementInfoContainers(); 93 assertEquals(0, containers.size()); 94 95 List <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 ftpBinding = new QName ("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 jmsBinding = new QName ("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 { 123 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 124 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 125 126 WSDLExtensibilityElement bindingOperationElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION); 128 assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION, bindingOperationElement.getName()); 129 130 List <WSDLExtensibilityElementInfoContainer> bindingOperationElementContainers = bindingOperationElement.getAllWSDLExtensibilityElementInfoContainers(); 131 assertEquals(0, bindingOperationElementContainers.size()); 132 133 List <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 ftpBindingOperation = new QName ("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 jmsBindingOperation = new QName ("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 { 162 163 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 164 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 165 166 WSDLExtensibilityElement bindingOperationInputElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT); 168 assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT, bindingOperationInputElement.getName()); 169 170 List <WSDLExtensibilityElementInfoContainer> bindingOperationInputElementContainers = bindingOperationInputElement.getAllWSDLExtensibilityElementInfoContainers(); 171 assertEquals(0, bindingOperationInputElementContainers.size()); 172 173 List <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 ftpBindingOperationInput1 = new QName ("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 ftpBindingOperationInput2 = new QName ("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 ftpBindingOperationInput3 = new QName ("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 jmsBindingOperationInput1 = new QName ("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 { 223 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 224 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 225 226 WSDLExtensibilityElement bindingOperationOutputElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT); 228 assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT, bindingOperationOutputElement.getName()); 229 230 List <WSDLExtensibilityElementInfoContainer> bindingOperationOutputElementContainers = bindingOperationOutputElement.getAllWSDLExtensibilityElementInfoContainers(); 231 assertEquals(0, bindingOperationOutputElementContainers.size()); 232 233 List <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 ftpBindingOperationInput1 = new QName ("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 ftpBindingOperationInput2 = new QName ("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 ftpBindingOperationInput3 = new QName ("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 jmsBindingOperationInput1 = new QName ("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "message"); 277 WSDLExtensibilityElementInfo jmsBindingOperationInputElementExInfo1 = bindingOperationOutputElement.getWSDLExtensibilityElementInfos(jmsBindingOperationInput1); 278 assertNotNull(jmsBindingOperationInputElementExInfo1); 279 280 291 } 292 293 public void testBindingOperationFault() throws Exception { 294 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 295 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 296 297 WSDLExtensibilityElement bindingOperationFaultElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_FAULT); 299 assertNull(bindingOperationFaultElement); 300 301 } 302 303 public void testServicePort() throws Exception { 304 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 305 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 306 307 WSDLExtensibilityElement servicePortElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_SERVICE_PORT); 309 assertEquals(WSDLExtensibilityElements.ELEMENT_SERVICE_PORT, servicePortElement.getName()); 310 311 List <WSDLExtensibilityElementInfoContainer> servicePortElementContainers = servicePortElement.getAllWSDLExtensibilityElementInfoContainers(); 312 assertEquals(0, servicePortElementContainers.size()); 313 314 List <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 ftpServicePort = new QName ("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 jmsServicePort = new QName ("http://schemas.sun.com/jbi/wsdl-extensions/jms/", "address"); 336 WSDLExtensibilityElementInfo jmsServicePortElementExInfo = servicePortElement.getWSDLExtensibilityElementInfos(jmsServicePort); 337 assertNotNull(jmsServicePortElementExInfo); 338 339 } 340 } 341 | Popular Tags |