001: /*
002: * WSDLSemanticValidatorTest.java
003: * JUnit based test
004: *
005: * Created on January 29, 2007, 10:47 AM
006: */
007:
008: package org.netbeans.modules.xml.wsdl.validator;
009:
010: import java.net.URI;
011: import java.net.URL;
012: import java.text.MessageFormat;
013: import java.util.HashSet;
014: import java.util.Iterator;
015: import java.util.ResourceBundle;
016: import java.util.Set;
017: import junit.framework.*;
018: import org.netbeans.modules.xml.wsdl.model.TestCatalogModel;
019: import org.netbeans.modules.xml.wsdl.model.WSDLModel;
020: import org.netbeans.modules.xml.wsdl.validator.visitor.WSDLSemanticsVisitor;
021: import org.netbeans.modules.xml.xam.spi.Validation;
022: import org.netbeans.modules.xml.xam.spi.ValidationResult;
023: import org.netbeans.modules.xml.xam.spi.Validation.ValidationType;
024: import org.netbeans.modules.xml.xam.spi.Validator.ResultItem;
025:
026: /**
027: *
028: * @author radval
029: */
030: public class WSDLSemanticValidatorTest extends TestCase {
031:
032: private static final ResourceBundle mMessages = ResourceBundle
033: .getBundle(WSDLSemanticsVisitor.class.getPackage()
034: .getName()
035: + ".Bundle");
036:
037: public WSDLSemanticValidatorTest(String testName) {
038: super (testName);
039: }
040:
041: protected void setUp() throws Exception {
042: }
043:
044: protected void tearDown() throws Exception {
045: }
046:
047: /**
048: * Test of getName method, of class org.netbeans.modules.xml.wsdl.validator.WSDLSemanticValidator.
049: */
050: public void testGetName() {
051: System.out.println("getName");
052:
053: WSDLSemanticValidator instance = new WSDLSemanticValidator();
054:
055: String expResult = "WSDLSemanticValidator";
056: String result = instance.getName();
057: assertEquals(expResult, result);
058:
059: }
060:
061: /**
062: * Test of validate method, of class org.netbeans.modules.xml.wsdl.validator.WSDLSemanticValidator.
063: */
064: public void testValidate() throws Exception {
065: System.out.println("validate");
066:
067: String fileName = "/org/netbeans/modules/xml/wsdl/validator/visitor/resources/valid/AsynchronousSample.wsdl";
068: URL url = getClass().getResource(fileName);
069: URI uri = url.toURI();
070:
071: Set<String> expectedErrors = new HashSet<String>();
072: validate(uri, expectedErrors);
073: }
074:
075: public void testValidateDefinitionShouldHaveTargetNamespaceWarning()
076: throws Exception {
077: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/definitionsTests/definitionsNoTargetN_invalid.wsdl";
078: URL url = getClass().getResource(fileName);
079: URI uri = url.toURI();
080:
081: HashSet<String> expectedErrors = new HashSet<String>();
082: expectedErrors
083: .add(format(mMessages
084: .getString("VAL_ERROR_WSDL_DEFINITIONS_NO_TARGETNAMESPACE")));
085: validate(uri, expectedErrors);
086: }
087:
088: public void testValidateDefinitionMissingTargetNamespaceWarning()
089: throws Exception {
090: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/definitionsTests/definitionsNoTargetN_valid_warning.wsdl";
091: URL url = getClass().getResource(fileName);
092: URI uri = url.toURI();
093:
094: HashSet<String> expectedErrors = new HashSet<String>();
095: expectedErrors
096: .add(format(mMessages
097: .getString("VAL_ERROR_WSDL_DEFINITIONS_NO_TARGETNAMESPACE")));
098: validate(uri, expectedErrors);
099: }
100:
101: public void testValidateImportBogusLocation() throws Exception {
102: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLTests/importBogusLocation_error.wsdl";
103: URL url = getClass().getResource(fileName);
104: URI uri = url.toURI();
105:
106: HashSet<String> expectedErrors = new HashSet<String>();
107: expectedErrors.add(format(mMessages
108: .getString("VAL_MISSING_IMPORTED_DOCUMENT")));
109: validate(uri, expectedErrors);
110: }
111:
112: public void testValidateImportNoLocation() throws Exception {
113: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLTests/importNoLocation_error.wsdl";
114: URL url = getClass().getResource(fileName);
115: URI uri = url.toURI();
116:
117: HashSet<String> expectedErrors = new HashSet<String>();
118: expectedErrors.add(format(mMessages
119: .getString("VAL_MISSING_IMPORTED_DOCUMENT")));
120: validate(uri, expectedErrors);
121: }
122:
123: public void testValidateImportNoNamespace() throws Exception {
124: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLTests/importNoNamespace_error.wsdl";
125: URL url = getClass().getResource(fileName);
126: URI uri = url.toURI();
127:
128: HashSet<String> expectedErrors = new HashSet<String>();
129: expectedErrors.add(format(mMessages
130: .getString("VAL_MISSING_IMPORTED_DOCUMENT")));
131: validate(uri, expectedErrors);
132: }
133:
134: public void testValidatePortTypeOperationDuplicateInputName()
135: throws Exception {
136: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/ptMultiOpsDupInput_error.wsdl";
137: URL url = getClass().getResource(fileName);
138: URI uri = url.toURI();
139:
140: HashSet<String> expectedErrors = new HashSet<String>();
141: expectedErrors
142: .add(format(mMessages
143: .getString("VAL_DUPLICATE_OPRATION_INPUT_NAME_IN_PORTTYPE")));
144: validate(uri, expectedErrors);
145:
146: }
147:
148: public void testValidatePortTypeOperationInputInvalidMessage()
149: throws Exception {
150: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/reqrep/inputBogusMsg_error.wsdl";
151: URL url = getClass().getResource(fileName);
152: URI uri = url.toURI();
153:
154: HashSet<String> expectedErrors = new HashSet<String>();
155: expectedErrors
156: .add(format(mMessages
157: .getString("VAL_MESSAGE_NOT_FOUND_IN_OPERATION_INPUT")));
158: validate(uri, expectedErrors);
159:
160: }
161:
162: public void testValidatePortTypeOperationDuplicateOutputName()
163: throws Exception {
164: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/ptMultiOpsDupOutput_error.wsdl";
165: URL url = getClass().getResource(fileName);
166: URI uri = url.toURI();
167:
168: HashSet<String> expectedErrors = new HashSet<String>();
169: expectedErrors
170: .add(format(mMessages
171: .getString("VAL_DUPLICATE_OPRATION_OUTPUT_NAME_IN_PORTTYPE")));
172: validate(uri, expectedErrors);
173:
174: }
175:
176: public void testValidatePortTypeOperationOutputInvalidMessage()
177: throws Exception {
178: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/reqrep/outputBogusMsg_error.wsdl";
179: URL url = getClass().getResource(fileName);
180: URI uri = url.toURI();
181:
182: HashSet<String> expectedErrors = new HashSet<String>();
183: expectedErrors
184: .add(format(mMessages
185: .getString("VAL_MESSAGE_NOT_FOUND_IN_OPERATION_OUTPUT")));
186: validate(uri, expectedErrors);
187:
188: }
189:
190: public void testValidateRequestResponseOperationDuplicateFaultName()
191: throws Exception {
192: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/ptMultiOpsDupFaultSameOps_error.wsdl";
193: URL url = getClass().getResource(fileName);
194: URI uri = url.toURI();
195:
196: HashSet<String> expectedErrors = new HashSet<String>();
197: expectedErrors.add(format(mMessages
198: .getString("VAL_DUPLICATE_OPRATION_FAULT_NAME")));
199: validate(uri, expectedErrors);
200: }
201:
202: public void testValidateRequestResponseOperationFaultInvalidMessage()
203: throws Exception {
204: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/reqrep/faultBogusMsg_error.wsdl";
205: URL url = getClass().getResource(fileName);
206: URI uri = url.toURI();
207:
208: HashSet<String> expectedErrors = new HashSet<String>();
209: expectedErrors
210: .add(format(mMessages
211: .getString("VAL_MESSAGE_NOT_FOUND_IN_OPERATION_FAULT")));
212: validate(uri, expectedErrors);
213: }
214:
215: public void testValidateSolicitResponseOperationDuplicateFaultName()
216: throws Exception {
217: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/solrep/multiOpsDupFaultSameOps_error.wsdl";
218: URL url = getClass().getResource(fileName);
219: URI uri = url.toURI();
220:
221: HashSet<String> expectedErrors = new HashSet<String>();
222: expectedErrors.add(format(mMessages
223: .getString("VAL_DUPLICATE_OPRATION_FAULT_NAME")));
224: validate(uri, expectedErrors);
225: }
226:
227: public void testValidateSolicitResponseOperationFaultInvalidMessage()
228: throws Exception {
229: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/solrep/faultBogusMsg_error.wsdl";
230: URL url = getClass().getResource(fileName);
231: URI uri = url.toURI();
232:
233: HashSet<String> expectedErrors = new HashSet<String>();
234: expectedErrors
235: .add(format(mMessages
236: .getString("VAL_MESSAGE_NOT_FOUND_IN_OPERATION_FAULT")));
237: validate(uri, expectedErrors);
238: }
239:
240: public void testValidateOnewayOperationFaultShouldNotBeDefined()
241: throws Exception {
242: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/oneway/faultDefined_error.wsdl";
243: URL url = getClass().getResource(fileName);
244: URI uri = url.toURI();
245:
246: HashSet<String> expectedErrors = new HashSet<String>();
247: expectedErrors.add(format(mMessages
248: .getString("VAL_FAULT_NOT_ALLOWED_IN_OPERATION")));
249: validate(uri, expectedErrors);
250: }
251:
252: public void testValidateNotificationOperationFaultShouldNotBeDefined()
253: throws Exception {
254: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/notify/faultDefined_error.wsdl";
255: URL url = getClass().getResource(fileName);
256: URI uri = url.toURI();
257:
258: HashSet<String> expectedErrors = new HashSet<String>();
259: expectedErrors.add(format(mMessages
260: .getString("VAL_FAULT_NOT_ALLOWED_IN_OPERATION")));
261: validate(uri, expectedErrors);
262: }
263:
264: public void testValidateMessageNoPartWarning() throws Exception {
265: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messageNoParts.wsdl";
266: URL url = getClass().getResource(fileName);
267: URI uri = url.toURI();
268:
269: HashSet<String> expectedErrors = new HashSet<String>();
270: expectedErrors
271: .add(format(mMessages
272: .getString("VAL_WARNING_WSDL_MESSAGE_DOES_NOT_HAVE_ANY_PARTS_DEFINED")));
273: validate(uri, expectedErrors);
274: }
275:
276: public void testValidatePartNoElementOrTypeAttribute()
277: throws Exception {
278: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartNoTypeOrElement_error.wsdl";
279: URL url = getClass().getResource(fileName);
280: URI uri = url.toURI();
281:
282: HashSet<String> expectedErrors = new HashSet<String>();
283: expectedErrors
284: .add(format(mMessages
285: .getString("VAL_NO_ELEMENT_OR_TYPE_ATTRIBUTE_DEFINED_IN_MESSAGE_PART")));
286: validate(uri, expectedErrors);
287: }
288:
289: public void testValidatePartInvalidElementAttribute()
290: throws Exception {
291: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartBadElement_error.wsdl";
292: URL url = getClass().getResource(fileName);
293: URI uri = url.toURI();
294:
295: HashSet<String> expectedErrors = new HashSet<String>();
296: expectedErrors
297: .add(format(mMessages
298: .getString("VAL_ELEMENT_ATTRIBUTE_DEFINED_IN_MESSAGE_PART_IS_NOT_VALID")));
299: validate(uri, expectedErrors);
300: }
301:
302: public void testValidatePartInvalidTypeAttribute() throws Exception {
303: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartBadType_error.wsdl";
304: URL url = getClass().getResource(fileName);
305: URI uri = url.toURI();
306:
307: HashSet<String> expectedErrors = new HashSet<String>();
308: expectedErrors
309: .add(format(mMessages
310: .getString("VAL_TYPE_ATTRIBUTE_DEFINED_IN_MESSAGE_PART_IS_NOT_VALID")));
311: validate(uri, expectedErrors);
312: }
313:
314: public void testValidatePartBothTypeAndAttributeError()
315: throws Exception {
316: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartElementAndType_error.wsdl";
317: URL url = getClass().getResource(fileName);
318: URI uri = url.toURI();
319:
320: HashSet<String> expectedErrors = new HashSet<String>();
321: expectedErrors
322: .add(format(mMessages
323: .getString("VAL_BOTH_ELEMENT_OR_TYPE_ATTRIBUTE_DEFINED_IN_MESSAGE_PART")));
324: validate(uri, expectedErrors);
325: }
326:
327: public void testValidateImport() throws Exception {
328: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLTests/importBogusLocation_error.wsdl";
329: URL url = getClass().getResource(fileName);
330: URI uri = url.toURI();
331:
332: HashSet<String> expectedErrors = new HashSet<String>();
333: expectedErrors.add(format(mMessages
334: .getString("VAL_MISSING_IMPORTED_DOCUMENT")));
335: validate(uri, expectedErrors);
336: }
337:
338: public void testValidateBindingInvalidType() throws Exception {
339: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/bindingRRFBogusType_error.wsdl";
340: URL url = getClass().getResource(fileName);
341: URI uri = url.toURI();
342:
343: HashSet<String> expectedErrors = new HashSet<String>();
344: expectedErrors.add(format(mMessages
345: .getString("VAL_MISSING_PORTTYPE_IN_BINDING")));
346: validate(uri, expectedErrors);
347: }
348:
349: public void testValidateBindingOperationOverloadedValid()
350: throws Exception {
351: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpName_valid.wsdl";
352: URL url = getClass().getResource(fileName);
353: URI uri = url.toURI();
354:
355: HashSet<String> expectedErrors = new HashSet<String>();
356: validate(uri, expectedErrors);
357: }
358:
359: public void testValidateBindingOperationOverloadedNoMatchingOperationError()
360: throws Exception {
361: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch_error.wsdl";
362: URL url = getClass().getResource(fileName);
363: URI uri = url.toURI();
364:
365: HashSet<String> expectedErrors = new HashSet<String>();
366: expectedErrors
367: .add(format(mMessages
368: .getString("VAL_OPERATION_DOES_NOT_MATCH_INPUT_NAME_IN_PORT_TYPE")));
369: expectedErrors
370: .add(format(mMessages
371: .getString("VAL_OPERATION_DOES_NOT_MATCH_OUTPUT_NAME_IN_PORT_TYPE")));
372: expectedErrors
373: .add(format(mMessages
374: .getString("VAL_OPERATION_DOES_NOT_MATCH_FAULTS_IN_PORT_TYPE")));
375:
376: validate(uri, expectedErrors);
377: }
378:
379: public void testValidateBindingOperationOverloadedNoMatchingOperationInputOutputFaultError1()
380: throws Exception {
381: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch_error.wsdl";
382: URL url = getClass().getResource(fileName);
383: URI uri = url.toURI();
384:
385: HashSet<String> expectedErrors = new HashSet<String>();
386: expectedErrors
387: .add(format(mMessages
388: .getString("VAL_OPERATION_DOES_NOT_MATCH_INPUT_NAME_IN_PORT_TYPE")));
389: expectedErrors
390: .add(format(mMessages
391: .getString("VAL_OPERATION_DOES_NOT_MATCH_OUTPUT_NAME_IN_PORT_TYPE")));
392: expectedErrors
393: .add(format(mMessages
394: .getString("VAL_OPERATION_DOES_NOT_MATCH_FAULTS_IN_PORT_TYPE")));
395:
396: validate(uri, expectedErrors);
397: }
398:
399: public void testValidateBindingOperationOverloadedNoMatchingOperationInputOutputFaultError2()
400: throws Exception {
401: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch2_error.wsdl";
402: URL url = getClass().getResource(fileName);
403: URI uri = url.toURI();
404:
405: HashSet<String> expectedErrors = new HashSet<String>();
406: expectedErrors
407: .add(format(mMessages
408: .getString("VAL_OPERATION_DOES_NOT_MATCH_INPUT_NAME_IN_PORT_TYPE")));
409: expectedErrors
410: .add(format(mMessages
411: .getString("VAL_OPERATION_DOES_NOT_MATCH_OUTPUT_NAME_IN_PORT_TYPE")));
412: expectedErrors
413: .add(format(mMessages
414: .getString("VAL_OPERATION_DOES_NOT_MATCH_FAULTS_IN_PORT_TYPE")));
415:
416: validate(uri, expectedErrors);
417: }
418:
419: public void testValidateBindingOperationSignatureSameAsPortTypeOperationValid()
420: throws Exception {
421: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingOperationSignatureSameAsPortTypeOperation_valid.wsdl";
422: URL url = getClass().getResource(fileName);
423: URI uri = url.toURI();
424:
425: HashSet<String> expectedErrors = new HashSet<String>();
426: validate(uri, expectedErrors);
427: }
428:
429: public void testServicePortInvalidBinding() throws Exception {
430: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/servicePortTests/servicePortBogusBinding_error.wsdl";
431: URL url = getClass().getResource(fileName);
432: URI uri = url.toURI();
433:
434: HashSet<String> expectedErrors = new HashSet<String>();
435: expectedErrors.add(format(mMessages
436: .getString("VAL_MISSING_BINDING_IN_SERVICE_PORT")));
437:
438: validate(uri, expectedErrors);
439:
440: }
441:
442: public void testSapInlineCrossReferenceValid() throws Exception {
443: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/Z_Flight.wsdl";
444: URL url = getClass().getResource(fileName);
445: URI uri = url.toURI();
446: HashSet<String> expectedErrors = new HashSet<String>();
447:
448: validate(uri, expectedErrors);
449: }
450:
451: public void testEmptyInlineSchemaValid() throws Exception {
452: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/emptyInlineSchema.wsdl";
453: URL url = getClass().getResource(fileName);
454: URI uri = url.toURI();
455: HashSet<String> expectedErrors = new HashSet<String>();
456:
457: validate(uri, expectedErrors);
458: }
459:
460: public void testInlineCrossReferenceAttributeValid()
461: throws Exception {
462: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/MultipleInlineSchemaReferingAttributes.wsdl";
463: URL url = getClass().getResource(fileName);
464: URI uri = url.toURI();
465: HashSet<String> expectedErrors = new HashSet<String>();
466:
467: validate(uri, expectedErrors);
468: }
469:
470: public void testMultipleTypesInValid() throws Exception {
471: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/typesMultiTypes_error.wsdl";
472: URL url = getClass().getResource(fileName);
473: URI uri = url.toURI();
474: HashSet<String> expectedErrors = new HashSet<String>();
475: expectedErrors.add(format(mMessages
476: .getString("VAL_MULTIPLE_TYPES_IN_DEFINITION")));
477:
478: validate(uri, expectedErrors);
479: }
480:
481: public void testRequestReplyOperationParameterOrderValid()
482: throws Exception {
483: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/reqrep/prmOrd_valid.wsdl";
484: URL url = getClass().getResource(fileName);
485: URI uri = url.toURI();
486: HashSet<String> expectedErrors = new HashSet<String>();
487:
488: validate(uri, expectedErrors);
489: }
490:
491: public void testRequestReplyOperationParameterOrderBogusPartsInvalid()
492: throws Exception {
493: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/reqrep/prmOrdBogusPartNames_error.wsdl";
494: URL url = getClass().getResource(fileName);
495: URI uri = url.toURI();
496: HashSet<String> expectedErrors = new HashSet<String>();
497: expectedErrors.add(format(mMessages
498: .getString("VAL_PARMETER_ORDER_CHECK_PART_EXISTENCE")));
499:
500: validate(uri, expectedErrors);
501: }
502:
503: public void testRequestReplyOperationParameterOrderMoreThanOnePartFromOutputMessageMissingInvalid()
504: throws Exception {
505: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/reqrep/prmOrdOpPartMissing_error.wsdl";
506: URL url = getClass().getResource(fileName);
507: URI uri = url.toURI();
508: HashSet<String> expectedErrors = new HashSet<String>();
509: expectedErrors
510: .add(format(mMessages
511: .getString("VAL_PARMETER_ORDER_CHECK_AT_MOST_ONE_OUTPUT_MESSAGE_PART_MISSING")));
512:
513: validate(uri, expectedErrors);
514: }
515:
516: public void testSolicitResponseOperationParameterOrderValid()
517: throws Exception {
518: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/solrep/prmOrd_valid.wsdl";
519:
520: URL url = getClass().getResource(fileName);
521: URI uri = url.toURI();
522: HashSet<String> expectedErrors = new HashSet<String>();
523:
524: validate(uri, expectedErrors);
525: }
526:
527: public void testSolicitResponseOperationParameterOrderBogusPartsInvalid()
528: throws Exception {
529: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/solrep/prmOrdBogusPartNames_error.wsdl";
530: URL url = getClass().getResource(fileName);
531: URI uri = url.toURI();
532: HashSet<String> expectedErrors = new HashSet<String>();
533: expectedErrors.add(format(mMessages
534: .getString("VAL_PARMETER_ORDER_CHECK_PART_EXISTENCE")));
535:
536: validate(uri, expectedErrors);
537: }
538:
539: public void testSolicitResponseOperationParameterOrderMoreThanOnePartFromOutputMessageMissingInvalid()
540: throws Exception {
541: String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/solrep/prmOrdOutputPartMissing_error.wsdl";
542: URL url = getClass().getResource(fileName);
543: URI uri = url.toURI();
544: HashSet<String> expectedErrors = new HashSet<String>();
545: expectedErrors
546: .add(format(mMessages
547: .getString("VAL_PARMETER_ORDER_CHECK_AT_MOST_ONE_OUTPUT_MESSAGE_PART_MISSING")));
548:
549: validate(uri, expectedErrors);
550: }
551:
552: private ValidationResult validate(URI relativePath)
553: throws Exception {
554: WSDLModel model = TestCatalogModel.getDefault().getWSDLModel(
555: relativePath);
556: Validation validation = new Validation();
557: ValidationType validationType = Validation.ValidationType.COMPLETE;
558: WSDLSemanticValidator instance = new WSDLSemanticValidator();
559:
560: ValidationResult result = instance.validate(model, validation,
561: validationType);
562: return result;
563: }
564:
565: private void validate(URI relativePath, Set<String> expectedErrors)
566: throws Exception {
567: System.out.println(relativePath);
568: ValidationResult result = validate(relativePath);
569: Iterator<ResultItem> it = result.getValidationResult()
570: .iterator();
571: ValidationHelper.dumpExpecedErrors(expectedErrors);
572: while (it.hasNext()) {
573: ResultItem item = it.next();
574: // System.out.println(" " + item.getDescription());
575: assertTrue("Actual Error " + item.getDescription() + "in "
576: + relativePath, ValidationHelper
577: .containsExpectedError(expectedErrors, item
578: .getDescription()));
579: }
580: if (result.getValidationResult().size() == 0
581: && expectedErrors.size() > 0) {
582: fail("Expected at least " + expectedErrors.size()
583: + " error(s). Got 0 errors instead");
584: }
585: }
586:
587: private String format(String value) {
588: return MessageFormat.format(value, new Object[] {});
589: }
590: }
|