Debian Codegraph @

test/encoding/TestDeser.java

raw
1 package test.encoding;
2
3 import junit.framework.TestCase;
4 import org.apache.axis.Constants;
5 import org.apache.axis.Message;
6 import org.apache.axis.MessageContext;
7 import org.apache.axis.encoding.TypeMapping;
8 import org.apache.axis.encoding.TypeMappingRegistry;
9 import org.apache.axis.message.RPCElement;
10 import org.apache.axis.message.RPCParam;
11 import org.apache.axis.message.SOAPEnvelope;
12 import org.apache.axis.server.AxisServer;
13 import org.apache.axis.utils.JavaUtils;
14 import samples.echo.SOAPStruct;
15 import samples.echo.SOAPStructStruct;
16
17 import javax.xml.namespace.QName;
18 import java.lang.reflect.Array;
19 import java.util.ArrayList;
20 import java.util.HashMap;
21 import java.util.Hashtable;
22 import java.util.Iterator;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Set;
26 import java.util.Vector;
27 /**
28 * Test deserialization of SOAP responses
29 */
30 public class TestDeser extends TestCase {
31
32 private String header;
33 private String footer;
34 private AxisServer server = new AxisServer();
35
36 public TestDeser(String name) {
37 this(name, Constants.URI_DEFAULT_SCHEMA_XSI,
38 Constants.URI_DEFAULT_SCHEMA_XSD);
39 }
40
41 public TestDeser(String name, String NS_XSI, String NS_XSD) {
42 super(name);
43
44 header =
45 "<?xml version=\"1.0\"?>\n" +
46 "<soap:Envelope " +
47 "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
48 "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
49 "xmlns:me=\"http://soapinterop.org/xsd\" " +
50 "xmlns:this=\"http://encoding.test\" " +
51 "xmlns:xsi=\"" + NS_XSI + "\" " +
52 "xmlns:xsd=\"" + NS_XSD + "\">\n" +
53 "<soap:Body>\n" +
54 "<methodResult xmlns=\"http://tempuri.org/\">\n";
55
56 footer =
57 "</methodResult>\n" +
58 "</soap:Body>\n" +
59 "</soap:Envelope>\n";
60
61 TypeMappingRegistry tmr = server.getTypeMappingRegistry();
62 TypeMapping tm = (TypeMapping) tmr.createTypeMapping();
63 tm.setSupportedEncodings(new String[] {Constants.URI_DEFAULT_SOAP_ENC});
64 tmr.register(Constants.URI_DEFAULT_SOAP_ENC, tm);
65 tm.register(java.lang.String[].class,
66 new QName("http://soapinterop.org/xsd", "ArrayOfString"),
67 new org.apache.axis.encoding.ser.ArraySerializerFactory(),
68 new org.apache.axis.encoding.ser.ArrayDeserializerFactory());
69 tm.register(java.lang.Object[].class,
70 new QName("http://soapinterop.org/xsd", "ArrayOfObject"),
71 new org.apache.axis.encoding.ser.ArraySerializerFactory(),
72 new org.apache.axis.encoding.ser.ArrayDeserializerFactory());
73 tm.register(samples.echo.SOAPStruct.class,
74 new QName("http://soapinterop.org/xsd", "SOAPStruct"),
75 new org.apache.axis.encoding.ser.BeanSerializerFactory(
76 samples.echo.SOAPStruct.class,
77 new QName("http://soapinterop.org/xsd", "SOAPStruct")),
78 new org.apache.axis.encoding.ser.BeanDeserializerFactory(
79 samples.echo.SOAPStruct.class,
80 new QName("http://soapinterop.org/xsd", "SOAPStruct")));
81 tm.register(samples.echo.SOAPStruct[].class,
82 new QName("http://soapinterop.org/xsd", "ArrayOfSOAPStruct"),
83 new org.apache.axis.encoding.ser.ArraySerializerFactory(),
84 new org.apache.axis.encoding.ser.ArrayDeserializerFactory());
85 tm.register(samples.echo.SOAPStructStruct.class,
86 new QName("http://soapinterop.org/xsd", "SOAPStructStruct"),
87 new org.apache.axis.encoding.ser.BeanSerializerFactory(
88 samples.echo.SOAPStructStruct.class,
89 new QName("http://soapinterop.org/xsd", "SOAPStructStruct")),
90 new org.apache.axis.encoding.ser.BeanDeserializerFactory(
91 samples.echo.SOAPStructStruct.class,
92 new QName("http://soapinterop.org/xsd", "SOAPStructStruct")));
93 tm.register(test.encoding.IndexPropBean.class,
94 new QName("http://encoding.test", "IndexPropBean"),
95 new org.apache.axis.encoding.ser.BeanSerializerFactory(
96 test.encoding.IndexPropBean.class,
97 new QName("http://encoding.test", "IndexPropBean")),
98 new org.apache.axis.encoding.ser.BeanDeserializerFactory(
99 test.encoding.IndexPropBean.class,
100 new QName("http://encoding.test", "IndexPropBean")));
101 }
102
103 /**
104 * Verify that two objects have the same value, handling arrays...
105 */
106 private static boolean equals(Object obj1, Object obj2) {
107 if ( (obj1 == null) || (obj2 == null) ) return (obj1 == obj2);
108 if (obj1.equals(obj2)) return true;
109 if (obj2.getClass().isArray() && obj1.getClass().isArray()) {
110 if (Array.getLength(obj1) != Array.getLength(obj2)) return false;
111 for (int i=0; i<Array.getLength(obj1); i++)
112 if (!equals(Array.get(obj1,i),Array.get(obj2,i))) return false;
113 return true;
114 }
115 if ((obj1 instanceof List) && (obj2 instanceof List)) {
116 List list1 = (List)obj1;
117 List list2 = (List)obj2;
118 if (list1.size() != list2.size()) return false;
119 for (int i=0; i < list1.size(); i++) {
120 if (!equals(list1.get(i), list2.get(i))) return false;
121 }
122 return true;
123 }
124 if ((obj1 instanceof Map) && (obj2 instanceof Map)) {
125 Map map1 = (Map)obj1;
126 Map map2 = (Map)obj2;
127 Set keys1 = map1.keySet();
128 Set keys2 = map2.keySet();
129 if (!(keys1.equals(keys2))) return false;
130 Iterator i = keys1.iterator();
131 while (i.hasNext()) {
132 Object key = i.next();
133 if (!map1.get(key).equals(map2.get(key)))
134 return false;
135 }
136 return true;
137 }
138
139 return false;
140 }
141
142 /**
143 * Verify that a given XML deserialized produces the expected result
144 */
145 protected void deserialize(String data, Object expected)
146 throws Exception {
147 deserialize(data, expected, false);
148 }
149
150 protected void deserialize(String data, Object expected, boolean tryConvert)
151 throws Exception {
152 deserialize(data, expected,tryConvert,"");
153 }
154
155
156 /**
157 * Verify that a given XML deserialized produces the expected result
158 * @param data
159 * @param expected
160 * @param tryConvert
161 * @param comment extra text to add
162 * @throws Exception
163 */
164 protected void deserialize(String data, Object expected, boolean tryConvert, String comment)
165 throws Exception
166 {
167 Message message = new Message(header + data + footer);
168 message.setMessageContext(new MessageContext(server));
169 String postfix="";
170 if(comment!=null) {
171 postfix=" "+comment;
172 }
173
174 SOAPEnvelope envelope = (SOAPEnvelope)message.getSOAPEnvelope();
175 assertNotNull("SOAP envelope should not be null"+ postfix, envelope);
176
177 RPCElement body = (RPCElement)envelope.getFirstBody();
178 assertNotNull("SOAP body should not be null" + postfix, body);
179
180 Vector arglist = body.getParams();
181 assertNotNull("arglist", arglist);
182 assertTrue("param.size()<=0 {Should be > 0}" + postfix, arglist.size()>0);
183
184 RPCParam param = (RPCParam) arglist.get(0);
185 assertNotNull("SOAP param should not be null" + postfix, param);
186
187 Object result = param.getObjectValue();
188 if (!equals(result, expected)) {
189 String errorText = "Failed to decode " + data + postfix+" : ";
190 // Try to convert to the expected class
191 if (tryConvert) {
192 Object result2 = JavaUtils.convert(result, expected.getClass());
193 if (!equals(result2, expected)) {
194
195 assertEquals(errorText, expected, result);
196 }
197 } else {
198 assertEquals(errorText, expected, result);
199 }
200 }
201 }
202
203 public void testString() throws Exception {
204 deserialize("<result xsi:type=\"xsd:string\">abc</result>",
205 "abc");
206 }
207
208 public void testBoolean() throws Exception {
209 deserialize("<result xsi:type=\"xsd:boolean\">false</result>",
210 new Boolean(false));
211 deserialize("<result xsi:type=\"xsd:boolean\">true</result>",
212 new Boolean(true));
213 deserialize("<result xsi:type=\"xsd:boolean\">0</result>",
214 new Boolean(false));
215 deserialize("<result xsi:type=\"xsd:boolean\">1</result>",
216 new Boolean(true));
217 }
218
219 public void testDouble() throws Exception {
220 deserialize("<result xsi:type=\"xsd:double\">3.14</result>",
221 new Double(3.14));
222 }
223
224 public void testDoubleNaN() throws Exception {
225 deserialize("<result xsi:type=\"xsd:double\">NaN</result>",
226 new Double(Double.NaN));
227 }
228
229 public void testDoubleINF() throws Exception {
230 deserialize("<result xsi:type=\"xsd:double\">INF</result>",
231 new Double(Double.POSITIVE_INFINITY));
232 }
233
234 public void testDoubleNINF() throws Exception {
235 deserialize("<result xsi:type=\"xsd:double\">-INF</result>",
236 new Double(Double.NEGATIVE_INFINITY));
237 }
238
239 public void testFloat() throws Exception {
240 deserialize("<result xsi:type=\"xsd:float\">3.14</result>",
241 new Float(3.14F));
242 }
243
244 public void testFloatNaN() throws Exception {
245 deserialize("<result xsi:type=\"xsd:float\">NaN</result>",
246 new Float(Float.NaN));
247 }
248
249 public void testFloatINF() throws Exception {
250 deserialize("<result xsi:type=\"xsd:float\">INF</result>",
251 new Float(Float.POSITIVE_INFINITY));
252 }
253
254 public void testFloatNINF() throws Exception {
255 deserialize("<result xsi:type=\"xsd:float\">-INF</result>",
256 new Float(Float.NEGATIVE_INFINITY));
257 }
258
259 public void testInt() throws Exception {
260 deserialize("<result xsi:type=\"xsd:int\">10</result>",
261 new Integer(10));
262 }
263
264 public void testLong() throws Exception {
265 deserialize("<result xsi:type=\"xsd:long\">17</result>",
266 new Long(17));
267 }
268
269 public void testShort() throws Exception {
270 deserialize("<result xsi:type=\"xsd:short\">3</result>",
271 new Short((short)3));
272 }
273
274 public void testQName() throws Exception {
275 String ns = "http://test";
276 String local = "bar";
277
278 deserialize("<result xmlns:foo=\"" + ns + "\" xsi:type=\"xsd:QName\">foo:" + local + "</result>",
279 new QName(ns, local));
280
281 deserialize("<result xmlns:foo=\"" + ns + "\" xsi:type=\"xsd:QName\">\n foo:" + local + " \r\n </result>",
282 new QName(ns, local));
283 }
284
285 public void testArray() throws Exception {
286 Vector v = new Vector();
287 v.addElement("abc");
288 v.addElement("def");
289 deserialize("<result xsi:type=\"soapenc:Array\" " +
290 "soapenc:arrayType=\"xsd:string[2]\"> " +
291 "<item xsi:type=\"xsd:string\">abc</item>" +
292 "<item xsi:type=\"xsd:string\">def</item>" +
293 "</result>",
294 v, true);
295 }
296
297 public void testSparseArray1() throws Exception {
298 ArrayList list = new ArrayList(4);
299 list.add(null);
300 list.add(null);
301 list.add("abc");
302 list.add("def");
303 deserialize("<result xsi:type=\"soapenc:Array\" " +
304 "soapenc:arrayType=\"xsd:string[4]\" " +
305 "soapenc:offset=\"[2]\"> " +
306 "<item xsi:type=\"xsd:string\">abc</item>" +
307 "<item xsi:type=\"xsd:string\">def</item>" +
308 "</result>",
309 list, true);
310 }
311
312 public void testSparseArray2() throws Exception {
313 ArrayList list = new ArrayList(4);
314 list.add("abc");
315 list.add(null);
316 list.add("def");
317 deserialize("<result xsi:type=\"soapenc:Array\" " +
318 "soapenc:arrayType=\"xsd:string[4]\"> " +
319 "<item soapenc:position=\"[0]\" xsi:type=\"xsd:string\">abc</item>" +
320 "<item soapenc:position=\"[2]\" xsi:type=\"xsd:string\">def</item>" +
321 "</result>",
322 list, true);
323 }
324
325 public void testHugeSparseArray() throws Exception {
326 ArrayList list = new ArrayList(4);
327 list.add("abc");
328 list.add(null);
329 list.add("def");
330 deserialize("<result xsi:type=\"soapenc:Array\" " +
331 "soapenc:arrayType=\"xsd:string[50000000]\"> " +
332 "<item soapenc:position=\"[0]\" xsi:type=\"xsd:string\">abc</item>" +
333 "<item soapenc:position=\"[2]\" xsi:type=\"xsd:string\">def</item>" +
334 "</result>",
335 list, true);
336 }
337 public void testMap() throws Exception {
338 HashMap m = new HashMap();
339 m.put("abcKey", "abcVal");
340 m.put("defKey", "defVal");
341 deserialize("<result xsi:type=\"xmlsoap:Map\" " +
342 "xmlns:xmlsoap=\"http://xml.apache.org/xml-soap\"> " +
343 "<item>" +
344 "<key xsi:type=\"xsd:string\">abcKey</key>" +
345 "<value xsi:type=\"xsd:string\">abcVal</value>" +
346 "</item><item>" +
347 "<key xsi:type=\"xsd:string\">defKey</key>" +
348 "<value xsi:type=\"xsd:string\">defVal</value>" +
349 "</item>" +
350 "</result>",
351 m);
352 }
353
354 public void testHashtable() throws Exception {
355 Hashtable ht = new Hashtable();
356 ht.put("abcKey", "abcVal");
357 ht.put("defKey", "defVal");
358 deserialize("<result xsi:type=\"xmlsoap:Map\" " +
359 "xmlns:xmlsoap=\"http://xml.apache.org/xml-soap\"> " +
360 "<item>" +
361 "<key xsi:type=\"xsd:string\">abcKey</key>" +
362 "<value xsi:type=\"xsd:string\">abcVal</value>" +
363 "</item><item>" +
364 "<key xsi:type=\"xsd:string\">defKey</key>" +
365 "<value xsi:type=\"xsd:string\">defVal</value>" +
366 "</item>" +
367 "</result>",
368 ht, true);
369 }
370
371 public void testUntyped() throws Exception {
372 deserialize("<result>10</result>", "10");
373 }
374
375 public void testSOAPString() throws Exception {
376 deserialize("<result xsi:type=\"soapenc:string\">abc</result>",
377 "abc");
378 }
379
380 // Complicated array tests
381
382 // type=soapenc:Array
383 public void testArrayA() throws Exception {
384 String[] s = new String[] {"abc", "def"};
385 deserialize("<result xsi:type=\"soapenc:Array\" " +
386 "soapenc:arrayType=\"xsd:string[2]\"> " +
387 "<item xsi:type=\"xsd:string\">abc</item>" +
388 "<item xsi:type=\"xsd:string\">def</item>" +
389 "</result>",
390 s, true);
391 }
392
393 // Like above but missing [2] dimension
394 public void testArrayB() throws Exception {
395 String[] s = new String[] {"abc", "def"};
396 deserialize("<result xsi:type=\"soapenc:Array\" " +
397 "soapenc:arrayType=\"xsd:string[]\"> " +
398 "<item xsi:type=\"xsd:string\">abc</item>" +
399 "<item xsi:type=\"xsd:string\">def</item>" +
400 "</result>",
401 s, true);
402 }
403
404
405 // Like above but no xsi:type on elements
406 public void testArrayC() throws Exception {
407 String[] s = new String[] {"abc", "def"};
408 deserialize("<result xsi:type=\"soapenc:Array\" " +
409 "soapenc:arrayType=\"xsd:string[]\"> " +
410 "<item>abc</item>" +
411 "<item>def</item>" +
412 "</result>",
413 s, true);
414 }
415
416 // Now try with arrayType=xsd:anyType
417 public void testArrayD() throws Exception {
418 String[] s = new String[] {"abc", "def"};
419 deserialize("<result xsi:type=\"soapenc:Array\" " +
420 "soapenc:arrayType=\"xsd:anyType[]\"> " +
421 "<item xsi:type=\"xsd:string\">abc</item>" +
422 "<item xsi:type=\"xsd:string\">def</item>" +
423 "</result>",
424 s, true);
425 }
426
427 // Now try without arrayType
428 public void testArrayE() throws Exception {
429 String[] s = new String[] {"abc", "def"};
430 deserialize("<result xsi:type=\"soapenc:Array\" " +
431 "> " +
432 "<item xsi:type=\"xsd:string\">abc</item>" +
433 "<item xsi:type=\"xsd:string\">def</item>" +
434 "</result>",
435 s, true);
436 }
437
438 // Use a specific array type, not soapenc:Array
439 public void testArrayF() throws Exception {
440 String[] s = new String[] {"abc", "def"};
441 deserialize("<result xsi:type=\"me:ArrayOfString\" " +
442 "> " +
443 "<item xsi:type=\"xsd:string\">abc</item>" +
444 "<item xsi:type=\"xsd:string\">def</item>" +
445 "</result>",
446 s, true);
447 }
448
449 // Same as above without individual item types
450 public void testArrayG() throws Exception {
451 String[] s = new String[] {"abc", "def"};
452 deserialize("<result xsi:type=\"me:ArrayOfString\" " +
453 "> " +
454 "<item>abc</item>" +
455 "<item>def</item>" +
456 "</result>",
457 s, true);
458 }
459
460 // Same as above except result is an Object[]
461 public void testArrayH() throws Exception {
462 Object[] s = new Object[] {new String("abc"), new String("def")};
463 deserialize("<result xsi:type=\"me:ArrayOfString\" " +
464 "> " +
465 "<item>abc</item>" +
466 "<item>def</item>" +
467 "</result>",
468 s, true);
469 }
470
471 // Ooh La La
472 // Array of Object containing a String and an Integer
473 public void testArrayI() throws Exception {
474 Object[] s = new Object[] {new String("abc"), new Integer(123)};
475 deserialize("<result xsi:type=\"me:ArrayOfObject\" " +
476 "> " +
477 "<item xsi:type=\"xsd:string\">abc</item>" +
478 "<item xsi:type=\"soapenc:int\">123</item>" +
479 "</result>",
480 s, true);
481 }
482
483 // Same as above using arrayType=xsd:anyType
484 public void testArrayJ() throws Exception {
485 Object[] s = new Object[] {new String("abc"), new Integer(123)};
486 deserialize("<result xsi:type=\"me:ArrayOfObject\" " +
487 "soapenc:arrayType=\"xsd:anyType[]\"> " +
488 "<item xsi:type=\"xsd:string\">abc</item>" +
489 "<item xsi:type=\"soapenc:int\">123</item>" +
490 "</result>",
491 s, true);
492 }
493
494 // Same as above using type=soapenc:Array and no arrayType...bare bones
495 public void testArrayK() throws Exception {
496 Object[] s = new Object[] {new String("abc"), new Integer(123)};
497 deserialize("<result xsi:type=\"soapenc:Array\" " +
498 "> " +
499 "<item xsi:type=\"xsd:string\">abc</item>" +
500 "<item xsi:type=\"soapenc:int\">123</item>" +
501 "</result>",
502 s, true);
503 }
504
505 // This was created from a return received from a .NET service
506 public void testArrayL() throws Exception {
507 SOAPStruct[] s = new SOAPStruct[] {
508 new SOAPStruct(),
509 new SOAPStruct(),
510 new SOAPStruct()};
511 s[0].setVarInt(1);
512 s[0].setVarString("one");
513 s[0].setVarFloat(1.1F);
514 s[1].setVarInt(2);
515 s[1].setVarString("two");
516 s[1].setVarFloat(2.2F);
517 s[2].setVarInt(3);
518 s[2].setVarString("three");
519 s[2].setVarFloat(3.3F);
520
521 deserialize("<soapenc:Array id=\"ref-7\" soapenc:arrayType=\"me:SOAPStruct[3]\">" +
522 "<item href=\"#ref-8\"/>" +
523 "<item href=\"#ref-9\"/>" +
524 "<item href=\"#ref-10\"/>" +
525 "</soapenc:Array>" +
526
527 "<me:SOAPStruct id=\"ref-8\">" +
528 "<varString xsi:type=\"xsd:string\">one</varString>" +
529 "<varInt xsi:type=\"xsd:int\">1</varInt>" +
530 "<varFloat xsi:type=\"xsd:float\">1.1</varFloat>" +
531 "</me:SOAPStruct>" +
532
533 "<me:SOAPStruct id=\"ref-9\">" +
534 "<varString xsi:type=\"xsd:string\">two</varString>" +
535 "<varInt xsi:type=\"xsd:int\">2</varInt>" +
536 "<varFloat xsi:type=\"xsd:float\">2.2</varFloat>" +
537 "</me:SOAPStruct>" +
538
539 "<me:SOAPStruct id=\"ref-10\">" +
540 "<varString xsi:type=\"xsd:string\">three</varString>" +
541 "<varInt xsi:type=\"xsd:int\">3</varInt>" +
542 "<varFloat xsi:type=\"xsd:float\">3.3</varFloat>" +
543 "</me:SOAPStruct>",
544 s, true);
545 }
546
547 // Like above without multiref
548 public void testArrayM() throws Exception {
549 SOAPStruct[] s = new SOAPStruct[] {
550 new SOAPStruct(),
551 new SOAPStruct(),
552 new SOAPStruct()};
553 s[0].setVarInt(1);
554 s[0].setVarString("one");
555 s[0].setVarFloat(1.1F);
556 s[1].setVarInt(2);
557 s[1].setVarString("two");
558 s[1].setVarFloat(2.2F);
559 s[2].setVarInt(3);
560 s[2].setVarString("three");
561 s[2].setVarFloat(3.3F);
562 deserialize("<soapenc:Array id=\"ref-7\" soapenc:arrayType=\"me:SOAPStruct[3]\">" +
563 "<me:SOAPStruct>" +
564 "<varString xsi:type=\"xsd:string\">one</varString>" +
565 "<varInt xsi:type=\"xsd:int\">1</varInt>" +
566 "<varFloat xsi:type=\"xsd:float\">1.1</varFloat>" +
567 "</me:SOAPStruct>" +
568
569 "<me:SOAPStruct>" +
570 "<varString xsi:type=\"xsd:string\">two</varString>" +
571 "<varInt xsi:type=\"xsd:int\">2</varInt>" +
572 "<varFloat xsi:type=\"xsd:float\">2.2</varFloat>" +
573 "</me:SOAPStruct>" +
574
575 "<me:SOAPStruct>" +
576 "<varString xsi:type=\"xsd:string\">three</varString>" +
577 "<varInt xsi:type=\"xsd:int\">3</varInt>" +
578 "<varFloat xsi:type=\"xsd:float\">3.3</varFloat>" +
579 "</me:SOAPStruct>" +
580
581 "</soapenc:Array>",
582 s, true);
583 }
584 // Deserialize Bean with discreet names
585 public void testBeanWithIndexedPropA() throws Exception {
586 IndexPropBean s = new IndexPropBean();
587 s.setName(new String[] {"hello", "goodbye"});
588 deserialize("<result xsi:type=\"this:IndexPropBean\" " + "> " +
589 "<name href=\"#ref-1\"/>" +
590 "<name href=\"#ref-2\"/>" +
591 "</result>" +
592 "<item id=\"ref-1\" xsi:type=\"xsd:string\">hello</item>" +
593 "<item id=\"ref-2\" xsi:type=\"xsd:string\">goodbye</item>",
594 s, true);
595 }
596 // Deserialize Bean with names in an array
597 public void testBeanWithIndexedPropB() throws Exception {
598 IndexPropBean s = new IndexPropBean();
599 s.setName(new String[] {"hello", "goodbye"});
600 deserialize("<result xsi:type=\"this:IndexPropBean\" " + "> " +
601 "<name href=\"#ref-0\" /> " +
602 "</result>" +
603 "<soapenc:Array id=\"ref-0\" soapenc:arrayType=\"xsd:string[2]\"> " +
604 "<item xsi:type=\"xsd:string\">hello</item>" +
605 "<item xsi:type=\"xsd:string\">goodbye</item>" +
606 "</soapenc:Array>",
607 s, true);
608 }
609 // Struct within Struct
610 public void testStructStruct() throws Exception {
611
612 SOAPStruct s = new samples.echo.SOAPStruct();
613 s.setVarInt(1);
614 s.setVarString("one");
615 s.setVarFloat(1.1F);
616 SOAPStructStruct ss = new SOAPStructStruct();
617 ss.setVarString("hello");
618 ss.setVarInt(2);
619 ss.setVarFloat(2.2F);
620 ss.setVarStruct(s);
621
622 deserialize("<whatever xsi:type=\"me:SOAPStructStruct\">" +
623 "<varString xsi:type=\"xsd:string\">hello</varString>" +
624 "<varInt xsi:type=\"xsd:int\">2</varInt>" +
625 "<varFloat xsi:type=\"xsd:float\">2.2</varFloat>" +
626 "<varStruct xsi:type=\"me:SOAPStruct\">" +
627 "<varString xsi:type=\"xsd:string\">one</varString>" +
628 "<varInt xsi:type=\"xsd:int\">1</varInt>" +
629 "<varFloat xsi:type=\"xsd:float\">1.1</varFloat>" +
630 "</varStruct>" +
631 "</whatever>" , ss, true);
632 }
633
634 /*
635 public void testBug18390() throws Exception {
636 String[] s = new String[] {"GW671055X"};
637 deserialize("<molNames soapenc:arrayType=\"xsd:string[1]\"> " +
638 "<xsd:string xsi:type=\"xsd:string\">GW671055X</xsd:string>" +
639 "</molNames>",
640 s, true);
641 }
642
643 public void testBug25536() throws Exception {
644 int[] array = new int[]{3,4};
645 deserialize("<myFavoriteNumbers soapenc:arrayType=\"xsd:int[2]\">\n" +
646 " <number>3</number> \n" +
647 " <number>4</number> \n" +
648 "</myFavoriteNumbers>",array,true);
649 }
650 */
651
652 // Struct within Struct
653 public void testStructStruct2() throws Exception {
654 SOAPStruct s = new samples.echo.SOAPStruct();
655 s.setVarInt(1);
656 s.setVarString("one");
657 s.setVarFloat(1.1F);
658 SOAPStructStruct ss = new SOAPStructStruct();
659 ss.setVarString("hello");
660 ss.setVarInt(2);
661 ss.setVarFloat(2.2F);
662 ss.setVarStruct(s);
663
664 deserialize("<whatever xsi:type=\"me:SOAPStructStruct\">" +
665 "<varString>hello</varString>" +
666 "<varInt>2</varInt>" +
667 "<varFloat>2.2</varFloat>" +
668 "<varStruct>" +
669 "<varString>one</varString>" +
670 "<varInt>1</varInt>" +
671 "<varFloat>1.1</varFloat>" +
672 "</varStruct>" +
673 "</whatever>" , ss, true);
674 }
675 }