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]); }
@SuppressWarnings("unchecked") @Test public void testUnwrappedLiteralResponseParsing() throws Exception { List response = new ArrayList(); String xml = "<getStringReturn xmlns=\"http://testing.org\">a string</getStringReturn>"; DocumentBuilder builder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes())); response.add(new SOAPBodyElement(doc.getDocumentElement())); TypeDescriptor descriptor = new BaseTypeDescriptor(); descriptor.setName("getStringReturn"); SOAPResponseLiteralParser parser = new SOAPResponsePrimitiveLiteralParser( Collections.singletonList(descriptor)); Map outputMap = parser.parse(response); assertNotNull("no output map returned", outputMap); assertEquals("map should contain 1 element", 1, outputMap.size()); Object stringReturn = outputMap.get("getStringReturn"); assertEquals("value of data returned is wrong","a string",stringReturn.toString()); }
@SuppressWarnings("unchecked") @Test public void testEmptyResponse() throws Exception { List response = new ArrayList(); TypeDescriptor descriptor = new BaseTypeDescriptor(); descriptor.setName("getStringReturn"); SOAPResponseLiteralParser parser = new SOAPResponseLiteralParser( Collections.singletonList(descriptor)); Map outputMap = parser.parse(response); assertNotNull("no output map returned", outputMap); assertEquals("map should contain 1 element", 0, outputMap.size()); }
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]); }
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]); }
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]); }