KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > encoding > TestDeser1999


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 TestDeser1999 extends TestDeser {
12
13     public TestDeser1999(String JavaDoc name) {
14         super(name, Constants.URI_1999_SCHEMA_XSI,
15                     Constants.URI_1999_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         // Test map with nulls and
23
// Test type references to the default namespace.
24
deserialize("<result xsi:type=\"xmlsoap:Map\" " +
25                     "xmlns:xmlsoap=\"http://xml.apache.org/xml-soap\"> " +
26                       "<item>" +
27                        "<key xsi:null=\"true\"/>" +
28                        "<value xsi:type=\"boolean\" xmlns=\"" +
29                          Constants.URI_1999_SCHEMA_XSD +
30                          "\">false</value>" +
31                       "</item><item>" +
32                        "<key xsi:type=\"string\" xmlns=\"" +
33                          Constants.URI_1999_SCHEMA_XSD +
34                          "\">hi</key>" +
35                        "<value xsi:null=\"true\"/>" +
36                       "</item>" +
37                     "</result>",
38                     m);
39     }
40
41     public void testArrayWithNullInt() throws Exception JavaDoc {
42         ArrayList JavaDoc list = new ArrayList JavaDoc(4);
43         list.add(new Integer JavaDoc(1));
44         list.add(null);
45         list.add(new Integer JavaDoc(3));
46         deserialize("<result xsi:type=\"soapenc:Array\" " +
47                             "soapenc:arrayType=\"xsd:int[3]\"> " +
48                        "<item xsi:type=\"xsd:int\">1</item>" +
49                        "<item xsi:null=\"true\"/>" +
50                        "<item xsi:type=\"xsd:int\">3</item>" +
51                     "</result>",
52                     list, true);
53     }
54     
55     public void testArrayWithNullString() throws Exception JavaDoc {
56         ArrayList JavaDoc list = new ArrayList JavaDoc(4);
57         list.add("abc");
58         list.add(null);
59         list.add("def");
60         deserialize("<result xsi:type=\"soapenc:Array\" " +
61                             "soapenc:arrayType=\"xsd:string[3]\"> " +
62                        "<item xsi:type=\"xsd:string\">abc</item>" +
63                        "<item xsi:null=\"true\"/>" +
64                        "<item xsi:type=\"xsd:string\">def</item>" +
65                     "</result>",
66                     list, true);
67     }
68     
69     public void testNullSOAPBoolean() throws Exception JavaDoc {
70         deserialize("<result xsi:type=\"soapenc:boolean\" xsi:null=\"true\" />",
71                     null);
72     }
73 }
74
Popular Tags