Debian Codegraph @

test/wsdl/marshall/MarshallTestCase.java

raw
1 /**
2 * MarshallTestCase.java
3 *
4 * This file was auto-generated from WSDL
5 * by the Apache Axis 1.2RC2 Feb 06, 2005 (12:14:42 EST) WSDL2Java emitter.
6 */
7 package test.wsdl.marshall;
8
9 import java.math.BigInteger;
10 import java.util.Iterator;
11 import javax.xml.namespace.QName;
12 import org.apache.axis.Message;
13 import org.apache.axis.message.MessageElement;
14 import org.apache.axis.message.SOAPBody;
15
16 public class MarshallTestCase extends junit.framework.TestCase {
17
18 private static final String DIMS = "[3]";
19
20 public MarshallTestCase(java.lang.String name) {
21 super(name);
22 }
23
24 public void testMarshallPortWSDL() throws Exception {
25 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory
26 .newInstance();
27 java.net.URL url = new java.net.URL(
28 new test.wsdl.marshall.MarshallLocator()
29 .getMarshallPortAddress()
30 + "?WSDL");
31 javax.xml.rpc.Service service = serviceFactory.createService(url,
32 new test.wsdl.marshall.MarshallLocator().getServiceName());
33 assertTrue(service != null);
34 }
35
36 public void test1MarshallPortMyBeanArray() throws Exception {
37 test.wsdl.marshall.MarshallBindingStub binding;
38 try {
39 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
40 .getMarshallPort();
41 } catch (javax.xml.rpc.ServiceException jre) {
42 if (jre.getLinkedCause() != null)
43 jre.getLinkedCause().printStackTrace();
44 throw new junit.framework.AssertionFailedError(
45 "JAX-RPC ServiceException caught: " + jre);
46 }
47 assertNotNull("binding is null", binding);
48 // Time out after a minute
49 binding.setTimeout(60000);
50 // Test operation
51 test.wsdl.marshall.types.MyBean[] value = null;
52 value = binding.myBeanArray(new test.wsdl.marshall.types.MyBean[0]);
53 // TBD - validate results
54 }
55
56 public void test2MarshallPortMyBeanMultiArray() throws Exception {
57 test.wsdl.marshall.MarshallBindingStub binding;
58 try {
59 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
60 .getMarshallPort();
61 } catch (javax.xml.rpc.ServiceException jre) {
62 if (jre.getLinkedCause() != null)
63 jre.getLinkedCause().printStackTrace();
64 throw new junit.framework.AssertionFailedError(
65 "JAX-RPC ServiceException caught: " + jre);
66 }
67 assertNotNull("binding is null", binding);
68 // Time out after a minute
69 binding.setTimeout(60000);
70 // Test operation
71 test.wsdl.marshall.types.MyBean[][] value = null;
72 value = binding
73 .myBeanMultiArray(new test.wsdl.marshall.types.MyBean[0][0]);
74 // TBD - validate results
75 }
76
77 public void test3MarshallPortMyBean() throws Exception {
78 test.wsdl.marshall.MarshallBindingStub binding;
79 try {
80 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
81 .getMarshallPort();
82 } catch (javax.xml.rpc.ServiceException jre) {
83 if (jre.getLinkedCause() != null)
84 jre.getLinkedCause().printStackTrace();
85 throw new junit.framework.AssertionFailedError(
86 "JAX-RPC ServiceException caught: " + jre);
87 }
88 assertNotNull("binding is null", binding);
89 // Time out after a minute
90 binding.setTimeout(60000);
91 // Test operation
92 test.wsdl.marshall.types.MyBean value = null;
93 value = binding.myBean(new test.wsdl.marshall.types.MyBean());
94 // TBD - validate results
95 }
96
97 public void test4MarshallPortArrayOfSoapEncString() throws Exception {
98 test.wsdl.marshall.MarshallBindingStub binding;
99 try {
100 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
101 .getMarshallPort();
102 } catch (javax.xml.rpc.ServiceException jre) {
103 if (jre.getLinkedCause() != null)
104 jre.getLinkedCause().printStackTrace();
105 throw new junit.framework.AssertionFailedError(
106 "JAX-RPC ServiceException caught: " + jre);
107 }
108 assertNotNull("binding is null", binding);
109 // Time out after a minute
110 binding.setTimeout(60000);
111 // Test operation
112 String[] value = new String[] { "1", "2", "", null, "5" };
113 String[] ret = null;
114 ret = binding.arrayOfSoapEncString(value);
115 QName responseQName = new QName("http://marshall.wsdl.test",
116 "ArrayOfSoapEncStringResponse");
117 QName returnQName = new QName("return");
118 Message m = binding._getCall().getResponseMessage();
119 SOAPBody body = (SOAPBody) m.getSOAPBody();
120 MessageElement response = body.getChildElement(responseQName);
121 MessageElement returnE = response.getChildElement(returnQName);
122 String arrayType = returnE.getAttributeNS(
123 "http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
124 assertEquals("wrong array type", "soapenc:string[5]", arrayType);
125 // TBD - validate results
126 }
127
128 public void test5MarshallPortArrayOfXsdString() throws Exception {
129 test.wsdl.marshall.MarshallBindingStub binding;
130 try {
131 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
132 .getMarshallPort();
133 } catch (javax.xml.rpc.ServiceException jre) {
134 if (jre.getLinkedCause() != null)
135 jre.getLinkedCause().printStackTrace();
136 throw new junit.framework.AssertionFailedError(
137 "JAX-RPC ServiceException caught: " + jre);
138 }
139 assertNotNull("binding is null", binding);
140 // Time out after a minute
141 binding.setTimeout(60000);
142 // Test operation
143 String[] value = new String[] { "1", "2", "", null, "5" };
144 String[] ret = null;
145 ret = binding.arrayOfXsdString(value);
146 // TBD - validate results
147 QName responseQName = new QName("http://marshall.wsdl.test",
148 "ArrayOfXsdStringResponse");
149 QName returnQName = new QName("return");
150 Message m = binding._getCall().getResponseMessage();
151 SOAPBody body = (SOAPBody) m.getSOAPBody();
152 MessageElement response = body.getChildElement(responseQName);
153 MessageElement returnE = response.getChildElement(returnQName);
154 String arrayType = returnE.getAttributeNS(
155 "http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
156 assertEquals("wrong array type", "xsd:string[5]", arrayType);
157 }
158
159 public void test6MarshallPortArrayOfbase64Binary() throws Exception {
160 test.wsdl.marshall.MarshallBindingStub binding;
161 try {
162 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
163 .getMarshallPort();
164 } catch (javax.xml.rpc.ServiceException jre) {
165 if (jre.getLinkedCause() != null)
166 jre.getLinkedCause().printStackTrace();
167 throw new junit.framework.AssertionFailedError(
168 "JAX-RPC ServiceException caught: " + jre);
169 }
170 assertNotNull("binding is null", binding);
171 // Time out after a minute
172 binding.setTimeout(60000);
173 // Test operation
174 byte[][] value = null;
175 value = binding.arrayOfbase64Binary(getBiDimensionnalByteArray());
176 // TBD - validate results
177 checkArrayReturnValues(value);
178 QName responseQName = new QName("http://marshall.wsdl.test",
179 "ArrayOfbase64BinaryResponse");
180 String innerTypeString = "xsd:base64Binary";
181 String arrayTypeString = innerTypeString + DIMS;
182 Message m = binding._getCall().getResponseMessage();
183 SOAPBody body = (SOAPBody) m.getSOAPBody();
184 checkReturnMessage(body, responseQName, arrayTypeString,
185 innerTypeString);
186 }
187
188 public void test7MarshallPortArrayOfhexBinary() throws Exception {
189 test.wsdl.marshall.MarshallBindingStub binding;
190 try {
191 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
192 .getMarshallPort();
193 } catch (javax.xml.rpc.ServiceException jre) {
194 if (jre.getLinkedCause() != null)
195 jre.getLinkedCause().printStackTrace();
196 throw new junit.framework.AssertionFailedError(
197 "JAX-RPC ServiceException caught: " + jre);
198 }
199 assertNotNull("binding is null", binding);
200 // Time out after a minute
201 binding.setTimeout(60000);
202 // Test operation
203 byte[][] value = null;
204 value = binding.arrayOfhexBinary(getBiDimensionnalByteArray());
205 // TBD - validate results
206 checkArrayReturnValues(value);
207 QName responseQName = new QName("http://marshall.wsdl.test",
208 "ArrayOfhexBinaryResponse");
209 String innerTypeString = "xsd:hexBinary";
210 String arrayTypeString = innerTypeString + DIMS;
211 Message m = binding._getCall().getResponseMessage();
212 SOAPBody body = (SOAPBody) m.getSOAPBody();
213 checkReturnMessage(body, responseQName, arrayTypeString,
214 innerTypeString);
215 }
216
217 public void test8MarshallPortArrayOfsoapencbase64() throws Exception {
218 test.wsdl.marshall.MarshallBindingStub binding;
219 try {
220 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
221 .getMarshallPort();
222 } catch (javax.xml.rpc.ServiceException jre) {
223 if (jre.getLinkedCause() != null)
224 jre.getLinkedCause().printStackTrace();
225 throw new junit.framework.AssertionFailedError(
226 "JAX-RPC ServiceException caught: " + jre);
227 }
228 assertNotNull("binding is null", binding);
229 // Time out after a minute
230 binding.setTimeout(60000);
231 // Test operation
232 byte[][] value = null;
233 value = binding.arrayOfsoapencbase64(getBiDimensionnalByteArray());
234 // TBD - validate results
235 checkArrayReturnValues(value);
236 QName responseQName = new QName("http://marshall.wsdl.test",
237 "ArrayOfsoapencbase64Response");
238 String innerTypeString = "soapenc:base64";
239 String arrayTypeString = innerTypeString + DIMS;
240 Message m = binding._getCall().getResponseMessage();
241 SOAPBody body = (SOAPBody) m.getSOAPBody();
242 checkReturnMessage(body, responseQName, arrayTypeString,
243 innerTypeString);
244 }
245
246 public void test9MarshallPortArrayOfbase64BinaryUnbounded()
247 throws Exception {
248 test.wsdl.marshall.MarshallBindingStub binding;
249 try {
250 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
251 .getMarshallPort();
252 } catch (javax.xml.rpc.ServiceException jre) {
253 if (jre.getLinkedCause() != null)
254 jre.getLinkedCause().printStackTrace();
255 throw new junit.framework.AssertionFailedError(
256 "JAX-RPC ServiceException caught: " + jre);
257 }
258 assertNotNull("binding is null", binding);
259 // Time out after a minute
260 binding.setTimeout(60000);
261 // Test operation
262 byte[][] value = null;
263 value = binding
264 .arrayOfbase64BinaryUnbounded(getBiDimensionnalByteArray());
265 // TBD - validate results
266 checkArrayReturnValues(value);
267
268 QName responseQName = new QName("http://marshall.wsdl.test",
269 "ArrayOfbase64BinaryUnboundedResponse");
270 String innerTypeString = "xsd:base64Binary";
271 String arrayTypeString = innerTypeString + DIMS;
272 Message m = binding._getCall().getResponseMessage();
273 SOAPBody body = (SOAPBody) m.getSOAPBody();
274 checkReturnMessage(body, responseQName, arrayTypeString,
275 innerTypeString);
276 }
277
278 public void test10MarshallPortArrayOfhexBinaryUnbounded() throws Exception {
279 test.wsdl.marshall.MarshallBindingStub binding;
280 try {
281 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
282 .getMarshallPort();
283 } catch (javax.xml.rpc.ServiceException jre) {
284 if (jre.getLinkedCause() != null)
285 jre.getLinkedCause().printStackTrace();
286 throw new junit.framework.AssertionFailedError(
287 "JAX-RPC ServiceException caught: " + jre);
288 }
289 assertNotNull("binding is null", binding);
290 // Time out after a minute
291 binding.setTimeout(60000);
292 // Test operation
293 byte[][] value = null;
294 value = binding.arrayOfhexBinaryUnbounded(getBiDimensionnalByteArray());
295 // TBD - validate results
296 checkArrayReturnValues(value);
297
298 QName responseQName = new QName("http://marshall.wsdl.test",
299 "ArrayOfhexBinaryUnboundedResponse");
300 String innerTypeString = "xsd:hexBinary";
301 String arrayTypeString = innerTypeString + DIMS;
302 Message m = binding._getCall().getResponseMessage();
303 SOAPBody body = (SOAPBody) m.getSOAPBody();
304 checkReturnMessage(body, responseQName, arrayTypeString,
305 innerTypeString);
306 }
307
308 public void test11MarshallPortArrayOfsoapencbase64Unbounded()
309 throws Exception {
310 test.wsdl.marshall.MarshallBindingStub binding;
311 try {
312 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
313 .getMarshallPort();
314 } catch (javax.xml.rpc.ServiceException jre) {
315 if (jre.getLinkedCause() != null)
316 jre.getLinkedCause().printStackTrace();
317 throw new junit.framework.AssertionFailedError(
318 "JAX-RPC ServiceException caught: " + jre);
319 }
320 assertNotNull("binding is null", binding);
321 // Time out after a minute
322 binding.setTimeout(60000);
323 // Test operation
324 byte[][] value = null;
325 value = binding
326 .arrayOfsoapencbase64Unbounded(getBiDimensionnalByteArray());
327 // TBD - validate results
328 checkArrayReturnValues(value);
329
330 QName responseQName = new QName("http://marshall.wsdl.test",
331 "ArrayOfsoapencbase64UnboundedResponse");
332 String innerTypeString = "soapenc:base64";
333 String arrayTypeString = innerTypeString + DIMS;
334 Message m = binding._getCall().getResponseMessage();
335 SOAPBody body = (SOAPBody) m.getSOAPBody();
336 checkReturnMessage(body, responseQName, arrayTypeString,
337 innerTypeString);
338 }
339
340 public void test12MarshallPortArrayOfArrayOfSoapEncString() throws Exception {
341 test.wsdl.marshall.MarshallBindingStub binding;
342 try {
343 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
344 .getMarshallPort();
345 } catch (javax.xml.rpc.ServiceException jre) {
346 if (jre.getLinkedCause() != null)
347 jre.getLinkedCause().printStackTrace();
348 throw new junit.framework.AssertionFailedError(
349 "JAX-RPC ServiceException caught: " + jre);
350 }
351 assertNotNull("binding is null", binding);
352 // Time out after a minute
353 binding.setTimeout(60000);
354 // Test operation
355 String[] v1 = new String[] { "a1", "a2", "", null, "a5", null};
356 String[] v2 = new String[] { "b1", "b2", "", null, "b5", null };
357 String[] v3 = new String[] { "c1", "c2", "", null, "c5", null };
358 String[][] value = new String[][] {v1, v2, v3};
359 String[][] ret = null;
360 ret = binding.arrayOfArrayOfSoapEncString(value);
361
362 // print Array
363 for(int i = 0; i < ret.length; i++) {
364 System.out.print("[");
365 for(int j = 0; j < ret[i].length; j++) {
366 System.out.print("[" + ret[i][j] + "]");
367 }
368 System.out.println("]");
369 }
370
371 assertEquals("array size incorrect", value.length, ret.length);
372 for(int i = 0; i < value.length; i++) {
373 assertEquals("array size incorrect", value[i].length, ret[i].length);
374 for(int j = 0; j < value[i].length; j++) {
375 assertEquals("value not equals", value[i][j], ret[i][j]);
376 }
377 }
378
379 QName responseQName = new QName("http://marshall.wsdl.test",
380 "ArrayOfArrayOfSoapEncStringResponse");
381 QName returnQName = new QName("return");
382 Message m = binding._getCall().getResponseMessage();
383
384 SOAPBody body = (SOAPBody) m.getSOAPBody();
385 MessageElement response = body.getChildElement(responseQName);
386 MessageElement returnE = response.getChildElement(returnQName);
387 String arrayType = returnE.getAttributeNS(
388 "http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
389 assertEquals("wrong array type", "soapenc:string[][3]", arrayType);
390
391
392 for (Iterator it = returnE.getChildElements(returnQName); it.hasNext();) {
393 returnE = (MessageElement) it.next();
394 arrayType = returnE.getAttributeNS(
395 "http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
396 assertEquals("wrong array type", "soapenc:string[6]", arrayType);
397
398
399 for (Iterator it2 = returnE.getChildElements(returnQName); it2.hasNext();) {
400 returnE = (MessageElement) it2.next();
401 String xsiType = returnE.getAttributeNS(
402 "http://www.w3.org/2001/XMLSchema-instance", "type");
403 assertEquals("wrong xsi type", "soapenc:string", xsiType);
404
405
406 }
407 }
408 // TBD - validate results
409 }
410
411 public void test13MarshallPortArrayOfArrayOfinteger() throws Exception {
412 test.wsdl.marshall.MarshallBindingStub binding;
413 try {
414 binding = (test.wsdl.marshall.MarshallBindingStub) new test.wsdl.marshall.MarshallLocator()
415 .getMarshallPort();
416 } catch (javax.xml.rpc.ServiceException jre) {
417 if (jre.getLinkedCause() != null)
418 jre.getLinkedCause().printStackTrace();
419 throw new junit.framework.AssertionFailedError(
420 "JAX-RPC ServiceException caught: " + jre);
421 }
422 assertNotNull("binding is null", binding);
423 // Time out after a minute
424 binding.setTimeout(60000);
425 // Test operation
426 BigInteger[] v1 = new BigInteger[] { new BigInteger("-3254687"), new BigInteger("0"), new BigInteger("3254687"), null};
427 BigInteger[] v2 = new BigInteger[] { new BigInteger("-3254688"), new BigInteger("0"), new BigInteger("3254688"), null};
428 BigInteger[] v3 = new BigInteger[] { new BigInteger("-3254689"), new BigInteger("0"), new BigInteger("3254689"), null};
429 BigInteger[][] value = new BigInteger[][] {v1, v2, v3};
430 BigInteger[][] ret = null;
431 ret = binding.arrayOfArrayOfinteger(value);
432
433 // print Array
434 for(int i = 0; i < ret.length; i++) {
435 System.out.print("[");
436 for(int j = 0; j < ret[i].length; j++) {
437 System.out.print("[" + ret[i][j] + "]");
438 }
439 System.out.println("]");
440 }
441
442 assertEquals("array size incorrect", value.length, ret.length);
443 for(int i = 0; i < value.length; i++) {
444 assertEquals("array size incorrect", value[i].length, ret[i].length);
445 for(int j = 0; j < value[i].length; j++) {
446 assertEquals("value not equals", value[i][j], ret[i][j]);
447 }
448 }
449
450 QName responseQName = new QName("http://marshall.wsdl.test",
451 "ArrayOfArrayOfintegerResponse");
452 QName returnQName = new QName("return");
453 Message m = binding._getCall().getResponseMessage();
454
455 SOAPBody body = (SOAPBody) m.getSOAPBody();
456 MessageElement response = body.getChildElement(responseQName);
457 MessageElement returnE = response.getChildElement(returnQName);
458 String arrayType = returnE.getAttributeNS(
459 "http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
460 assertEquals("wrong array type", "xsd:integer[][3]", arrayType);
461
462
463 for (Iterator it = returnE.getChildElements(returnQName); it.hasNext();) {
464 returnE = (MessageElement) it.next();
465 arrayType = returnE.getAttributeNS(
466 "http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
467 assertEquals("wrong array type", "xsd:integer[4]", arrayType);
468
469
470 for (Iterator it2 = returnE.getChildElements(returnQName); it2.hasNext();) {
471 returnE = (MessageElement) it2.next();
472 // we have multiRef to follow here
473 MessageElement real = returnE.getRealElement();
474 String xsiType = real.getAttributeNS(
475 "http://www.w3.org/2001/XMLSchema-instance", "type");
476 assertEquals("wrong xsi type", "xsd:integer", xsiType);
477
478
479 }
480 }
481 // TBD - validate results
482 }
483
484 /**
485 * @param m
486 */
487 private void printMessage(Message m) throws Exception {
488 System.out.println();
489 m.writeTo(System.out);
490 System.out.println();
491 }
492
493 /**
494 * @param responseQName
495 * @param arrayTypeString
496 * @param innerTypeString
497 */
498 private void checkReturnMessage(SOAPBody body, QName responseQName,
499 String arrayTypeString, String innerTypeString) {
500 // Message should looks like this :
501 // ns:<methodName>Response
502 // return @soapenc:arrayType
503 // return @xsi:type
504 QName returnQName = new QName("return");
505 MessageElement response = body.getChildElement(responseQName);
506 // check arrayType attribute
507 MessageElement returnE = response.getChildElement(returnQName);
508 String arrayType = returnE.getAttributeNS(
509 "http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
510 assertEquals("wrong array type", arrayTypeString, arrayType);
511 for (Iterator i = returnE.getChildElements(returnQName); i.hasNext();) {
512 MessageElement ret = (MessageElement) i.next();
513 String xsiType = ret.getAttributeNS(
514 "http://www.w3.org/2001/XMLSchema-instance", "type");
515 assertNotNull("should have an xsi:type attribute", xsiType);
516 assertEquals("wrong xsi:type", innerTypeString, xsiType);
517 }
518 }
519
520 /**
521 * @param value
522 */
523 private void checkArrayReturnValues(byte[][] value) {
524 assertEquals("wrong array length", 3, value.length);
525 assertEquals("wrong subarray length", 3, value[0].length);
526 assertEquals("wrong subarray length", 3, value[1].length);
527 assertEquals("wrong subarray length", 3, value[2].length);
528 assertEquals("wrong value[0][0]", -127, value[0][0]);
529 assertEquals("wrong value[0][1]", 0, value[0][1]);
530 assertEquals("wrong value[0][2]", 127, value[0][2]);
531 assertEquals("wrong value[1][0]", -127, value[1][0]);
532 assertEquals("wrong value[1][1]", 0, value[1][1]);
533 assertEquals("wrong value[1][2]", 127, value[1][2]);
534 assertEquals("wrong value[2][0]", -127, value[2][0]);
535 assertEquals("wrong value[2][1]", 0, value[2][1]);
536 assertEquals("wrong value[2][2]", 127, value[2][2]);
537 }
538
539 /**
540 * @return
541 */
542 private byte[][] getBiDimensionnalByteArray() {
543 byte[][] array = new byte[3][];
544 array[0] = new byte[3];
545 array[1] = new byte[3];
546 array[2] = new byte[3];
547 array[0][0] = -127;
548 array[0][1] = 0;
549 array[0][2] = 127;
550 array[1][0] = -127;
551 array[1][1] = 0;
552 array[1][2] = 127;
553 array[2][0] = -127;
554 array[2][1] = 0;
555 array[2][2] = 127;
556 return array;
557 }
558
559 }