private static int depthForDescriptor(TypeDescriptor desc) { if (desc instanceof ArrayTypeDescriptor && (!((ArrayTypeDescriptor)desc).isWrapped() || ((ArrayTypeDescriptor)desc).getElementType() instanceof BaseTypeDescriptor)) { return 1; } else { return 0; } }
public TypeDescriptor getTypeDescriptorForOutputPort(String portName) { TypeDescriptor result = null; if (typeDescriptor instanceof ComplexTypeDescriptor) { for (TypeDescriptor desc : ((ComplexTypeDescriptor) typeDescriptor) .getElements()) { if (desc.getName().equals(portName)) { result = desc; break; } } } else if (typeDescriptor instanceof ArrayTypeDescriptor) { TypeDescriptor desc = ((ArrayTypeDescriptor)typeDescriptor).getElementType(); if (typeDescriptor.getName().equals(portName)) { result = desc; } } return result; }
public void testForCyclicTrueWithArray() { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("outertype"); ArrayTypeDescriptor b = new ArrayTypeDescriptor(); b.setName("b"); b.setType("arraytype"); ComplexTypeDescriptor c = new ComplexTypeDescriptor(); c.setName("c"); c.setType("innertype"); a.getElements().add(b); b.setElementType(c); c.getElements().add(a); assertTrue("should be identified as cyclic", TypeDescriptor.isCyclic(a)); }
@Test public void testGetUseLiteral() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("eutils/eutils_lite.wsdl")); String use = parser.getUse("run_eInfo"); assertEquals("use should be literal", "literal", use); }
@Test public void testBaseTypes() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("bind.wsdl")); List<TypeDescriptor> inputs = parser .getOperationInputParameters("BIVGetRecord"); assertEquals("wrong number of inputs", 1, inputs.size()); assertTrue("should not be base type", inputs.get(0) instanceof BaseTypeDescriptor); assertEquals("wrong name", "bid", (inputs.get(0)) .getName()); assertEquals("wrong type", "int", (inputs.get(0)) .getType()); }
public void testRetrieveSignitureForArrayDescriptor3() { ArrayTypeDescriptor desc = new ArrayTypeDescriptor(); desc.setName("AnArray"); desc.setType("string"); BaseTypeDescriptor base = new BaseTypeDescriptor(); base.setName(""); base.setType("string"); desc.setElementType(base); String[] names = new String[1]; Class<?>[] types = new Class[1]; List<TypeDescriptor> params = new ArrayList<TypeDescriptor>(); params.add(desc); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("AnArray", names[0]); assertEquals(String[].class, types[0]); }
@Test public void testMissingStyleInBinding() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("SBWReader.wsdl")); assertEquals("Style should default to document if missing", "document", parser.getStyle()); }
public void testRetrieveSignitureForArrayDescriptor2() { ArrayTypeDescriptor desc = new ArrayTypeDescriptor(); desc.setName("AnArray"); desc.setType("complextype"); ComplexTypeDescriptor complex = new ComplexTypeDescriptor(); complex.setName("complex"); complex.setType("complextype"); desc.setElementType(complex); String[] names = new String[1]; Class<?>[] types = new Class[1]; List<TypeDescriptor> params = new ArrayList<TypeDescriptor>(); params.add(desc); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("AnArray", names[0]); assertEquals(org.w3c.dom.Element.class, types[0]); }
@Test public void testGetOperationNamespace() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("CurrencyExchangeService.wsdl")); String operationNamespace = parser.getOperationNamespaceURI("getRate"); assertEquals("operation namespace is wrong", "urn:xmethods-CurrencyExchange", operationNamespace); }
public void testForCyclicFalse() { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("person"); ComplexTypeDescriptor b = new ComplexTypeDescriptor(); b.setName("b"); b.setType("name"); ComplexTypeDescriptor c = new ComplexTypeDescriptor(); c.setName("c"); c.setType("age"); a.getElements().add(b); a.getElements().add(c); assertFalse("should be not identified as cyclic", TypeDescriptor .isCyclic(a)); }
public void testForCyclicTrue() { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("outertype"); ComplexTypeDescriptor b = new ComplexTypeDescriptor(); b.setName("b"); b.setType("middletype"); ComplexTypeDescriptor c = new ComplexTypeDescriptor(); c.setName("c"); c.setType("innertype"); a.getElements().add(b); b.getElements().add(c); c.getElements().add(a); assertTrue("should be identified as cyclic", TypeDescriptor.isCyclic(a)); }
public void testBaseTypeKnownSigniture() { TypeDescriptor decimal=new BaseTypeDescriptor(); decimal.setName("adecimal"); decimal.setType("decimal"); List<TypeDescriptor> params=new ArrayList<TypeDescriptor>(); String [] names=new String[1]; Class<?> [] types=new Class[1]; params.add(decimal); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("should only be 1 type",1,types.length); assertEquals("should only be 1 name",1,names.length); assertEquals("name should be adecimal","adecimal",names[0]); assertEquals("type should be double",Double.TYPE,types[0]); }
@Test public void testGetActionURI() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("eutils/eutils_lite.wsdl")); String actionURI = parser.getSOAPActionURI("run_eInfo"); assertEquals("action uri is wrong", "einfo", actionURI); }
public void testComplex() { TypeDescriptor complex=new ComplexTypeDescriptor(); complex.setName("acomplex"); complex.setType("complextype"); List<TypeDescriptor> params=new ArrayList<TypeDescriptor>(); String [] names=new String[1]; Class<?> [] types=new Class[1]; params.add(complex); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("should only be 1 type",1,types.length); assertEquals("should only be 1 name",1,names.length); assertEquals("name should be adecimal","acomplex",names[0]); assertEquals("type should be string",org.w3c.dom.Element.class,types[0]); }
public void testQNameAsString() { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setQnameFromString("{URI}localPart"); assertEquals("URI", a.getQname().getNamespaceURI()); assertEquals("localPart", a.getQname().getLocalPart()); a = new ComplexTypeDescriptor(); a.setQnameFromString("{}localPart"); assertEquals("", a.getQname().getNamespaceURI()); assertEquals("localPart", a.getQname().getLocalPart()); }
@Override /** * Overridden to catch when a scavenger is removed from the tree (newParent = null). * This triggers the flushing of the WSDLParser cache. */ public void setParent(MutableTreeNode newParent) { super.setParent(newParent); if (newParent==null) { WSDLParser.flushCache(wsdlLocation); } }
@Test public void testGetUseEncoded() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("bind.wsdl")); String use = parser.getUse("BIVGetRecords"); assertEquals("use should be encoded", "encoded", use); }
public void testRetrieveSignitureForArrayDescriptor() { ArrayTypeDescriptor desc = new ArrayTypeDescriptor(); desc.setName("AnArray"); desc.setType("arrayofstring"); BaseTypeDescriptor base = new BaseTypeDescriptor(); base.setName(""); base.setType("string"); desc.setElementType(base); String[] names = new String[1]; Class<?>[] types = new Class[1]; List<TypeDescriptor> params = new ArrayList<TypeDescriptor>(); params.add(desc); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("AnArray", names[0]); assertEquals(String[].class, types[0]); }
@Test public void testGetOperationNamespace2() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("eutils/eutils_lite.wsdl")); String operationNamespace = parser .getOperationNamespaceURI("run_eInfo"); assertEquals("operation namespace is wrong", "http://www.ncbi.nlm.nih.gov/soap/eutils/einfo", operationNamespace); }
public void testBaseTypeUnrecognisedSigniture() { TypeDescriptor date=new BaseTypeDescriptor(); date.setName("adate"); date.setType("date"); List<TypeDescriptor> params=new ArrayList<TypeDescriptor>(); String [] names=new String[1]; Class<?> [] types=new Class[1]; params.add(date); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("should only be 1 type",1,types.length); assertEquals("should only be 1 name",1,names.length); assertEquals("name should be adecimal","adate",names[0]); assertEquals("type should be string",String.class,types[0]); }