1 7 8 package org.netbeans.modules.xml.wsdl.validator; 9 10 import java.net.URI ; 11 import java.net.URL ; 12 import java.text.MessageFormat ; 13 import java.util.HashSet ; 14 import java.util.Iterator ; 15 import java.util.ResourceBundle ; 16 import java.util.Set ; 17 import junit.framework.*; 18 import org.netbeans.modules.xml.wsdl.model.TestCatalogModel; 19 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 20 import org.netbeans.modules.xml.wsdl.validator.visitor.WSDLSemanticsVisitor; 21 import org.netbeans.modules.xml.xam.spi.Validation; 22 import org.netbeans.modules.xml.xam.spi.ValidationResult; 23 import org.netbeans.modules.xml.xam.spi.Validation.ValidationType; 24 import org.netbeans.modules.xml.xam.spi.Validator.ResultItem; 25 26 30 public class WSDLSemanticValidatorTest extends TestCase { 31 32 private static final ResourceBundle mMessages = 33 ResourceBundle.getBundle(WSDLSemanticsVisitor.class.getPackage().getName()+".Bundle"); 34 35 public WSDLSemanticValidatorTest(String testName) { 36 super(testName); 37 } 38 39 protected void setUp() throws Exception { 40 } 41 42 protected void tearDown() throws Exception { 43 } 44 45 48 public void testGetName() { 49 System.out.println("getName"); 50 51 WSDLSemanticValidator instance = new WSDLSemanticValidator(); 52 53 String expResult = "WSDLSemanticValidator"; 54 String result = instance.getName(); 55 assertEquals(expResult, result); 56 57 } 58 59 62 public void testValidate() throws Exception { 63 System.out.println("validate"); 64 65 String fileName = "/org/netbeans/modules/xml/wsdl/validator/visitor/resources/valid/AsynchronousSample.wsdl"; 66 URL url = getClass().getResource(fileName); 67 URI uri = url.toURI(); 68 69 Set <String > expectedErrors = new HashSet <String >(); 70 validate(uri, expectedErrors); 71 } 72 73 public void testValidateDefinitionShouldHaveTargetNamespaceWarning() throws Exception { 74 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/definitionsTests/definitionsNoTargetN_invalid.wsdl"; 75 URL url = getClass().getResource(fileName); 76 URI uri = url.toURI(); 77 78 HashSet <String > expectedErrors = new HashSet <String >(); 79 expectedErrors.add(format(mMessages.getString("VAL_ERROR_WSDL_DEFINITIONS_NO_TARGETNAMESPACE"))); 80 validate(uri, expectedErrors); 81 } 82 83 84 public void testValidateDefinitionMissingTargetNamespaceWarning() throws Exception { 85 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/definitionsTests/definitionsNoTargetN_valid_warning.wsdl"; 86 URL url = getClass().getResource(fileName); 87 URI uri = url.toURI(); 88 89 HashSet <String > expectedErrors = new HashSet <String >(); 90 expectedErrors.add(format(mMessages.getString("VAL_ERROR_WSDL_DEFINITIONS_NO_TARGETNAMESPACE"))); 91 validate(uri, expectedErrors); 92 } 93 94 95 public void testValidateImportBogusLocation() throws Exception { 96 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLtests/importBogusLocation_error.wsdl"; 97 URL url = getClass().getResource(fileName); 98 URI uri = url.toURI(); 99 100 HashSet <String > expectedErrors = new HashSet <String >(); 101 expectedErrors.add(format(mMessages.getString("VAL_MISSING_IMPORTED_DOCUMENT"))); 102 validate(uri, expectedErrors); 103 } 104 105 public void testValidateImportNoLocation() throws Exception { 106 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLtests/importNoLocation_error.wsdl"; 107 URL url = getClass().getResource(fileName); 108 URI uri = url.toURI(); 109 110 HashSet <String > expectedErrors = new HashSet <String >(); 111 expectedErrors.add(format(mMessages.getString("VAL_MISSING_IMPORTED_DOCUMENT"))); 112 validate(uri, expectedErrors); 113 } 114 115 116 public void testValidateImportNoNamespace() throws Exception { 117 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLtests/importNoNamespace_error.wsdl"; 118 URL url = getClass().getResource(fileName); 119 URI uri = url.toURI(); 120 121 HashSet <String > expectedErrors = new HashSet <String >(); 122 expectedErrors.add(format(mMessages.getString("VAL_MISSING_IMPORTED_DOCUMENT"))); 123 validate(uri, expectedErrors); 124 } 125 126 public void testValidatePortTypeOperationDuplicateInputName() throws Exception { 127 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/portTypeMultiOpsNonuniqueInputNames_error.wsdl"; 128 URL url = getClass().getResource(fileName); 129 URI uri = url.toURI(); 130 131 HashSet <String > expectedErrors = new HashSet <String >(); 132 expectedErrors.add(format(mMessages.getString("VAL_DUPLICATE_OPRATION_INPUT_NAME_IN_PORTTYPE"))); 133 validate(uri, expectedErrors); 134 135 136 } 137 138 public void testValidatePortTypeOperationInputInvalidMessage() throws Exception { 139 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperationInputBogusMessage_error.wsdl"; 140 URL url = getClass().getResource(fileName); 141 URI uri = url.toURI(); 142 143 HashSet <String > expectedErrors = new HashSet <String >(); 144 expectedErrors.add(format(mMessages.getString("VAL_MESSAGE_NOT_FOUND_IN_OPERATION_INPUT"))); 145 validate(uri, expectedErrors); 146 147 148 } 149 150 public void testValidatePortTypeOperationDuplicateOutputName() throws Exception { 151 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/portTypeMultiOpsNonuniqueOutputNames_error.wsdl"; 152 URL url = getClass().getResource(fileName); 153 URI uri = url.toURI(); 154 155 HashSet <String > expectedErrors = new HashSet <String >(); 156 expectedErrors.add(format(mMessages.getString("VAL_DUPLICATE_OPRATION_OUTPUT_NAME_IN_PORTTYPE"))); 157 validate(uri, expectedErrors); 158 159 160 } 161 162 public void testValidatePortTypeOperationOutputInvalidMessage() throws Exception { 163 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperationOutputBogusMessage_error.wsdl"; 164 URL url = getClass().getResource(fileName); 165 URI uri = url.toURI(); 166 167 HashSet <String > expectedErrors = new HashSet <String >(); 168 expectedErrors.add(format(mMessages.getString("VAL_MESSAGE_NOT_FOUND_IN_OPERATION_OUTPUT"))); 169 validate(uri, expectedErrors); 170 171 172 } 173 174 public void testValidateRequestResponseOperationDuplicateFaultName() throws Exception { 175 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/portTypeMultiOpsNonuniqueFaultNamesSameOps_error.wsdl"; 176 URL url = getClass().getResource(fileName); 177 URI uri = url.toURI(); 178 179 HashSet <String > expectedErrors = new HashSet <String >(); 180 expectedErrors.add(format(mMessages.getString("VAL_DUPLICATE_OPRATION_FAULT_NAME"))); 181 validate(uri, expectedErrors); 182 } 183 184 public void testValidateRequestResponseOperationFaultInvalidMessage() throws Exception { 185 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperationFaultBogusMessage_error.wsdl"; 186 URL url = getClass().getResource(fileName); 187 URI uri = url.toURI(); 188 189 HashSet <String > expectedErrors = new HashSet <String >(); 190 expectedErrors.add(format(mMessages.getString("VAL_MESSAGE_NOT_FOUND_IN_OPERATION_FAULT"))); 191 validate(uri, expectedErrors); 192 } 193 194 public void testValidateSolicitResponseOperationDuplicateFaultName() throws Exception { 195 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeMultiOpsNonuniqueFaultNamesSameOps_error.wsdl"; 196 URL url = getClass().getResource(fileName); 197 URI uri = url.toURI(); 198 199 HashSet <String > expectedErrors = new HashSet <String >(); 200 expectedErrors.add(format(mMessages.getString("VAL_DUPLICATE_OPRATION_FAULT_NAME"))); 201 validate(uri, expectedErrors); 202 } 203 204 public void testValidateSolicitResponseOperationFaultInvalidMessage() throws Exception { 205 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeSRFOperationFaultBogusMessage_error.wsdl"; 206 URL url = getClass().getResource(fileName); 207 URI uri = url.toURI(); 208 209 HashSet <String > expectedErrors = new HashSet <String >(); 210 expectedErrors.add(format(mMessages.getString("VAL_MESSAGE_NOT_FOUND_IN_OPERATION_FAULT"))); 211 validate(uri, expectedErrors); 212 } 213 214 public void testValidateOnewayOperationFaultShouldNotBeDefined() throws Exception { 215 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/OneWay/portTypeOWOperationFaultDefined_error.wsdl"; 216 URL url = getClass().getResource(fileName); 217 URI uri = url.toURI(); 218 219 HashSet <String > expectedErrors = new HashSet <String >(); 220 expectedErrors.add(format(mMessages.getString("VAL_FAULT_NOT_ALLOWED_IN_OPERATION"))); 221 validate(uri, expectedErrors); 222 } 223 224 public void testValidateNotificationOperationFaultShouldNotBeDefined() throws Exception { 225 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/Notification/portTypeNOperationFaultDefined_error.wsdl"; 226 URL url = getClass().getResource(fileName); 227 URI uri = url.toURI(); 228 229 HashSet <String > expectedErrors = new HashSet <String >(); 230 expectedErrors.add(format(mMessages.getString("VAL_FAULT_NOT_ALLOWED_IN_OPERATION"))); 231 validate(uri, expectedErrors); 232 } 233 234 public void testValidateMessageNoPartWarning() throws Exception { 235 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messageNoParts.wsdl"; 236 URL url = getClass().getResource(fileName); 237 URI uri = url.toURI(); 238 239 HashSet <String > expectedErrors = new HashSet <String >(); 240 expectedErrors.add(format(mMessages.getString("VAL_WARNING_WSDL_MESSAGE_DOES_NOT_HAVE_ANY_PARTS_DEFINED"))); 241 validate(uri, expectedErrors); 242 } 243 244 public void testValidatePartNoElementOrTypeAttribute() throws Exception { 245 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartNoTypeOrElement_error.wsdl"; 246 URL url = getClass().getResource(fileName); 247 URI uri = url.toURI(); 248 249 HashSet <String > expectedErrors = new HashSet <String >(); 250 expectedErrors.add(format(mMessages.getString("VAL_NO_ELEMENT_OR_TYPE_ATTRIBUTE_DEFINED_IN_MESSAGE_PART"))); 251 validate(uri, expectedErrors); 252 } 253 254 public void testValidatePartInvalidElementAttribute() throws Exception { 255 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartBadElement_error.wsdl"; 256 URL url = getClass().getResource(fileName); 257 URI uri = url.toURI(); 258 259 HashSet <String > expectedErrors = new HashSet <String >(); 260 expectedErrors.add(format(mMessages.getString("VAL_ELEMENT_ATTRIBUTE_DEFINED_IN_MESSAGE_PART_IS_NOT_VALID"))); 261 validate(uri, expectedErrors); 262 } 263 264 265 public void testValidatePartInvalidTypeAttribute() throws Exception { 266 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartBadType_error.wsdl"; 267 URL url = getClass().getResource(fileName); 268 URI uri = url.toURI(); 269 270 HashSet <String > expectedErrors = new HashSet <String >(); 271 expectedErrors.add(format(mMessages.getString("VAL_TYPE_ATTRIBUTE_DEFINED_IN_MESSAGE_PART_IS_NOT_VALID"))); 272 validate(uri, expectedErrors); 273 } 274 275 public void testValidatePartBothTypeAndAttributeError() throws Exception { 276 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartElementAndType_error.wsdl"; 277 URL url = getClass().getResource(fileName); 278 URI uri = url.toURI(); 279 280 HashSet <String > expectedErrors = new HashSet <String >(); 281 expectedErrors.add(format(mMessages.getString("VAL_BOTH_ELEMENT_OR_TYPE_ATTRIBUTE_DEFINED_IN_MESSAGE_PART"))); 282 validate(uri, expectedErrors); 283 } 284 285 public void testValidateImport() throws Exception { 286 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLTests/importBogusLocation_error.wsdl"; 287 URL url = getClass().getResource(fileName); 288 URI uri = url.toURI(); 289 290 HashSet <String > expectedErrors = new HashSet <String >(); 291 expectedErrors.add(format(mMessages.getString("VAL_MISSING_IMPORTED_DOCUMENT"))); 292 validate(uri, expectedErrors); 293 } 294 295 296 public void testValidateBindingInvalidType() throws Exception { 297 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/bindingRRFBogusType_error.wsdl"; 298 URL url = getClass().getResource(fileName); 299 URI uri = url.toURI(); 300 301 HashSet <String > expectedErrors = new HashSet <String >(); 302 expectedErrors.add(format(mMessages.getString("VAL_MISSING_PORTTYPE_IN_BINDING"))); 303 validate(uri, expectedErrors); 304 } 305 306 307 public void testValidateBindingOperationOverloadedValid() throws Exception { 308 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpName_valid.wsdl"; 309 URL url = getClass().getResource(fileName); 310 URI uri = url.toURI(); 311 312 HashSet <String > expectedErrors = new HashSet <String >(); 313 validate(uri, expectedErrors); 314 } 315 316 317 public void testValidateBindingOperationOverloadedNoMatchingOperationError() throws Exception { 318 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch_error.wsdl"; 319 URL url = getClass().getResource(fileName); 320 URI uri = url.toURI(); 321 322 HashSet <String > expectedErrors = new HashSet <String >(); 323 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_INPUT_NAME_IN_PORT_TYPE"))); 324 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_OUTPUT_NAME_IN_PORT_TYPE"))); 325 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_FAULTS_IN_PORT_TYPE"))); 326 327 validate(uri, expectedErrors); 328 } 329 330 public void testValidateBindingOperationOverloadedNoMatchingOperationInputOutputFaultError1() throws Exception { 331 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch_error.wsdl"; 332 URL url = getClass().getResource(fileName); 333 URI uri = url.toURI(); 334 335 HashSet <String > expectedErrors = new HashSet <String >(); 336 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_INPUT_NAME_IN_PORT_TYPE"))); 337 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_OUTPUT_NAME_IN_PORT_TYPE"))); 338 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_FAULTS_IN_PORT_TYPE"))); 339 340 validate(uri, expectedErrors); 341 } 342 343 public void testValidateBindingOperationOverloadedNoMatchingOperationInputOutputFaultError2() throws Exception { 344 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch2_error.wsdl"; 345 URL url = getClass().getResource(fileName); 346 URI uri = url.toURI(); 347 348 HashSet <String > expectedErrors = new HashSet <String >(); 349 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_INPUT_NAME_IN_PORT_TYPE"))); 350 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_OUTPUT_NAME_IN_PORT_TYPE"))); 351 expectedErrors.add(format(mMessages.getString("VAL_OPERATION_DOES_NOT_MATCH_FAULTS_IN_PORT_TYPE"))); 352 353 validate(uri, expectedErrors); 354 } 355 356 public void testValidateBindingOperationSignatureSameAsPortTypeOperationValid() throws Exception { 357 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingOperationSignatureSameAsPortTypeOperation_valid.wsdl"; 358 URL url = getClass().getResource(fileName); 359 URI uri = url.toURI(); 360 361 HashSet <String > expectedErrors = new HashSet <String >(); 362 validate(uri, expectedErrors); 363 } 364 365 366 public void testServicePortInvalidBinding() throws Exception { 367 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/servicePortTests/servicePortBogusBinding_error.wsdl"; 368 URL url = getClass().getResource(fileName); 369 URI uri = url.toURI(); 370 371 HashSet <String > expectedErrors = new HashSet <String >(); 372 expectedErrors.add(format(mMessages.getString("VAL_MISSING_BINDING_IN_SERVICE_PORT"))); 373 374 375 validate(uri, expectedErrors); 376 377 } 378 379 public void testSapInlineCrossReferenceValid() throws Exception { 380 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/Z_Flight.wsdl"; 381 URL url = getClass().getResource(fileName); 382 URI uri = url.toURI(); 383 HashSet <String > expectedErrors = new HashSet <String >(); 384 385 validate(uri, expectedErrors); 386 } 387 388 389 public void testEmptyInlineSchemaValid() throws Exception { 390 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/emptyInlineSchema.wsdl"; 391 URL url = getClass().getResource(fileName); 392 URI uri = url.toURI(); 393 HashSet <String > expectedErrors = new HashSet <String >(); 394 395 validate(uri, expectedErrors); 396 } 397 398 399 public void testInlineCrossReferenceAttributeValid() throws Exception { 400 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/MultipleInlineSchemaReferingAttributes.wsdl"; 401 URL url = getClass().getResource(fileName); 402 URI uri = url.toURI(); 403 HashSet <String > expectedErrors = new HashSet <String >(); 404 405 validate(uri, expectedErrors); 406 } 407 408 public void testMultipleTypesInValid() throws Exception { 409 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/typesMultiTypes_error.wsdl"; 410 URL url = getClass().getResource(fileName); 411 URI uri = url.toURI(); 412 HashSet <String > expectedErrors = new HashSet <String >(); 413 expectedErrors.add(format(mMessages.getString("VAL_MULTIPLE_TYPES_IN_DEFINITION"))); 414 415 validate(uri, expectedErrors); 416 } 417 418 419 public void testRequestReplyOperationParameterOrderValid() throws Exception { 420 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperatorparamOrder_valid.wsdl"; 421 URL url = getClass().getResource(fileName); 422 URI uri = url.toURI(); 423 HashSet <String > expectedErrors = new HashSet <String >(); 424 425 validate(uri, expectedErrors); 426 } 427 428 429 public void testRequestReplyOperationParameterOrderBogusPartsInvalid() throws Exception { 430 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperatorparamOrderBogusPartNames_error.wsdl"; 431 URL url = getClass().getResource(fileName); 432 URI uri = url.toURI(); 433 HashSet <String > expectedErrors = new HashSet <String >(); 434 expectedErrors.add(format(mMessages.getString("VAL_PARMETER_ORDER_CHECK_PART_EXISTENCE"))); 435 436 validate(uri, expectedErrors); 437 } 438 439 public void testRequestReplyOperationParameterOrderMoreThanOnePartFromOutputMessageMissingInvalid() throws Exception { 440 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperatorparamOrderMoreThanOneOutputMessagePartMissing_error.wsdl"; 441 URL url = getClass().getResource(fileName); 442 URI uri = url.toURI(); 443 HashSet <String > expectedErrors = new HashSet <String >(); 444 expectedErrors.add(format(mMessages.getString("VAL_PARMETER_ORDER_CHECK_AT_MOST_ONE_OUTPUT_MESSAGE_PART_MISSING"))); 445 446 validate(uri, expectedErrors); 447 } 448 449 public void testSolicitResponseOperationParameterOrderValid() throws Exception { 450 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeSRFOperationparmOrder_valid.wsdl"; 451 452 URL url = getClass().getResource(fileName); 453 URI uri = url.toURI(); 454 HashSet <String > expectedErrors = new HashSet <String >(); 455 456 validate(uri, expectedErrors); 457 } 458 459 460 public void testSolicitResponseOperationParameterOrderBogusPartsInvalid() throws Exception { 461 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeSRFOperationparmOrderBogusPartNames_error.wsdl"; 462 URL url = getClass().getResource(fileName); 463 URI uri = url.toURI(); 464 HashSet <String > expectedErrors = new HashSet <String >(); 465 expectedErrors.add(format(mMessages.getString("VAL_PARMETER_ORDER_CHECK_PART_EXISTENCE"))); 466 467 validate(uri, expectedErrors); 468 } 469 470 public void testSolicitResponseOperationParameterOrderMoreThanOnePartFromOutputMessageMissingInvalid() throws Exception { 471 String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeSRFOperationparmOrderrMoreThanOneOutputMessagePartMissing_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.getString("VAL_PARMETER_ORDER_CHECK_AT_MOST_ONE_OUTPUT_MESSAGE_PART_MISSING"))); 476 477 validate(uri, expectedErrors); 478 } 479 480 private ValidationResult validate(URI relativePath) throws Exception { 481 WSDLModel model = TestCatalogModel.getDefault().getWSDLModel(relativePath); 482 Validation validation = new Validation(); 483 ValidationType validationType = Validation.ValidationType.COMPLETE; 484 WSDLSemanticValidator instance = new WSDLSemanticValidator(); 485 486 ValidationResult result = 487 instance.validate(model, validation, validationType); 488 return result; 489 } 490 491 private void validate(URI relativePath, Set <String > expectedErrors) 492 throws Exception { 493 System.out.println(relativePath); 494 ValidationResult result = validate(relativePath); 495 Iterator <ResultItem> it = result.getValidationResult().iterator(); 496 ValidationHelper.dumpExpecedErrors(expectedErrors); 497 while (it.hasNext()) { 498 ResultItem item = it.next(); 499 assertTrue("Actual Error "+ item.getDescription() + "in " +relativePath, ValidationHelper.containsExpectedError(expectedErrors, item.getDescription())); 501 } 502 if (result.getValidationResult().size() == 0 && expectedErrors.size() > 0) { 503 fail("Expected at least " + expectedErrors.size() + " error(s). Got 0 errors instead"); 504 } 505 } 506 507 private String format(String value) { 508 return MessageFormat.format(value, new Object []{}); 509 } 510 } 511 | Popular Tags |