1 16 package org.apache.wsdl; 17 18 19 import org.apache.axis2.wsdl.WSDLVersionWrapper; 20 import org.apache.axis2.wsdl.builder.WOMBuilderFactory; 21 22 import javax.wsdl.Definition; 23 import javax.wsdl.Operation; 24 import javax.wsdl.PortType; 25 import javax.wsdl.Service; 26 import java.io.FileInputStream ; 27 import java.io.InputStream ; 28 import java.util.Iterator ; 29 30 33 public class WOMBuilderTest extends AbstractTestCase { 34 35 private WSDLDescription womDescription = null; 36 37 private Definition wsdl4jDefinition = null; 38 39 public WOMBuilderTest(String testName) { 40 super(testName); 41 } 42 43 private void initialize() throws Exception { 44 45 WSDLVersionWrapper wsdlVersionWrapper = null; 46 if (null == this.womDescription) { 47 InputStream in = new FileInputStream (getTestResourceFile("InteropTest.wsdl")); 48 wsdlVersionWrapper = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in); 49 this.womDescription = wsdlVersionWrapper.getDescription(); 50 } 51 if (null == wsdl4jDefinition) { 52 this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition(); 53 } 54 } 55 56 public void testTopLevelComponentCount() throws Exception { 57 this.initialize(); 58 assertEquals(womDescription.getServices().size(), wsdl4jDefinition.getServices().size()); 59 assertEquals(womDescription.getWsdlInterfaces().size(), wsdl4jDefinition.getPortTypes().size()); 60 ; 61 assertEquals(womDescription.getServices().size(), wsdl4jDefinition.getServices().size()); 62 assertEquals(womDescription.getBindings().size(), wsdl4jDefinition.getBindings().size()); 63 64 } 65 66 public void testInterfacesComponent() throws Exception { 67 this.initialize(); 68 Iterator interfaceIterator = this.womDescription.getWsdlInterfaces().values().iterator(); 69 Iterator porttypeIterator = this.wsdl4jDefinition.getPortTypes().values().iterator(); 70 while (interfaceIterator.hasNext() & porttypeIterator.hasNext()) { 71 WSDLInterface wsdlInterface = (WSDLInterface) interfaceIterator.next(); 72 PortType porttype = (PortType) porttypeIterator.next(); 73 assertEquals(wsdlInterface.getName(), porttype.getQName()); 74 assertEquals(wsdlInterface.getTargetnamespace(), porttype.getQName().getNamespaceURI()); 75 assertEquals(wsdlInterface.getAllOperations().size(), porttype.getOperations().size()); 76 Iterator womOperationIterator = wsdlInterface.getAllOperations().values().iterator(); 77 Iterator wsdl4jOprationIterator = porttype.getOperations().iterator(); 78 while (wsdl4jOprationIterator.hasNext()) { 80 Operation wsdl4jOperation = (Operation) wsdl4jOprationIterator.next(); 81 this.operationsWaliking(wsdlInterface.getOperation(wsdl4jOperation.getName()), wsdl4jOperation); 82 } 83 while(womOperationIterator.hasNext() ){ 84 WSDLOperation womOperation = (WSDLOperation)womOperationIterator.next(); 85 this.operationsWaliking(womOperation, porttype.getOperation(womOperation.getName().getLocalPart(), null,null)); 86 } 87 88 } 89 } 90 91 public void testServiceComponent() throws Exception { 92 this.initialize(); 93 Iterator womServiceIterator = this.womDescription.getServices().values().iterator(); 94 Iterator wsdl4jServiceIterator = this.wsdl4jDefinition.getServices().values().iterator(); 95 96 while (womServiceIterator.hasNext() & wsdl4jServiceIterator.hasNext()) { 97 WSDLService wsdlService = (WSDLService) womServiceIterator.next(); 98 Service wsdl4jService = (Service) wsdl4jServiceIterator.next(); 99 assertEquals(wsdlService.getName(), wsdl4jService.getQName()); 100 101 } 102 } 103 104 105 private void operationsWaliking(WSDLOperation womOperation, Operation wsdl4jOperation) { 106 assertEquals(womOperation.getName().getLocalPart(), wsdl4jOperation.getName()); 107 109 110 } 111 112 113 } 114 | Popular Tags |