KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > encoding > TestDeser2000


1 package test.encoding;
2
3 import org.apache.axis.Constants;
4
5 import java.util.ArrayList JavaDoc;
6 import java.util.HashMap JavaDoc;
7
8 /**
9  * Test deserialization of SOAP responses
10  */

11 public class TestDeser2000 extends TestDeser {
12
13     public TestDeser2000(String JavaDoc name) {
14         super(name, Constants.URI_2000_SCHEMA_XSI,
15                     Constants.URI_2000_SCHEMA_XSD);
16     }
17
18     public void testMapWithNulls() throws Exception JavaDoc {
19         HashMap JavaDoc m = new HashMap JavaDoc();
20         m.put(null, new Boolean JavaDoc("false"));
21         m.put("hi", null);
22         deserialize("<result xsi:type=\"xmlsoap:Map\" " +
23                     "xmlns:xmlsoap=\"http://xml.apache.org/xml-soap\"> " +
24                       "<item>" +
25                        "<key xsi:null=\"true\"/>" +
26                        "<value xsi:type=\"xsd:boolean\">false</value>" +
27                       "</item><item>" +
28                        "<key xsi:type=\"xsd:string\">hi</key>" +
29                        "<value xsi:null=\"true\"/>" +
30                       "</item>" +
31                     "</result>",
32                     m);
33     }
34
35     public void testArrayWithNullInt() throws Exception JavaDoc {
36         ArrayList JavaDoc list = new ArrayList JavaDoc(4);
37         list.add(new Integer JavaDoc(1));
38         list.add(null);
39         list.add(new Integer JavaDoc(3));
40         deserialize("<result xsi:type=\"soapenc:Array\" " +
41                             "soapenc:arrayType=\"xsd:int[3]\"> " +
42                        "<item xsi:type=\"xsd:int\">1</item>" +
43                        "<item xsi:null=\"true\"/>" +
44                        "<item xsi:type=\"xsd:int\">3</item>" +
45                     "</result>",
46                     list, true);
47     }
48     
49     public void testArrayWithNullString() throws Exception JavaDoc {
50         ArrayList JavaDoc list = new ArrayList JavaDoc(4);
51         list.add("abc");
52         list.add(null);
53         list.add("def");
54         deserialize("<result xsi:type=\"soapenc:Array\" " +
55                             "soapenc:arrayType=\"xsd:string[3]\"> " +
56                        "<item xsi:type=\"xsd:string\">abc</item>" +
57                        "<item xsi:null=\"true\"/>" +
58                        "<item xsi:type=\"xsd:string\">def</item>" +
59                     "</result>",
60                     list, true);
61     }
62     
63     public void testNullSOAPBoolean() throws Exception JavaDoc {
64         deserialize("<result xsi:type=\"soapenc:boolean\" xsi:null=\"true\" />",
65                     null);
66     }
67 }
68
Popular Tags