1 19 20 28 29 package org.netbeans.modules.xml.wsdl.ui.extensibility.model; 30 31 import java.util.List ; 32 import javax.xml.namespace.QName ; 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 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 ex) { 54 ex.printStackTrace(); 55 } 56 } 57 58 59 public WSDLJmsExtensibilityElementsTest() { 60 } 61 62 protected void setUp() throws Exception { 63 } 64 65 protected void tearDown() throws Exception { 66 } 67 68 69 public void testGetWSDLExtensibilityElements() throws Exception { 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 { 82 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 83 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 84 85 WSDLExtensibilityElement bindingElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING); 87 assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING, bindingElement.getName()); 88 89 List <WSDLExtensibilityElementInfoContainer> containers = bindingElement.getAllWSDLExtensibilityElementInfoContainers(); 90 assertEquals(0, containers.size()); 91 92 List <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 jmsBinding = new QName ("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 { 109 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 110 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 111 112 WSDLExtensibilityElement bindingOperationElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION); 114 assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION, bindingOperationElement.getName()); 115 116 List <WSDLExtensibilityElementInfoContainer> bindingOperationElementContainers = bindingOperationElement.getAllWSDLExtensibilityElementInfoContainers(); 117 assertEquals(0, bindingOperationElementContainers.size()); 118 119 List <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 jmsBindingOperation = new QName ("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 { 136 137 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 138 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 139 140 WSDLExtensibilityElement bindingOperationInputElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT); 142 assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT, bindingOperationInputElement.getName()); 143 144 List <WSDLExtensibilityElementInfoContainer> bindingOperationInputElementContainers = bindingOperationInputElement.getAllWSDLExtensibilityElementInfoContainers(); 145 assertEquals(0, bindingOperationInputElementContainers.size()); 146 147 List <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 jmsBindingOperationInput = new QName ("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 { 164 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 165 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 166 167 WSDLExtensibilityElement bindingOperationOutputElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT); 169 assertEquals(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT, bindingOperationOutputElement.getName()); 170 171 List <WSDLExtensibilityElementInfoContainer> bindingOperationOutputElementContainers = bindingOperationOutputElement.getAllWSDLExtensibilityElementInfoContainers(); 172 assertEquals(0, bindingOperationOutputElementContainers.size()); 173 174 List <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 jmsBindingOperationInput = new QName ("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 { 191 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 192 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 193 194 WSDLExtensibilityElement bindingOperationFaultElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_FAULT); 196 assertNull(bindingOperationFaultElement); 197 198 } 199 200 public void testServicePort() throws Exception { 201 WSDLExtensibilityElementsFactory instance = WSDLExtensibilityElementsFactory.getInstance(); 202 WSDLExtensibilityElements result = instance.getWSDLExtensibilityElements(); 203 204 WSDLExtensibilityElement servicePortElement = result.getWSDLExtensibilityElement(WSDLExtensibilityElements.ELEMENT_SERVICE_PORT); 206 assertEquals(WSDLExtensibilityElements.ELEMENT_SERVICE_PORT, servicePortElement.getName()); 207 208 List <WSDLExtensibilityElementInfoContainer> servicePortElementContainers = servicePortElement.getAllWSDLExtensibilityElementInfoContainers(); 209 assertEquals(0, servicePortElementContainers.size()); 210 211 List <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 jmsBindingOperationInput = new QName ("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 |