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()); }
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)); }
@SuppressWarnings("unchecked") @Test public void testLiteralParserResultInTextBlock() throws Exception { List response = new ArrayList(); String xml = "<testResponse><out><data name="a">some data</data><data name="b">some more data</data></out></testResponse>"; DocumentBuilder builder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes())); response.add(new SOAPBodyElement(doc.getDocumentElement())); TypeDescriptor descriptor = new ComplexTypeDescriptor(); descriptor.setName("testResponse"); SOAPResponseLiteralParser parser = new SOAPResponseLiteralParser( Collections.singletonList(descriptor)); Map outputMap = parser.parse(response); assertNotNull("no output map returned", outputMap); assertEquals("map should contain 1 element", 1, outputMap.size()); Object testResponse = outputMap.get("testResponse"); assertNotNull("there should be an output named 'testReponse'", testResponse); assertEquals("output data should be a string", String.class, testResponse.getClass()); assertEquals( "xml is wrong", "<testResponse><out><data name="a">some data</data><data name="b">some more data</data></out></testResponse>", testResponse.toString()); }
@SuppressWarnings("unchecked") @Test public void testLiteralParser() throws Exception { List response = new ArrayList(); String xml = "<testResponse><out><data name=\"a\">some data</data><data name=\"b\">some more data</data></out></testResponse>"; DocumentBuilder builder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes())); response.add(new SOAPBodyElement(doc.getDocumentElement())); TypeDescriptor descriptor = new ComplexTypeDescriptor(); descriptor.setName("testResponse"); SOAPResponseLiteralParser parser = new SOAPResponseLiteralParser( Collections.singletonList(descriptor)); Map outputMap = parser.parse(response); assertNotNull("no output map returned", outputMap); assertEquals("map should contain 1 element", 1, outputMap.size()); Object testResponse = outputMap.get("testResponse"); assertNotNull("there should be an output named 'testReponse'", testResponse); assertEquals("output data should be a string", String.class, testResponse.getClass()); assertEquals( "xml is wrong", "<testResponse><out><data name=\"a\">some data</data><data name=\"b\">some more data</data></out></testResponse>", testResponse.toString()); }
TypeDescriptor descriptor = new ComplexTypeDescriptor(); descriptor.setName("result"); SOAPResponseEncodedMultiRefParser parser = new SOAPResponseEncodedMultiRefParser(
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]); }
@Test public void testCyclicToElement() throws Exception { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("typename"); a.setQnameFromString("{namespace}typename"); ComplexTypeDescriptor b = new ComplexTypeDescriptor(); b.setName("b"); b.setType("typename2"); b.setQnameFromString("{namespace}typename2"); a.getElements().add(b); b.getElements().add(a); Element el = XMLSplitterSerialisationHelper .typeDescriptorToExtensionXML(a); String xml = new XMLOutputter().outputString(el); assertEquals( "unexpected xml", "<s:extensions xmlns:s=\"http://org.embl.ebi.escience/xscufl/0.1alpha\"><s:complextype optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" qname=\"{namespace}typename\"><s:elements><s:complextype optional=\"false\" unbounded=\"false\" typename=\"typename2\" name=\"b\" qname=\"{namespace}typename2\"><s:elements><s:complextype id=\"{namespace}typename\" optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" /></s:elements></s:complextype></s:elements></s:complextype></s:extensions>", xml); }
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 testCyclicToElement2() throws Exception { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("typename"); a.setQnameFromString("{namespace}typename"); a.getElements().add(a); Element el = XMLSplitterSerialisationHelper .typeDescriptorToExtensionXML(a); String xml = new XMLOutputter().outputString(el); assertEquals( "unexpected xml", "<s:extensions xmlns:s=\"http://org.embl.ebi.escience/xscufl/0.1alpha\"><s:complextype optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" qname=\"{namespace}typename\"><s:elements><s:complextype id=\"{namespace}typename\" optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" /></s:elements></s:complextype></s:extensions>", xml); }
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]); }