/
Client.java
1644 lines (1520 loc) · 62.9 KB
/
Client.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2007, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
/*
* $Id$
*/
package com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped;
import com.sun.ts.lib.util.*;
import com.sun.ts.lib.porting.*;
import com.sun.ts.lib.harness.*;
import java.util.*;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.sun.javatest.Status;
import com.sun.ts.lib.harness.ServiceEETest;
import com.sun.ts.tests.jaxws.sharedclients.ClientFactory;
import com.sun.ts.tests.jaxws.sharedclients.SOAPClient;
import com.sun.ts.tests.jaxws.sharedclients.DescriptionClient;
import com.sun.ts.tests.jaxws.wsi.constants.DescriptionConstants;
import com.sun.ts.tests.jaxws.wsi.constants.SOAPConstants;
import com.sun.ts.tests.jaxws.wsi.constants.SchemaConstants;
import com.sun.ts.tests.jaxws.wsi.utils.DescriptionUtils;
import com.sun.ts.tests.jaxws.wsi.j2w.NamespaceAttributeVerifier;
import java.lang.annotation.Annotation;
import jakarta.xml.bind.annotation.*;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import jakarta.xml.bind.annotation.adapters.HexBinaryAdapter;
import jakarta.activation.DataHandler;
import com.sun.ts.tests.jaxws.common.*;
public class Client extends ServiceEETest
implements DescriptionConstants, SOAPConstants, SchemaConstants {
/*
* The client.
*/
private DescriptionClient client;
/*
* The document.
*/
private Document document;
/**
* The generated WSDL file.
*/
private static final String WSDLLOC_URL = "j2wdlwrapped.wsdlloc.1";
private static final String TSHOME = "ts.home";
private String baseURL, wsdlFile;
private String tshome = null;
private String wsdlFileUrl = null;
private static final String EXPECTED_TARGETNAMESPACE = "http://doclitservice.org/wsdl";
private static final String EXPECTED_PORTTYPE_NAME = "MYJ2WDLSharedEndpoint";
private static final String EXPECTED_PORT_NAME = "J2WDLSharedEndpointPort";
private static final String EXPECTED_SERVICE_NAME = "J2WDLSharedService";
private static final String ONEWAY_METHOD = "oneWayOperation";
private static final String TWOWAY_METHOD_WITH_FAULTS = "operationWithHeaderAndHeaderFaultAndFault";
private static final String FAULT = "MyFault";
private static final String HEADERFAULT = "ConfigHeaderFault";
private static final String PARAMETER_RESULT_NAMING_METHOD = "stringOperation";
private static final String INPUT_PART_NAME = "ivalue0";
private static final String OUTPUT_PART_NAME = "rvalue";
private static final String THREE_INPUT_PART_METHOD = "oneTwoThree";
private static final String[] EXPECTED_OPERATION_NAMES = {
"arrayOperationFromClient", "getBean", "arrayOperation",
"stringOperation", "stringOperation2", "oneTwoThree",
"holderMethodDefault", "holderMethodInOut", "holderMethodOut",
"helloWorld", "helloWorld2", "oneWayOperation",
"operationWithHeaderAndHeaderFaultAndFault", "hello", "bye",
"methodWithNoReturn", "methodWithNoReturn2",
"operationThatThrowsAFault", };
private static final int[][] EXPECTED_PART_COUNTS = { { 1, 1, 0 }, // arrayOperationFromClient
{ 1, 1, 0 }, // getBean
{ 1, 1, 0 }, // arrayOperation
{ 1, 1, 0 }, // stringOperation
{ 1, 1, 0 }, // stringOperation2
{ 1, 1, 0 }, // oneTwoThree
{ 1, 1, 0 }, // holderMethodDefault
{ 1, 1, 0 }, // holderMethodInOut
{ 1, 1, 0 }, // holderMethodOut
{ 1, 1, 0 }, // helloWorld
{ 1, 1, 0 }, // helloWorld2
{ 1, 0, 0 }, // oneWayOperation
{ 2, 1, 2 }, // operationWithHeaderAndHeaderFaultAndFault
{ 1, 1, 0 }, // hello
{ 1, 1, 0 }, // bye
{ 1, 1, 0 }, // methodWithNoReturn
{ 1, 1, 0 }, // methodWithNoReturn2
{ 1, 1, 1 }, // operationThatThrowsAFault
};
private static final String[][] EXPECTED_TYPE_ELEMENT_MAPPINGS = {
{ "arrayOperationFromClient", "arrayOperationFromClientResponse", "", "",
"", "" }, // arrayOperationFromClient
{ "getBean", "getBeanResponse", "", "", "", "" }, // getBean
{ "arrayOperation", "arrayOperationResponse", "", "", "", "" }, // arrayOperation
{ "stringOperation", "stringOperationResponse", "", "", "", "" }, // stringOperation
{ "myStringOperation", "myStringOperationResponse", "", "", "", "" }, // stringOperation2
{ "oneTwoThree", "oneTwoThreeResponse", "", "", "", "" }, // oneTwoThree
{ "holderMethodDefault", "holderMethodDefaultResponse", "", "", "", "" }, // holderMethodDefault
{ "holderMethodInOut", "holderMethodInOutResponse", "", "", "", "" }, // holderMethodInOut
{ "holderMethodOut", "holderMethodOutResponse", "", "", "", "" }, // holderMethodOut
{ "helloWorld", "helloWorldResponse", "", "", "", "" }, // helloWorld
{ "helloWorld2", "helloWorld2Response", "", "", "", "" }, // helloWorld2
{ "oneWayOperation", "", "", "", "", "" }, // oneWayOperation
{ "operationWithHeaderAndHeaderFaultAndFault", "ConfigHeader",
"operationWithHeaderAndHeaderFaultAndFaultResponse",
"ConfigHeaderFault", "MyFault", "" }, // operationWithHeaderAndHeaderFaultAndFault
{ "hello", "helloResponse", "", "", "", "" }, // hello
{ "bye", "byeResponse", "", "", "", "" }, // bye
{ "methodWithNoReturn", "methodWithNoReturnResponse", "", "", "", "" }, // methodWithNoReturn
{ "methodWithNoReturn2", "methodWithNoReturn2Response", "", "", "", "" }, // methodWithNoReturn2
{ "operationThatThrowsAFault", "MyOtherFault",
"operationThatThrowsAFaultResponse", "", "", "" }, // operationThatThrowsAFault
};
// For verifying document/wrapped default naming
private static final String DEFAULT_DOCUMENT_WRAPPED_METHOD = "stringOperation";
private static final String DEFAULT_STRING_OPERATION_REQUEST = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.jaxws.StringOperation";
private static final String DEFAULT_STRING_OPERATION_RESPONSE = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.jaxws.StringOperationResponse";
// For verifying document/wrapped customized naming
private static final String CUSTOMIZED_DOCUMENT_WRAPPED_METHOD = "stringOperation2";
private static final String CUSTOMIZED_STRING_OPERATION_REQUEST = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.MyStringOperation";
private static final String CUSTOMIZED_STRING_OPERATION_RESPONSE = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.MyStringOperationResponse";
private static final String JAXB_ANNOTATIONS_TEST1 = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.jaxws.JaxbAnnotationsTest1";
private static final String JAXB_ANNOTATIONS_TEST2 = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.jaxws.JaxbAnnotationsTest2";
private static final String JAXB_ANNOTATIONS_TEST3 = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.jaxws.JaxbAnnotationsTest3";
private static final String JAXB_ANNOTATIONS_TEST4 = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.jaxws.JaxbAnnotationsTest4";
private static final String JAXB_ANNOTATIONS_FAULTBEAN = "com.sun.ts.tests.jaxws.mapping.j2wmapping.document.literal.wrapped.jaxws.MyFaultBean";
private boolean debug = false;
Hashtable ht = new Hashtable();
Hashtable ht2 = new Hashtable();
// private methods here
private boolean ProcessWsdlDocument(Document document) throws Fault {
boolean pass = true;
// Process wsdl <import> elements (imported wsdl's)
Document[] wsdlDocs = DescriptionUtils.getWsdlDocuments(document,
tshome + baseURL);
if (wsdlDocs != null) {
for (int i = 0; i < wsdlDocs.length; i++) {
TestUtil.logMsg("Process imported wsdl file: "
+ wsdlDocs[i].getDocumentElement().getAttribute("WsdlFile"));
wsdlDocs[i].getDocumentElement().removeAttribute("WsdlFile");
pass = ProcessWsdlDocument(wsdlDocs[i]);
}
}
// Process wsdl <types> element (If none then we are done)
Element types = DescriptionUtils.getTypes(document);
if (types == null)
return pass;
// Verify namespaceURI on wsdl <schema> elements if any
Element[] schemas = DescriptionUtils.getChildElements(types, null,
WSDL_SCHEMA_LOCAL_NAME);
TestUtil.logMsg("Verify namespaceURI on wsdl <schema> elements");
if (schemas != null) {
for (int i = 0; i < schemas.length; i++) {
String namespaceURI = schemas[i].getNamespaceURI();
Attr[] attributes = DescriptionUtils.getElementAttributes(schemas[i]);
for (int j = 0; j < attributes.length; j++) {
String aname = attributes[j].getName();
String avalue = attributes[j].getValue();
if (aname.startsWith("xmlns:")) {
String aprefix = aname.substring(6, aname.length());
ht.put(aprefix, avalue);
}
}
if (!namespaceURI.equals(XSD_NAMESPACE_URI)) {
TestUtil
.logErr("Encountered 'schema' element with invalid namespaceURI '"
+ namespaceURI);
pass = false;
}
}
}
// Verify schema element types defined in wsdl <types> element if any
NodeList list = types.getElementsByTagNameNS(XSD_NAMESPACE_URI,
XSD_ELEMENT_LOCAL_NAME);
TestUtil
.logMsg("Verify schema element types defined in wsdl <types> element");
if (list.getLength() != 0) {
if (!VerifyElementTypes(list))
pass = false;
}
// Process schema <import> elements (imported schema's)
Document[] schemaDocs = DescriptionUtils.getSchemaDocuments(document,
tshome + baseURL);
if (schemaDocs != null) {
for (int i = 0; i < schemaDocs.length; i++) {
TestUtil.logMsg("Process imported schema file: "
+ schemaDocs[i].getDocumentElement().getAttribute("SchemaFile"));
schemaDocs[i].getDocumentElement().removeAttribute("SchemaFile");
pass = ProcessSchemaDocument(schemaDocs[i]);
}
}
return pass;
}
private boolean ProcessSchemaDocument(Document document) throws Fault {
boolean pass = true;
// Process schema <import> elements (imported schema's)
Document[] schemaDocs = DescriptionUtils.getSchemaDocuments(document,
tshome + baseURL);
if (schemaDocs != null) {
for (int i = 0; i < schemaDocs.length; i++) {
TestUtil.logMsg("Process imported schema file: "
+ schemaDocs[i].getDocumentElement().getAttribute("SchemaFile"));
schemaDocs[i].getDocumentElement().removeAttribute("SchemaFile");
pass = ProcessSchemaDocument(schemaDocs[i]);
}
}
// Verify schema element types defined in imported schema if any
TestUtil.logMsg("Verify schema element types defined in imported schema");
ht2 = new Hashtable();
String[] s = DescriptionUtils.getAllPrefixAndNamespace(document);
for (int i = 0; i < s.length; i++) {
String prefix = s[i].substring(0, s[i].indexOf(":"));
String namespace = s[i].substring(s[i].indexOf(":") + 1, s[i].length());
ht2.put(prefix, namespace);
}
NodeList list = document.getDocumentElement()
.getElementsByTagNameNS(XSD_NAMESPACE_URI, XSD_ELEMENT_LOCAL_NAME);
if (!VerifyElementTypes(list))
pass = false;
return pass;
}
private boolean VerifyElementTypes(NodeList list) {
boolean pass = true;
for (int j = 0; j < list.getLength(); j++) {
boolean ok = false;
Element element = (Element) list.item(j);
String type = element.getAttribute(XSD_TYPE_ATTR);
String name = element.getAttribute(XSD_NAME_ATTR);
String prefix = element.getPrefix();
String uri = element.getNamespaceURI();
ht.put(prefix, uri);
if (type.contains(":")) {
prefix = type.substring(0, type.indexOf(":"));
Attr attributes[] = DescriptionUtils.getElementAttributes(element);
for (int k = 0; k < attributes.length; k++) {
String aname = attributes[k].getName();
String avalue = attributes[k].getValue();
if (aname.startsWith("xmlns:")) {
String aprefix = aname.substring(6, aname.length());
ht.put(aprefix, avalue);
if (prefix.equals(aprefix)) {
uri = avalue;
}
}
}
}
// Verify element type and prefix has associated (prefix,namespace) in
// hashtable
TestUtil.logMsg("Verify 'element' name=" + name + " type=" + type
+ " prefix=" + prefix);
// Check hashtable prefix's of current element
Enumeration e = ht.keys();
while (e.hasMoreElements()) {
String cprefix = (String) e.nextElement();
if (prefix.equals(cprefix)) {
ok = true;
break;
}
}
// Check hashtable prefix's of document root element
if (!ok) {
e = ht2.keys();
while (e.hasMoreElements()) {
String cprefix = (String) e.nextElement();
if (prefix.equals(cprefix)) {
ok = true;
break;
}
}
}
if (!ok) {
TestUtil.logErr(
"Encountered 'element' " + name + " with invalid prefix " + prefix);
pass = false;
}
}
return pass;
}
private boolean VerifyTypeElementMappings(Element[] iparts, Element[] oparts,
Element[] fparts, String opname) throws Fault {
boolean ok = true;
if (!PartCountsOk(iparts, oparts, fparts, opname))
ok = false;
if (!TypesElementsOk(iparts, oparts, fparts, opname))
ok = false;
return ok;
}
private boolean PartCountsOk(Element[] iparts, Element[] oparts,
Element[] fparts, String opname) {
boolean ok = true;
int index, icnt, ocnt, fcnt;
TestUtil.logMsg("Verify part counts for operation: " + opname);
index = GetIndex(opname);
if (index == -1) {
TestUtil.logErr("Unexpected operation name: " + opname);
ok = false;
} else {
icnt = EXPECTED_PART_COUNTS[index][0];
ocnt = EXPECTED_PART_COUNTS[index][1];
fcnt = EXPECTED_PART_COUNTS[index][2];
if ((iparts == null && icnt != 0)
|| (iparts != null && iparts.length != icnt)) {
TestUtil.logErr("Incorrect number of input parts");
ok = false;
}
if ((oparts == null && ocnt != 0)
|| (oparts != null && oparts.length != ocnt)) {
TestUtil.logErr("Incorrect number of output parts");
ok = false;
}
if ((fparts == null && fcnt != 0)
|| (fparts != null && fparts.length != fcnt)) {
TestUtil.logErr("Incorrect number of fault parts");
ok = false;
}
}
return ok;
}
private boolean TypesElementsOk(Element[] iparts, Element[] oparts,
Element[] fparts, String opname) {
boolean ok = true;
int index;
TestUtil.logMsg("Verify types for operation: " + opname);
index = GetIndex(opname);
if (index == -1) {
TestUtil.logErr("Unexpected operation name: " + opname);
ok = false;
} else {
ArrayList alist1 = new ArrayList();
ArrayList alist2 = new ArrayList();
String expectedtypes[] = null;
String types[] = null;
String str = null;
for (int i = 0; i < 6; i++) {
if (!EXPECTED_TYPE_ELEMENT_MAPPINGS[index][i].equals(""))
alist1.add(EXPECTED_TYPE_ELEMENT_MAPPINGS[index][i]);
}
if (alist1.size() > 0)
expectedtypes = (String[]) alist1.toArray(new String[alist1.size()]);
if (iparts != null) {
for (int i = 0; i < iparts.length; i++) {
str = iparts[i].getAttribute(XSD_ELEMENT_ATTR);
alist2.add(str.substring(str.indexOf(":") + 1));
}
}
if (oparts != null) {
for (int i = 0; i < oparts.length; i++) {
str = oparts[i].getAttribute(XSD_ELEMENT_ATTR);
alist2.add(str.substring(str.indexOf(":") + 1));
}
}
if (fparts != null) {
for (int i = 0; i < fparts.length; i++) {
str = fparts[i].getAttribute(XSD_ELEMENT_ATTR);
alist2.add(str.substring(str.indexOf(":") + 1));
}
}
if (alist2.size() > 0)
types = (String[]) alist2.toArray(new String[alist2.size()]);
if (!CompareTypesElementsOk(expectedtypes, types, opname))
ok = false;
}
return ok;
}
private int GetIndex(String opname) {
for (int i = 0; i < EXPECTED_OPERATION_NAMES.length; i++) {
if (opname.equals(EXPECTED_OPERATION_NAMES[i]))
return i;
}
return -1;
}
private boolean CompareTypesElementsOk(String[] expectedtypes, String[] types,
String opname) {
boolean ok = true;
boolean found = false;
if (expectedtypes == null && types == null) {
;
} else if (expectedtypes == null && types != null) {
TestUtil.logErr(
"Incorrect number of types: got " + types.length + ", expected null");
ok = false;
} else if (expectedtypes != null && types == null) {
TestUtil.logErr("Incorrect number of types: got null " + ", expected "
+ expectedtypes.length);
ok = false;
} else if (types != null && types.length != expectedtypes.length) {
TestUtil.logErr("Incorrect number of types: got " + types.length
+ ", expected " + expectedtypes.length);
ok = false;
} else {
if (types != null) {
for (int i = 0; i < types.length; i++) {
for (int j = 0; j < types.length; j++) {
if (types[i].equals(expectedtypes[j]))
found = true;
}
if (!found)
ok = false;
else
found = false;
}
StringBuffer got = new StringBuffer("[ ");
StringBuffer exp = new StringBuffer("[ ");
for (int i = 0; i < types.length; i++) {
got.append(types[i] + " ");
exp.append(expectedtypes[i] + " ");
}
got.append("]");
exp.append("]");
if (!ok)
TestUtil.logErr("Incorrect types: got " + got.toString()
+ ", expected " + exp.toString());
else
TestUtil.logMsg("Types are correct: " + got.toString());
}
}
return ok;
}
/*
* Test entry point.
*
*/
public static void main(String[] args) {
Client test = new Client();
Status status = test.run(args, System.out, System.err);
status.exit();
}
/*
* @class.testArgs: -ap jaxws-url-props.dat
*
* @class.setup_props: ts.home;
*/
public void setup(String[] args, Properties properties) throws Fault {
tshome = properties.getProperty(TSHOME);
try {
wsdlFile = JAXWS_Util.getURLFromProp(WSDLLOC_URL);
} catch (Exception e) {
throw new Fault("Failed getting wsdl prop", e);
}
baseURL = wsdlFile.substring(0, wsdlFile.lastIndexOf("/") + 1);
wsdlFileUrl = "file:" + tshome + wsdlFile;
TestUtil.logMsg("wsdlFileUrl=" + wsdlFileUrl);
client = new DescriptionClient();
client.setURL(wsdlFileUrl);
TestUtil.logMsg("setup ok");
}
public void cleanup() {
TestUtil.logMsg("cleanup");
}
/*
* @testName: VerifyTargetNamespaceWithAnnotation
*
* @assertion_ids: JAXWS:SPEC:3000; JAXWS:SPEC:3001; JAXWS:SPEC:3002;
* JAXWS:SPEC:3004; JAXWS:SPEC:3005; JAXWS:SPEC:3007; JAXWS:SPEC:3008;
* JAXWS:SPEC:3012; JAXWS:SPEC:3019; JAXWS:SPEC:3020; JAXWS:SPEC:3033;
* JAXWS:SPEC:3034; JAXWS:SPEC:3035;
*
* @test_Strategy: Verify that the targetNamespace in the generated WSDL
* matches the targetNamespace as specified in the jakarta.jws.WebService
* annotation. (Java to WSDL 1.1 Mapping). Conformance requirement done: -
* Package name mapping
*
*/
public void VerifyTargetNamespaceWithAnnotation() throws Fault {
TestUtil.logMsg("VerifyTargetNamespaceWithAnnotation");
boolean pass = true;
try {
String targetNamespace = DescriptionUtils
.getTargetNamespaceAttr(client.getDocument());
TestUtil
.logMsg("Verify that targetNamespace is correct in generated WSDL");
if (!targetNamespace.equals(EXPECTED_TARGETNAMESPACE)) {
TestUtil.logErr("TargetNamespace is incorrect, expected: "
+ EXPECTED_TARGETNAMESPACE + ", got: " + targetNamespace);
pass = false;
} else
TestUtil.logMsg("TargetNamespace is correct: " + targetNamespace);
} catch (Exception e) {
TestUtil.logErr("Caught exception:" + e.getMessage());
TestUtil.printStackTrace(e);
pass = false;
}
if (!pass)
throw new Fault("VerifyTargetNamespaceWithAnnotation failed");
else
TestUtil.logMsg("Verification passed");
}
/*
* @testName: VerifySOAPElementNamespaceUseAttributeWithAnnotation
*
* @assertion_ids: JAXWS:SPEC:3000; JAXWS:SPEC:3001; JAXWS:SPEC:3002;
* JAXWS:SPEC:3004; JAXWS:SPEC:3005; JAXWS:SPEC:3007; JAXWS:SPEC:3008;
* JAXWS:SPEC:3012; JAXWS:SPEC:3019; JAXWS:SPEC:3020; JAXWS:SPEC:3033;
* JAXWS:SPEC:3034; JAXWS:SPEC:3035;
*
* @test_Strategy: Verify the namespace and use attributes for all SOAP
* Elements in the generated WSDL (Java to WSDL 1.1 Mapping and BP1.1).
* Conformance requirement done: - verify use attribute of literal for all
* SOAP elements - verify no namespace attribute on all soap:body elements
*
*
*/
public void VerifySOAPElementNamespaceUseAttributeWithAnnotation()
throws Fault {
TestUtil.logMsg("VerifySOAPElementNamespaceUseAttributeWithAnnotation");
boolean pass = true;
Document document = client.getDocument();
TestUtil.logMsg(
"Verify that no namespace and use attribute does exist on soap:body elements");
NamespaceAttributeVerifier verifier = new NamespaceAttributeVerifier(
document, 2716);
verifier.verify();
if (!pass)
throw new Fault(
"VerifySOAPElementNamespaceUseAttributeWithAnnotation failed");
else
TestUtil.logMsg("Verification passed");
}
/*
* @testName: VerifySOAPBindingTransportStyleAttributeWithAnnotation
*
* @assertion_ids: JAXWS:SPEC:3000; JAXWS:SPEC:3001; JAXWS:SPEC:3002;
* JAXWS:SPEC:3004; JAXWS:SPEC:3005; JAXWS:SPEC:3007; JAXWS:SPEC:3008;
* JAXWS:SPEC:3012; JAXWS:SPEC:3019; JAXWS:SPEC:3020; JAXWS:SPEC:3033;
* JAXWS:SPEC:3034; JAXWS:SPEC:3035;
*
* @test_Strategy: Verify the soap:binding transport and style attributes in
* the generated WSDL. (Java to WSDL 1.1 Mapping and BP1.1). Conformance
* requirement done: - SOAP binding support - SOAP binding style required -
* SOAP binding transport required
*
*
*/
public void VerifySOAPBindingTransportStyleAttributeWithAnnotation()
throws Fault {
TestUtil.logMsg("VerifySOAPBindingTransportStyleAttributeWithAnnotation");
boolean pass = true;
Document document = client.getDocument();
TestUtil.logMsg("Verify soap:binding transport and style attribute");
Element[] bindings = DescriptionUtils.getBindings(document);
for (int i = 0; i < bindings.length; i++) {
if (debug)
DescriptionUtils.dumpDOMNodes(bindings[i]);
Element soapBinding = DescriptionUtils.getChildElement(bindings[i],
SOAP_NAMESPACE_URI, SOAP_BINDING_LOCAL_NAME);
if (soapBinding == null) {
TestUtil.logErr("soap:binding is null unexpected");
pass = false;
} else {
String style = soapBinding.getAttribute(SOAP_STYLE_ATTR);
if (!style.equals(SOAP_DOCUMENT)) {
TestUtil.logErr("soap:binding style attribute incorrect, expected: "
+ SOAP_DOCUMENT + ", got: " + style);
pass = false;
} else
TestUtil.logMsg("soap:binding style attribute is correct: " + style);
String transport = soapBinding.getAttribute(SOAP_TRANSPORT_ATTR);
if (!transport.equals(SOAP_TRANSPORT)) {
TestUtil
.logErr("soap:binding transport attribute incorrect, expected: "
+ SOAP_TRANSPORT + ", got: " + transport);
pass = false;
} else
TestUtil.logMsg(
"soap:binding transport attribute is correct: " + transport);
}
}
if (!pass)
throw new Fault(
"VerifySOAPBindingTransportStyleAttributeWithAnnotation failed");
else
TestUtil.logMsg("Verification passed");
}
/*
* @testName: VerifyPortTypeNameWithAnnotation
*
* @assertion_ids: JAXWS:SPEC:3000; JAXWS:SPEC:3001; JAXWS:SPEC:3002;
* JAXWS:SPEC:3004; JAXWS:SPEC:3005; JAXWS:SPEC:3007; JAXWS:SPEC:3008;
* JAXWS:SPEC:3012; JAXWS:SPEC:3019; JAXWS:SPEC:3020; JAXWS:SPEC:3033;
* JAXWS:SPEC:3034; JAXWS:SPEC:3035;
*
* @test_Strategy: Verify the wsdl:portType name is correct in the generated
* WSDL. Conformance requirement done: - portType naming
*
*
*/
public void VerifyPortTypeNameWithAnnotation() throws Fault {
TestUtil.logMsg("VerifyPortTypeNameWithAnnotation");
boolean pass = true;
TestUtil.logMsg("Checking for portType name verification of: "
+ EXPECTED_PORTTYPE_NAME);
pass = DescriptionUtils.isPortTypeNameAttr(client.getDocument(),
EXPECTED_PORTTYPE_NAME);
if (!pass)
throw new Fault("VerifyPortTypeNameWithAnnotation failed");
else
TestUtil.logMsg("Verification passed");
}
/*
* @testName: VerifyServiceNameWithAnnotation
*
* @assertion_ids: JAXWS:SPEC:3037;
*
* @test_Strategy: Verify the wsdl:service element name is correct in the
* generated WSDL. Conformance requirement done: - service naming
*
*/
public void VerifyServiceNameWithAnnotation() throws Fault {
TestUtil.logMsg("VerifyServiceNameWithAnnotation");
boolean pass = true;
TestUtil.logMsg(
"Checking for service name verification of: " + EXPECTED_SERVICE_NAME);
pass = DescriptionUtils.isServiceNameAttr(client.getDocument(),
EXPECTED_SERVICE_NAME);
if (!pass)
throw new Fault("VerifyServiceNameWithAnnotation failed");
else
TestUtil.logMsg("Verification passed");
}
/*
* @testName: VerifyPortNameWithAnnotation
*
* @assertion_ids: JAXWS:SPEC:3000; JAXWS:SPEC:3001; JAXWS:SPEC:3002;
* JAXWS:SPEC:3004; JAXWS:SPEC:3005; JAXWS:SPEC:3007; JAXWS:SPEC:3008;
* JAXWS:SPEC:3012; JAXWS:SPEC:3019; JAXWS:SPEC:3020; JAXWS:SPEC:3033;
* JAXWS:SPEC:3034; JAXWS:SPEC:3035;
*
* @test_Strategy: Verify the wsdl:port name is correct in the generated WSDL.
* Conformance requirement done: - port naming
*
*
*/
public void VerifyPortNameWithAnnotation() throws Fault {
TestUtil.logMsg("VerifyPortNameWithAnnotation");
boolean pass = true;
TestUtil.logMsg(
"Checking for port name verification of: " + EXPECTED_PORT_NAME);
pass = DescriptionUtils.isPortNameAttr(client.getDocument(),
EXPECTED_PORT_NAME);
if (!pass)
throw new Fault("VerifyPortNameWithAnnotation failed");
else
TestUtil.logMsg("Verification passed");
}
/*
* @testName: VerifyOperationNames
*
* @assertion_ids: JAXWS:SPEC:3000; JAXWS:SPEC:3001; JAXWS:SPEC:3002;
* JAXWS:SPEC:3004; JAXWS:SPEC:3005; JAXWS:SPEC:3007; JAXWS:SPEC:3008;
* JAXWS:SPEC:3010; JAXWS:SPEC:3012; JAXWS:SPEC:3019; JAXWS:SPEC:3020;
* JAXWS:SPEC:3033; JAXWS:SPEC:3034; JAXWS:SPEC:3035; JAXWS:SPEC:3003;
* JAXWS:SPEC:7004; JAXWS:SPEC:7005;
*
* @test_Strategy: Verify wsdl:portType operation names are correct in the
* generated WSDL. Verify all public method mapping to wsdl:operation
* elements. Conformance requirement done: - Inheritance flattening -
* Operation naming - Method name disambiguation
*
*
*/
public void VerifyOperationNames() throws Fault {
TestUtil.logMsg("VerifyOperationNames");
boolean pass = true;
TestUtil.logMsg(
"Checking for operation names for portType: " + EXPECTED_PORTTYPE_NAME);
String opNames[] = DescriptionUtils.getPortTypeOperationNames(
client.getDocument(), EXPECTED_PORTTYPE_NAME);
if (opNames.length == EXPECTED_OPERATION_NAMES.length)
TestUtil.logMsg("operation name count is as expected: "
+ EXPECTED_OPERATION_NAMES.length);
else {
pass = false;
TestUtil.logErr("operation count expected: "
+ EXPECTED_OPERATION_NAMES.length + ", received: " + opNames.length);
}
int cnt = 0;
for (int i = 0; i < opNames.length; i++) {
boolean found = false;
for (int j = 0; j < EXPECTED_OPERATION_NAMES.length; j++) {
if (opNames[i].equals(EXPECTED_OPERATION_NAMES[j])) {
found = true;
cnt++;
TestUtil.logMsg("Matched operation name ... " + opNames[i]);
break;
}
}
if (!found) {
TestUtil.logErr("UnMatched operation name: " + opNames[i]);
pass = false;
}
}
if (cnt == EXPECTED_OPERATION_NAMES.length)
TestUtil.logMsg("All operation names matched expected ...");
if (!pass)
throw new Fault("VerifyOperationNames failed");
else
TestUtil.logMsg("Verification passed");
}
/*
* @testName: VerifyOneWayAndTwoWayOperations
*
* @assertion_ids: JAXWS:SPEC:3000; JAXWS:SPEC:3001; JAXWS:SPEC:3002;
* JAXWS:SPEC:3004; JAXWS:SPEC:3005; JAXWS:SPEC:3007; JAXWS:SPEC:3008;
* JAXWS:SPEC:3011; JAXWS:SPEC:3012; JAXWS:SPEC:3019; JAXWS:SPEC:3020;
* JAXWS:SPEC:3033; JAXWS:SPEC:3034; JAXWS:SPEC:3035; JAXWS:SPEC:3014;
*
* @test_Strategy: Verify operations are correctly identifed as OneWay or
* TwoWay. Conformance requirement done: - One-way mapping - Two-way mapping -
* Two-way mapping with faults - Method and parameters where expected in both
* wsdl:portType and wsdl:binding
*
*
*/
public void VerifyOneWayAndTwoWayOperations() throws Fault {
TestUtil.logMsg("VerifyOneWayAndTwoWayOperations");
boolean pass = true;
TestUtil.logMsg(
"Checking for operation names for portType: " + EXPECTED_PORTTYPE_NAME);
Element operations[] = DescriptionUtils.getPortTypeOperationNameElements(
client.getDocument(), EXPECTED_PORTTYPE_NAME);
for (int i = 0; i < operations.length; i++) {
String name = operations[i].getAttribute(WSDL_NAME_ATTR);
Element e = DescriptionUtils
.getBindingOperationNameElement(client.getDocument(), name);
if (name.equals(ONEWAY_METHOD)) {
TestUtil
.logMsg("Checking for one way operation for operation: " + name);
TestUtil.logMsg("verify in portType operation ...");
if (DescriptionUtils.isOneWay(operations[i]))
TestUtil.logMsg("is One way");
else {
TestUtil.logErr("is not One way");
pass = false;
}
TestUtil.logMsg("verify in binding operation ...");
if (DescriptionUtils.isOneWay(e))
TestUtil.logMsg("is One way");
else {
TestUtil.logErr("is not One way");
pass = false;
}
} else {
TestUtil
.logMsg("Checking for two way operation for operation: " + name);
TestUtil.logMsg("verify in portType operation ...");
if (DescriptionUtils.isTwoWay(operations[i]))
TestUtil.logMsg("is Two way");
else {
TestUtil.logErr("is not Two way");
pass = false;
}
TestUtil.logMsg("verify in binding operation ...");
if (DescriptionUtils.isTwoWay(e))
TestUtil.logMsg("is Two way");
else {
TestUtil.logErr("is not Two way");
pass = false;
}
if (name.equals(TWOWAY_METHOD_WITH_FAULTS)) {
TestUtil.logMsg("Checking for faults for operation: " + name);
TestUtil.logMsg("Expected faults are: " + FAULT + "," + HEADERFAULT);
TestUtil.logMsg("verify in portType operation ...");
if (DescriptionUtils.hasFault(operations[i], FAULT)
&& DescriptionUtils.hasFault(operations[i], HEADERFAULT))
TestUtil.logMsg("fault match");
else {
TestUtil.logErr("fault mismatch, did not get expected faults: "
+ FAULT + "," + HEADERFAULT);
pass = false;
}
TestUtil.logMsg("verify in binding operation ...");
if (DescriptionUtils.hasFault(e, FAULT)
&& DescriptionUtils.hasFault(e, HEADERFAULT))
TestUtil.logMsg("fault match");
else {
TestUtil.logErr("fault mismatch, did not get expected faults: "
+ FAULT + "," + HEADERFAULT);
pass = false;
}
}
}
}
if (!pass)
throw new Fault("VerifyOneWayAndTwoWayOperations failed");
else
TestUtil.logMsg("Verification passed");
}
/*
* @testName: VerifyParameterAndResultNaming
*
* @assertion_ids: JAXWS:SPEC:3000; JAXWS:SPEC:3001; JAXWS:SPEC:3002;
* JAXWS:SPEC:3004; JAXWS:SPEC:3005; JAXWS:SPEC:3007; JAXWS:SPEC:3008;
* JAXWS:SPEC:3012; JAXWS:SPEC:3019; JAXWS:SPEC:3020; JAXWS:SPEC:3033;
* JAXWS:SPEC:3034; JAXWS:SPEC:3035; JAXWS:SPEC:3017; JAXWS:SPEC:3018;
*
* @test_Strategy: Verify use of annotations to name parameters and results.
* Conformance requirement done: - Parameter naming - Result naming
*
*
*/
public void VerifyParameterAndResultNaming() throws Fault {
TestUtil.logMsg("VerifyParameterAndResultNaming");
boolean pass = true;
Document document = client.getDocument();
TestUtil
.logMsg("Checking for operation name " + PARAMETER_RESULT_NAMING_METHOD
+ " in portType " + EXPECTED_PORTTYPE_NAME);
Element operation = DescriptionUtils.getPortTypeOperationNameElement(
document, EXPECTED_PORTTYPE_NAME, PARAMETER_RESULT_NAMING_METHOD);
Element input = DescriptionUtils.getChildElement(operation,
WSDL_NAMESPACE_URI, WSDL_INPUT_LOCAL_NAME);
Element output = DescriptionUtils.getChildElement(operation,
WSDL_NAMESPACE_URI, WSDL_OUTPUT_LOCAL_NAME);
String imsg = input.getAttribute(WSDL_MESSAGE_ATTR);
String omsg = output.getAttribute(WSDL_MESSAGE_ATTR);
int iidx = imsg.indexOf(":");
int oidx = omsg.indexOf(":");
String imessage, omessage;
if (iidx != -1) {
imessage = imsg.substring(iidx + 1);
omessage = omsg.substring(oidx + 1);
} else {
imessage = imsg;
omessage = omsg;
}
TestUtil.logMsg("input message name is " + imessage);
TestUtil.logMsg("output message name is " + omessage);
Element ipart = DescriptionUtils.getPartElement(document, imessage);
String ielement = ipart.getAttribute(WSDL_ELEMENT_ATTR);
String ielementName = ielement;
if (ielementName.indexOf(":") >= 0) {
ielementName = ielementName.substring(ielementName.indexOf(":") + 1,
ielementName.length());
}
String iprefix = ielement.substring(0, ielement.indexOf(":"));
Element opart = DescriptionUtils.getPartElement(document, omessage);
String oelement = opart.getAttribute(WSDL_ELEMENT_ATTR);
String oelementName = oelement;
if (oelementName.indexOf(":") >= 0) {
oelementName = oelementName.substring(oelementName.indexOf(":") + 1,
oelementName.length());
}
String oprefix = oelement.substring(0, oelement.indexOf(":"));
TestUtil.logMsg("input prefix " + iprefix);
TestUtil.logMsg("output prefix " + oprefix);
Document schemaDoc = null;
NodeList list = null;
// Search first types section of WSDL to see if element declared there
// else look in schema imports as below.
Element element = DescriptionUtils.getSchemaElementName(document,
ielementName);
String type = null;
Element complexType = null;
if (element != null) {
type = element.getAttribute(WSDL_TYPE_ATTR);
if (type.indexOf(":") != -1)
type = type.substring(type.indexOf(":") + 1, type.length());
complexType = DescriptionUtils.getSchemaComplexTypeName(document, type);
if (complexType != null)
list = complexType.getElementsByTagNameNS(XSD_NAMESPACE_URI,
XSD_ELEMENT_LOCAL_NAME);
} else {
element = DescriptionUtils.getSchemaElementName(document, ielementName);
if (element != null) {
type = element.getAttribute(WSDL_TYPE_ATTR);
if (type.indexOf(":") != -1)
type = type.substring(type.indexOf(":") + 1, type.length());
complexType = DescriptionUtils.getSchemaComplexTypeName(document, type);
if (complexType != null)
list = complexType.getElementsByTagNameNS(XSD_NAMESPACE_URI,
XSD_ELEMENT_LOCAL_NAME);
} else
type = ielementName;
// Find complex type of imessage in schema and element name matches
schemaDoc = DescriptionUtils.getSchemaDocument(document, iprefix,
tshome + baseURL);
if (schemaDoc != null) {
complexType = DescriptionUtils.getNamedChildElement(
schemaDoc.getDocumentElement(), XSD_NAMESPACE_URI,
XSD_COMPLEXTYPE_LOCAL_NAME, type);
if (complexType != null)
list = complexType.getElementsByTagNameNS(XSD_NAMESPACE_URI,
XSD_ELEMENT_LOCAL_NAME);
}
}
String ipartName = null;
if (list != null) {
if (list.getLength() == 1) {
Element e = (Element) list.item(0);
ipartName = e.getAttribute(XSD_NAME_ATTR);
}
}
TestUtil.logMsg("ipartName=" + ipartName);