Debian Codegraph @

test/wsdl/soap12/assertion/WhiteMesaSoap12TestSvcTestCase.java

raw
1 /**
2 * WhiteMesaSoap12TestSvcTestCase.java
3 *
4 * This file was auto-generated from WSDL
5 * by the Apache Axis WSDL2Java emitter.
6 */
7
8 package test.wsdl.soap12.assertion;
9
10 import org.apache.axis.message.SOAPHeaderElement;
11 import org.apache.axis.message.SOAPEnvelope;
12 import org.apache.axis.Constants;
13 import org.apache.axis.MessageContext;
14 import org.apache.axis.AxisFault;
15 import org.apache.axis.soap.SOAPConstants;
16 import org.apache.axis.constants.Style;
17 import org.apache.axis.client.Call;
18 import org.apache.axis.client.Service;
19
20 import java.util.Arrays;
21 import java.util.TimeZone;
22 import java.util.Calendar;
23 import java.util.ArrayList;
24 import java.util.Iterator;
25
26 public class WhiteMesaSoap12TestSvcTestCase extends junit.framework.TestCase {
27 public final String TEST_NS = "http://example.org/ts-tests";
28 public final String DOC_ENDPOINT = "http://www.whitemesa.net/soap12/test-doc";
29 public final String INTERMEDIARY_ENDPOINT = "http://www.whitemesa.net/soap12/test-intermediary";
30 public final String ROLE_A = "http://example.org/ts-tests/A";
31 public final String ROLE_B = "http://example.org/ts-tests/B";
32 public final String ROLE_C = "http://example.org/ts-tests/C";
33
34 public WhiteMesaSoap12TestSvcTestCase(java.lang.String name) {
35 super(name);
36 }
37
38 public void testSoap12TestDocPortWSDL() throws Exception {
39 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
40 java.net.URL url = new java.net.URL(new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestDocPortAddress() + "?WSDL");
41 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getServiceName());
42 assertTrue(service != null);
43 }
44
45 public void testSoap12TestRpcPortWSDL() throws Exception {
46 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
47 java.net.URL url = new java.net.URL(new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPortAddress() + "?WSDL");
48 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getServiceName());
49 assertTrue(service != null);
50 }
51
52 public void test1Soap12TestRpcPortReturnVoid() throws Exception {
53 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
54 try {
55 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
56 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
57 }
58 catch (javax.xml.rpc.ServiceException jre) {
59 if(jre.getLinkedCause()!=null)
60 jre.getLinkedCause().printStackTrace();
61 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
62 }
63 assertNotNull("binding is null", binding);
64
65 // Time out after a minute
66 binding.setTimeout(60000);
67
68 // Test operation
69 binding.returnVoid();
70 // TBD - validate results
71 }
72
73 public void test2Soap12TestRpcPortEchoStruct() throws Exception {
74 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
75 try {
76 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
77 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
78 }
79 catch (javax.xml.rpc.ServiceException jre) {
80 if(jre.getLinkedCause()!=null)
81 jre.getLinkedCause().printStackTrace();
82 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
83 }
84 assertNotNull("binding is null", binding);
85
86 // Time out after a minute
87 binding.setTimeout(60000);
88
89 test.wsdl.soap12.assertion.xsd.SOAPStruct input = new test.wsdl.soap12.assertion.xsd.SOAPStruct();
90 input.setVarFloat(-5);
91 input.setVarInt(10);
92 input.setVarString("EchoStruct");
93
94 // Test operation
95 test.wsdl.soap12.assertion.xsd.SOAPStruct output = null;
96 output = binding.echoStruct(input);
97 // TBD - validate results
98 assertEquals(input, output);
99 }
100
101 public void test3Soap12TestRpcPortEchoStructArray() throws Exception {
102 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
103 try {
104 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
105 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
106 }
107 catch (javax.xml.rpc.ServiceException jre) {
108 if(jre.getLinkedCause()!=null)
109 jre.getLinkedCause().printStackTrace();
110 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
111 }
112 assertNotNull("binding is null", binding);
113
114 // Time out after a minute
115 binding.setTimeout(60000);
116
117 test.wsdl.soap12.assertion.xsd.SOAPStruct[] input = new test.wsdl.soap12.assertion.xsd.SOAPStruct[1];
118 input[0] = new test.wsdl.soap12.assertion.xsd.SOAPStruct();
119 input[0].setVarFloat(-5);
120 input[0].setVarInt(10);
121 input[0].setVarString("EchoStruct");
122 // Test operation
123 test.wsdl.soap12.assertion.xsd.SOAPStruct[] output = null;
124 output = binding.echoStructArray(input);
125 // TBD - validate results
126 assertTrue(Arrays.equals(input,output));
127 }
128
129 public void test4Soap12TestRpcPortEchoStructAsSimpleTypes() throws Exception {
130 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
131 try {
132 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
133 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
134 }
135 catch (javax.xml.rpc.ServiceException jre) {
136 if(jre.getLinkedCause()!=null)
137 jre.getLinkedCause().printStackTrace();
138 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
139 }
140 assertNotNull("binding is null", binding);
141
142 // Time out after a minute
143 binding.setTimeout(60000);
144
145 test.wsdl.soap12.assertion.xsd.SOAPStruct input = new test.wsdl.soap12.assertion.xsd.SOAPStruct();
146 input.setVarFloat(-5);
147 input.setVarInt(10);
148 input.setVarString("EchoStructAsSimpleTypes");
149
150 javax.xml.rpc.holders.StringHolder out1 = new javax.xml.rpc.holders.StringHolder();
151 javax.xml.rpc.holders.IntHolder out2 = new javax.xml.rpc.holders.IntHolder();
152 javax.xml.rpc.holders.FloatHolder out3 = new javax.xml.rpc.holders.FloatHolder();
153
154 // Test operation
155 binding.echoStructAsSimpleTypes(input, out1, out2, out3);
156 // TBD - validate results
157 assertEquals(out1.value, input.getVarString());
158 assertEquals(out2.value, input.getVarInt());
159 assertTrue(out3.value == input.getVarFloat());
160 }
161
162 public void test5Soap12TestRpcPortEchoSimpleTypesAsStruct() throws Exception {
163 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
164 try {
165 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
166 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
167 }
168 catch (javax.xml.rpc.ServiceException jre) {
169 if(jre.getLinkedCause()!=null)
170 jre.getLinkedCause().printStackTrace();
171 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
172 }
173 assertNotNull("binding is null", binding);
174
175 // Time out after a minute
176 binding.setTimeout(60000);
177
178 String input1 = new String("EchoSimpleTypesAsStruct");
179 int input2 = 50;
180 float input3 = 45.5F;
181 // Test operation
182 test.wsdl.soap12.assertion.xsd.SOAPStruct output = null;
183 output = binding.echoSimpleTypesAsStruct(input1, input2, input3);
184
185 // TBD - validate results
186 assertEquals(input1, output.getVarString());
187 assertEquals(input2, output.getVarInt());
188 assertTrue(input3 == output.getVarFloat());
189 }
190
191 public void test6Soap12TestRpcPortEchoNestedStruct() throws Exception {
192 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
193 try {
194 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
195 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
196 }
197 catch (javax.xml.rpc.ServiceException jre) {
198 if(jre.getLinkedCause()!=null)
199 jre.getLinkedCause().printStackTrace();
200 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
201 }
202 assertNotNull("binding is null", binding);
203
204 // Time out after a minute
205 binding.setTimeout(60000);
206
207 test.wsdl.soap12.assertion.xsd.SOAPStructStruct input = new test.wsdl.soap12.assertion.xsd.SOAPStructStruct();
208 input.setVarFloat(-5);
209 input.setVarInt(10);
210 input.setVarString("EchoNestedStruct1");
211
212 test.wsdl.soap12.assertion.xsd.SOAPStruct inputInner = new test.wsdl.soap12.assertion.xsd.SOAPStruct();
213 inputInner.setVarFloat(-5);
214 inputInner.setVarInt(10);
215 inputInner.setVarString("EchoNestedStruct2");
216
217 input.setVarStruct(inputInner);
218
219 // Test operation
220 test.wsdl.soap12.assertion.xsd.SOAPStructStruct output = null;
221 output = binding.echoNestedStruct(input);
222
223 // TBD - validate results
224 assertEquals(input, output);
225 }
226
227 public void test7Soap12TestRpcPortEchoNestedArray() throws Exception {
228 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
229 try {
230 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
231 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
232 }
233 catch (javax.xml.rpc.ServiceException jre) {
234 if(jre.getLinkedCause()!=null)
235 jre.getLinkedCause().printStackTrace();
236 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
237 }
238 assertNotNull("binding is null", binding);
239
240 // Time out after a minute
241 binding.setTimeout(60000);
242
243 test.wsdl.soap12.assertion.xsd.SOAPArrayStruct input = new test.wsdl.soap12.assertion.xsd.SOAPArrayStruct();
244 input.setVarFloat(-5);
245 input.setVarInt(10);
246 input.setVarString("EchoNestedArray1");
247 input.setVarArray(new String[] {"EchoNestedArray2","EchoNestedArray3","EchoNestedArray4"});
248
249 // TODO: This does not work :(
250 //// Test operation
251 //test.wsdl.soap12.assertion.xsd.SOAPArrayStruct output = null;
252 //output = binding.echoNestedArray(input);
253 //// TBD - validate results
254 //assertEquals(input, output);
255 }
256
257 public void test8Soap12TestRpcPortEchoFloatArray() throws Exception {
258 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
259 try {
260 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
261 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
262 }
263 catch (javax.xml.rpc.ServiceException jre) {
264 if(jre.getLinkedCause()!=null)
265 jre.getLinkedCause().printStackTrace();
266 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
267 }
268 assertNotNull("binding is null", binding);
269
270 // Time out after a minute
271 binding.setTimeout(60000);
272
273 float[] input = new float[] {
274 1.1F,
275 1.2F,
276 1.3F
277 };
278
279 // Test operation
280 float[] output = null;
281 output = binding.echoFloatArray(input);
282
283 // TBD - validate results
284 assertTrue(Arrays.equals(input,output));
285 }
286
287 public void test9Soap12TestRpcPortEchoStringArray() throws Exception {
288 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
289 try {
290 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
291 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
292 }
293 catch (javax.xml.rpc.ServiceException jre) {
294 if(jre.getLinkedCause()!=null)
295 jre.getLinkedCause().printStackTrace();
296 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
297 }
298 assertNotNull("binding is null", binding);
299
300 // Time out after a minute
301 binding.setTimeout(60000);
302
303 String[] input = new String[] {
304 "1.1F",
305 "1.2F",
306 "1.3F"
307 };
308 // Test operation
309 java.lang.String[] output = null;
310 output = binding.echoStringArray(input);
311
312 // TBD - validate results
313 assertTrue(Arrays.equals(input,output));
314 }
315
316 public void test10Soap12TestRpcPortEchoIntegerArray() throws Exception {
317 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
318 try {
319 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
320 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
321 }
322 catch (javax.xml.rpc.ServiceException jre) {
323 if(jre.getLinkedCause()!=null)
324 jre.getLinkedCause().printStackTrace();
325 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
326 }
327 assertNotNull("binding is null", binding);
328
329 // Time out after a minute
330 binding.setTimeout(60000);
331
332 int[] input = new int[] {
333 1,
334 2,
335 3
336 };
337 // Test operation
338 int[] output = null;
339 output = binding.echoIntegerArray(input);
340
341 // TBD - validate results
342 assertTrue(Arrays.equals(input,output));
343 }
344
345 public void test11Soap12TestRpcPortEchoBase64() throws Exception {
346 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
347 try {
348 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
349 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
350 }
351 catch (javax.xml.rpc.ServiceException jre) {
352 if(jre.getLinkedCause()!=null)
353 jre.getLinkedCause().printStackTrace();
354 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
355 }
356 assertNotNull("binding is null", binding);
357
358 // Time out after a minute
359 binding.setTimeout(60000);
360
361 byte[] input = new byte[] {0xC, 0xA, 0xF, 0xE};
362
363 // Test operation
364 byte[] output = null;
365 output = binding.echoBase64(input);
366
367 // TBD - validate results
368 assertTrue(Arrays.equals(input,output));
369 }
370
371 public void test12Soap12TestRpcPortEchoBoolean() throws Exception {
372 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
373 try {
374 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
375 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
376 }
377 catch (javax.xml.rpc.ServiceException jre) {
378 if(jre.getLinkedCause()!=null)
379 jre.getLinkedCause().printStackTrace();
380 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
381 }
382 assertNotNull("binding is null", binding);
383
384 // Time out after a minute
385 binding.setTimeout(60000);
386
387 // Test operation
388 boolean value = false;
389 value = binding.echoBoolean(true);
390 // TBD - validate results
391 assertEquals(true, value);
392 }
393
394 public void test13Soap12TestRpcPortEchoDate() throws Exception {
395 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
396 try {
397 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
398 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
399 }
400 catch (javax.xml.rpc.ServiceException jre) {
401 if(jre.getLinkedCause()!=null)
402 jre.getLinkedCause().printStackTrace();
403 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
404 }
405 assertNotNull("binding is null", binding);
406
407 // Time out after a minute
408 binding.setTimeout(60000);
409
410 java.util.Calendar input = java.util.Calendar.getInstance();
411 input.setTimeZone(TimeZone.getTimeZone("GMT"));
412 input.set(Calendar.MILLISECOND, 0);
413
414 java.util.Calendar output = null;
415 output = binding.echoDate(input);
416 output.setTimeZone(TimeZone.getTimeZone("GMT"));
417 assertEquals(input, output);
418 }
419
420 public void test14Soap12TestRpcPortEchoDecimal() throws Exception {
421 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
422 try {
423 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
424 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
425 }
426 catch (javax.xml.rpc.ServiceException jre) {
427 if(jre.getLinkedCause()!=null)
428 jre.getLinkedCause().printStackTrace();
429 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
430 }
431 assertNotNull("binding is null", binding);
432
433 // Time out after a minute
434 binding.setTimeout(60000);
435
436 java.math.BigDecimal input = new java.math.BigDecimal(5000);
437
438 // Test operation
439 java.math.BigDecimal output = null;
440 output = binding.echoDecimal(input);
441
442 // TBD - validate results
443 assertEquals(input, output);
444 }
445
446 public void test15Soap12TestRpcPortEchoFloat() throws Exception {
447 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
448 try {
449 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
450 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
451 }
452 catch (javax.xml.rpc.ServiceException jre) {
453 if(jre.getLinkedCause()!=null)
454 jre.getLinkedCause().printStackTrace();
455 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
456 }
457 assertNotNull("binding is null", binding);
458
459 // Time out after a minute
460 binding.setTimeout(60000);
461
462 float input = -334.5F;
463 // Test operation
464 float output = 0;
465 output = binding.echoFloat(input);
466 // TBD - validate results
467 assertTrue(input == output);
468 }
469
470 public void test16Soap12TestRpcPortEchoString() throws Exception {
471 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
472 try {
473 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
474 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
475 }
476 catch (javax.xml.rpc.ServiceException jre) {
477 if(jre.getLinkedCause()!=null)
478 jre.getLinkedCause().printStackTrace();
479 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
480 }
481 assertNotNull("binding is null", binding);
482
483 // Time out after a minute
484 binding.setTimeout(60000);
485
486 // Test operation
487 java.lang.String value = null;
488 value = binding.echoString(new java.lang.String("EchoString"));
489
490 // TBD - validate results
491 assertEquals("EchoString", value);
492 }
493
494 public void test17Soap12TestRpcPortCountItems() throws Exception {
495 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
496 try {
497 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
498 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
499 }
500 catch (javax.xml.rpc.ServiceException jre) {
501 if(jre.getLinkedCause()!=null)
502 jre.getLinkedCause().printStackTrace();
503 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
504 }
505 assertNotNull("binding is null", binding);
506
507 // Time out after a minute
508 binding.setTimeout(60000);
509
510 // Test operation
511 int output = -3;
512 output = binding.countItems(new java.lang.String[] {"Life","is","a","box","of","chocolates"});
513 // TBD - validate results
514 assertEquals(output, 6);
515 }
516
517 public void test18Soap12TestRpcPortIsNil() throws Exception {
518 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding;
519 try {
520 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub)
521 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort();
522 }
523 catch (javax.xml.rpc.ServiceException jre) {
524 if(jre.getLinkedCause()!=null)
525 jre.getLinkedCause().printStackTrace();
526 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
527 }
528 assertNotNull("binding is null", binding);
529
530 // Time out after a minute
531 binding.setTimeout(60000);
532
533 // TODO: This does not work :(
534 //// Test operation
535 //boolean value = binding.isNil(new java.lang.String("isNil"));
536 //
537 //// TBD - validate results
538 //assertEquals(false, value);
539 }
540
541 /**
542 * Several tests (T1, etc) use the same functionality, send an empty body
543 * with the "echoOk" header using various roles, and check the return in the
544 * "responseOk" header.
545 *
546 * @throws Exception
547 */
548 protected void testEchoOkHeaderWithEmptyBody(String role) throws Exception {
549 test.wsdl.soap12.assertion.Soap12TestDocBindingStub binding;
550 try {
551 binding = (test.wsdl.soap12.assertion.Soap12TestDocBindingStub)
552 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestDocPort();
553 }
554 catch (javax.xml.rpc.ServiceException jre) {
555 if(jre.getLinkedCause()!=null)
556 jre.getLinkedCause().printStackTrace();
557 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
558 }
559 assertNotNull("binding is null", binding);
560
561 // Time out after a minute
562 binding.setTimeout(60000);
563
564 // Test operation
565 SOAPHeaderElement header =
566 new SOAPHeaderElement(TEST_NS, "echoOk");
567 if (role != null)
568 header.setRole(role);
569 header.setObjectValue("this is a test");
570 binding.setHeader(header);
571 binding.emptyBody();
572 // Get the response header
573 SOAPHeaderElement respHeader =
574 binding.getHeader(TEST_NS,
575 "responseOk");
576 assertNotNull("Missing response header", respHeader);
577 assertEquals("this is a test", respHeader.getValue());
578 }
579
580 /**
581 * Test T1 - echoOk header with empty body using "next" role
582 *
583 * @throws Exception
584 */
585 public void testT1() throws Exception {
586 testEchoOkHeaderWithEmptyBody(Constants.URI_SOAP12_NEXT_ROLE);
587 }
588
589 /**
590 * Test T2 - echoOk header with empty body using supported role
591 *
592 * @throws Exception
593 */
594 public void testT2() throws Exception {
595 testEchoOkHeaderWithEmptyBody("http://example.org/ts-tests/C");
596 }
597
598 /**
599 * Test T3 - echoOk header with empty body using no role
600 *
601 * @throws Exception
602 */
603 public void testT3() throws Exception {
604 testEchoOkHeaderWithEmptyBody(null);
605 }
606
607 /**
608 * Test T4 - echoOk header with empty body using role ""
609 *
610 * @throws Exception
611 */
612 public void testT4() throws Exception {
613 testEchoOkHeaderWithEmptyBody("");
614 }
615
616 /**
617 * Test T5 - echoOk header to unrecognized role (should be ignored)
618 *
619 * @throws Exception
620 */
621 public void testT5() throws Exception {
622 Call call = new Call(DOC_ENDPOINT);
623 call.setOperationStyle(Style.DOCUMENT);
624 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
625 SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
626 SOAPHeaderElement header = new SOAPHeaderElement(TEST_NS, "echoOk");
627 header.setRole(ROLE_B);
628 header.setObjectValue("test header");
629 reqEnv.addHeader(header);
630 SOAPEnvelope respEnv = call.invoke(reqEnv);
631 assertTrue("Got unexpected header!", respEnv.getHeaders().isEmpty());
632 }
633
634 /**
635 * Test T6 - echoOk header targeted at endpoint via intermediary
636 *
637 * @throws Exception
638 */
639 public void testT6() throws Exception {
640 Call call = new Call(INTERMEDIARY_ENDPOINT);
641 call.setOperationStyle(Style.DOCUMENT);
642 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
643 SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
644 SOAPHeaderElement header = new SOAPHeaderElement(TEST_NS, "echoOk");
645 header.setRole(ROLE_C);
646 header.setObjectValue("test header");
647 reqEnv.addHeader(header);
648 SOAPEnvelope respEnv = call.invoke(reqEnv);
649 SOAPHeaderElement respHeader =
650 respEnv.getHeaderByName(TEST_NS, "responseOk");
651 assertNotNull(respHeader);
652 assertEquals("test header", respHeader.getValue());
653 }
654
655 /**
656 * Test T12 - unknown header, with MustUnderstand true
657 *
658 * @throws Exception
659 */
660 public void testT12() throws Exception {
661 Call call = new Call(DOC_ENDPOINT);
662 call.setOperationStyle(Style.DOCUMENT);
663 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
664 SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
665 SOAPHeaderElement header = new SOAPHeaderElement(TEST_NS, "Unknown");
666 header.setObjectValue("test header");
667 header.setMustUnderstand(true);
668 reqEnv.addHeader(header);
669 try {
670 call.invoke(reqEnv);
671 } catch (AxisFault fault) {
672 assertEquals(Constants.FAULT_SOAP12_MUSTUNDERSTAND,
673 fault.getFaultCode());
674 ArrayList headers = fault.getHeaders();
675 // If there is a NotUnderstood header, check it
676 for (Iterator i = headers.iterator(); i.hasNext();) {
677 SOAPHeaderElement h = (SOAPHeaderElement) i.next();
678 if (h.getQName().equals(Constants.QNAME_NOTUNDERSTOOD)) {
679 // TODO : check qname attribute
680 }
681 }
682 return;
683 }
684 fail("Didn't receive expected fault!");
685 }
686
687 public void test20Soap12TestDocPortEchoOk() throws Exception {
688 test.wsdl.soap12.assertion.Soap12TestDocBindingStub binding;
689 try {
690 binding = (test.wsdl.soap12.assertion.Soap12TestDocBindingStub)
691 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestDocPort();
692 }
693 catch (javax.xml.rpc.ServiceException jre) {
694 if(jre.getLinkedCause()!=null)
695 jre.getLinkedCause().printStackTrace();
696 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
697 }
698 assertNotNull("binding is null", binding);
699
700 // Time out after a minute
701 binding.setTimeout(60000);
702
703 // TODO: This does not work :(
704 //// Test operation
705 //java.lang.String value = null;
706 // value = binding.echoOk(new java.lang.String("EchoOk"));
707 //// TBD - validate results
708 //assertEquals(value, "EchoOk");
709 }
710
711 }