1 16 package org.apache.wsdl; 17 18 import org.apache.wsdl.impl.WSDLInterfaceImpl; 19 import org.apache.wsdl.impl.WSDLOperationImpl; 20 21 import javax.xml.namespace.QName ; 22 import java.util.Iterator ; 23 24 public class InterfaceTest extends AbstractTestCase { 25 public InterfaceTest(String testName) { 26 super(testName); 27 } 28 29 public void testGetAllOperations() { 30 WSDLOperation op; 31 WSDLInterface intfc; 32 WSDLInterface[] array = new WSDLInterface[5]; 33 int interfaceCounter = 5; 34 int operationCounter = 5; 35 for (int j = 0; j < interfaceCounter; j++) { 36 intfc = new WSDLInterfaceImpl(); 37 intfc.setName(new QName (WSDLConstants.WSDL2_0_NAMESPACE, "inteface" 38 + j)); 39 for (int i = 0; i < operationCounter; i++) { 40 op = new WSDLOperationImpl(); 41 op.setName(new QName (WSDLConstants.WSDL1_1_NAMESPACE, "op" + i 42 + "of inteface" + j)); 43 assertNotNull(op.getName()); 44 intfc.setOperation(op); 45 } 46 if (j > 0) { 47 intfc.addSuperInterface(array[j - 1]); 48 } 49 array[j] = intfc; 50 } 51 assertEquals(((WSDLOperation) array[0].getOperation("op0of inteface0")) 52 .getName().getLocalPart(), "op0of inteface0"); 53 assertEquals(((WSDLOperation) array[0].getOperation("op1of inteface0")) 54 .getName().getLocalPart(), "op1of inteface0"); 55 assertEquals(array[interfaceCounter - 1].getAllOperations().size(), 56 interfaceCounter * operationCounter); 57 assertEquals(interfaceCounter * operationCounter, 58 array[interfaceCounter - 1].getAllOperations().size()); 59 Iterator iter = array[1].getAllOperations().keySet().iterator(); 60 while (iter.hasNext()) { 61 assertNotNull(((WSDLOperation) array[interfaceCounter - 1] 62 .getAllOperations().get(iter.next())).getName()); 63 } 64 for (int j = 0; j < interfaceCounter; j++) { 65 for (int i = 0; i < operationCounter; i++) { 66 WSDLOperation operation = (WSDLOperation) array[interfaceCounter - 1] 67 .getAllOperations().get("op" + j + "of inteface" + i); 68 assertEquals((operation).getName().getLocalPart(), "op" + j 69 + "of inteface" + i); 70 } 71 } 72 73 } 74 75 79 public void testInheritedOperationResolution() throws Exception { 80 WSDLOperation op; 81 WSDLInterface intfc; 82 WSDLInterface[] array = new WSDLInterface[5]; 83 int interfaceCounter = 5; 84 int operationCounter = 5; 85 for (int i = 0; i < interfaceCounter; i++) { 86 intfc = new WSDLInterfaceImpl(); 87 for (int j = 0; j < operationCounter; j++) { 88 op = new WSDLOperationImpl(); 89 op.setName(new QName (WSDLConstants.WSDL1_1_NAMESPACE, 90 "operation" + j)); 91 intfc.setOperation(op); 92 } 93 intfc.setName(new QName (WSDLConstants.WSDL2_0_NAMESPACE, 94 "Interface" + i)); 95 array[i] = intfc; 96 } 97 WSDLInterface inheritedInterface = new WSDLInterfaceImpl(); 98 for (int i = 0; i < array.length; i++) { 99 inheritedInterface.addSuperInterface(array[i]); 100 } 101 assertEquals(inheritedInterface.getAllOperations().size(), 5); 102 103 } 104 } 105 106 | Popular Tags |