KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > validator > WSDLSemanticValidatorTest


1 /*
2  * WSDLSemanticValidatorTest.java
3  * JUnit based test
4  *
5  * Created on January 29, 2007, 10:47 AM
6  */

7
8 package org.netbeans.modules.xml.wsdl.validator;
9
10 import java.net.URI JavaDoc;
11 import java.net.URL JavaDoc;
12 import java.text.MessageFormat JavaDoc;
13 import java.util.HashSet JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.ResourceBundle JavaDoc;
16 import java.util.Set JavaDoc;
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 /**
27  *
28  * @author radval
29  */

30 public class WSDLSemanticValidatorTest extends TestCase {
31     
32     private static final ResourceBundle JavaDoc mMessages =
33         ResourceBundle.getBundle(WSDLSemanticsVisitor.class.getPackage().getName()+".Bundle");
34
35     public WSDLSemanticValidatorTest(String JavaDoc testName) {
36         super(testName);
37     }
38
39     protected void setUp() throws Exception JavaDoc {
40     }
41
42     protected void tearDown() throws Exception JavaDoc {
43     }
44
45     /**
46      * Test of getName method, of class org.netbeans.modules.xml.wsdl.validator.WSDLSemanticValidator.
47      */

48     public void testGetName() {
49         System.out.println("getName");
50         
51         WSDLSemanticValidator instance = new WSDLSemanticValidator();
52         
53         String JavaDoc expResult = "WSDLSemanticValidator";
54         String JavaDoc result = instance.getName();
55         assertEquals(expResult, result);
56         
57     }
58
59     /**
60      * Test of validate method, of class org.netbeans.modules.xml.wsdl.validator.WSDLSemanticValidator.
61      */

62     public void testValidate() throws Exception JavaDoc {
63         System.out.println("validate");
64         
65         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/visitor/resources/valid/AsynchronousSample.wsdl";
66         URL JavaDoc url = getClass().getResource(fileName);
67         URI JavaDoc uri = url.toURI();
68         
69         Set JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
70         validate(uri, expectedErrors);
71     }
72     
73     public void testValidateDefinitionShouldHaveTargetNamespaceWarning() throws Exception JavaDoc {
74         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/definitionsTests/definitionsNoTargetN_invalid.wsdl";
75         URL JavaDoc url = getClass().getResource(fileName);
76         URI JavaDoc uri = url.toURI();
77         
78         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
85         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/definitionsTests/definitionsNoTargetN_valid_warning.wsdl";
86         URL JavaDoc url = getClass().getResource(fileName);
87         URI JavaDoc uri = url.toURI();
88         
89         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
96         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLtests/importBogusLocation_error.wsdl";
97         URL JavaDoc url = getClass().getResource(fileName);
98         URI JavaDoc uri = url.toURI();
99         
100         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
101         expectedErrors.add(format(mMessages.getString("VAL_MISSING_IMPORTED_DOCUMENT")));
102         validate(uri, expectedErrors);
103     }
104     
105     public void testValidateImportNoLocation() throws Exception JavaDoc {
106         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLtests/importNoLocation_error.wsdl";
107         URL JavaDoc url = getClass().getResource(fileName);
108         URI JavaDoc uri = url.toURI();
109         
110         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
111         expectedErrors.add(format(mMessages.getString("VAL_MISSING_IMPORTED_DOCUMENT")));
112         validate(uri, expectedErrors);
113     }
114     
115     
116     public void testValidateImportNoNamespace() throws Exception JavaDoc {
117         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLtests/importNoNamespace_error.wsdl";
118         URL JavaDoc url = getClass().getResource(fileName);
119         URI JavaDoc uri = url.toURI();
120         
121         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
122         expectedErrors.add(format(mMessages.getString("VAL_MISSING_IMPORTED_DOCUMENT")));
123         validate(uri, expectedErrors);
124     }
125     
126     public void testValidatePortTypeOperationDuplicateInputName() throws Exception JavaDoc {
127         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/portTypeMultiOpsNonuniqueInputNames_error.wsdl";
128         URL JavaDoc url = getClass().getResource(fileName);
129         URI JavaDoc uri = url.toURI();
130         
131         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
139         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperationInputBogusMessage_error.wsdl";
140         URL JavaDoc url = getClass().getResource(fileName);
141         URI JavaDoc uri = url.toURI();
142         
143         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
151         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/portTypeMultiOpsNonuniqueOutputNames_error.wsdl";
152         URL JavaDoc url = getClass().getResource(fileName);
153         URI JavaDoc uri = url.toURI();
154         
155         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
163         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperationOutputBogusMessage_error.wsdl";
164         URL JavaDoc url = getClass().getResource(fileName);
165         URI JavaDoc uri = url.toURI();
166         
167         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
175         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/portTypeMultiOpsNonuniqueFaultNamesSameOps_error.wsdl";
176         URL JavaDoc url = getClass().getResource(fileName);
177         URI JavaDoc uri = url.toURI();
178         
179         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
180         expectedErrors.add(format(mMessages.getString("VAL_DUPLICATE_OPRATION_FAULT_NAME")));
181         validate(uri, expectedErrors);
182     }
183      
184     public void testValidateRequestResponseOperationFaultInvalidMessage() throws Exception JavaDoc {
185         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperationFaultBogusMessage_error.wsdl";
186         URL JavaDoc url = getClass().getResource(fileName);
187         URI JavaDoc uri = url.toURI();
188         
189         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
195         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeMultiOpsNonuniqueFaultNamesSameOps_error.wsdl";
196         URL JavaDoc url = getClass().getResource(fileName);
197         URI JavaDoc uri = url.toURI();
198         
199         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
200         expectedErrors.add(format(mMessages.getString("VAL_DUPLICATE_OPRATION_FAULT_NAME")));
201         validate(uri, expectedErrors);
202     }
203      
204     public void testValidateSolicitResponseOperationFaultInvalidMessage() throws Exception JavaDoc {
205         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeSRFOperationFaultBogusMessage_error.wsdl";
206         URL JavaDoc url = getClass().getResource(fileName);
207         URI JavaDoc uri = url.toURI();
208         
209         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
215         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/OneWay/portTypeOWOperationFaultDefined_error.wsdl";
216         URL JavaDoc url = getClass().getResource(fileName);
217         URI JavaDoc uri = url.toURI();
218         
219         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
220         expectedErrors.add(format(mMessages.getString("VAL_FAULT_NOT_ALLOWED_IN_OPERATION")));
221         validate(uri, expectedErrors);
222     }
223     
224     public void testValidateNotificationOperationFaultShouldNotBeDefined() throws Exception JavaDoc {
225         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/Notification/portTypeNOperationFaultDefined_error.wsdl";
226         URL JavaDoc url = getClass().getResource(fileName);
227         URI JavaDoc uri = url.toURI();
228         
229         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
230         expectedErrors.add(format(mMessages.getString("VAL_FAULT_NOT_ALLOWED_IN_OPERATION")));
231         validate(uri, expectedErrors);
232     }
233     
234     public void testValidateMessageNoPartWarning() throws Exception JavaDoc {
235         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messageNoParts.wsdl";
236         URL JavaDoc url = getClass().getResource(fileName);
237         URI JavaDoc uri = url.toURI();
238         
239         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
245         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartNoTypeOrElement_error.wsdl";
246         URL JavaDoc url = getClass().getResource(fileName);
247         URI JavaDoc uri = url.toURI();
248         
249         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
255         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartBadElement_error.wsdl";
256         URL JavaDoc url = getClass().getResource(fileName);
257         URI JavaDoc uri = url.toURI();
258         
259         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
266         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartBadType_error.wsdl";
267         URL JavaDoc url = getClass().getResource(fileName);
268         URI JavaDoc uri = url.toURI();
269         
270         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
276         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messagePartElementAndType_error.wsdl";
277         URL JavaDoc url = getClass().getResource(fileName);
278         URI JavaDoc uri = url.toURI();
279         
280         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
286         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLTests/importBogusLocation_error.wsdl";
287         URL JavaDoc url = getClass().getResource(fileName);
288         URI JavaDoc uri = url.toURI();
289         
290         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
291         expectedErrors.add(format(mMessages.getString("VAL_MISSING_IMPORTED_DOCUMENT")));
292         validate(uri, expectedErrors);
293     }
294     
295     
296     public void testValidateBindingInvalidType() throws Exception JavaDoc {
297         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/bindingRRFBogusType_error.wsdl";
298         URL JavaDoc url = getClass().getResource(fileName);
299         URI JavaDoc uri = url.toURI();
300         
301         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
302         expectedErrors.add(format(mMessages.getString("VAL_MISSING_PORTTYPE_IN_BINDING")));
303         validate(uri, expectedErrors);
304     }
305     
306     
307     public void testValidateBindingOperationOverloadedValid() throws Exception JavaDoc {
308         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpName_valid.wsdl";
309         URL JavaDoc url = getClass().getResource(fileName);
310         URI JavaDoc uri = url.toURI();
311         
312         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
313         validate(uri, expectedErrors);
314     }
315     
316     
317     public void testValidateBindingOperationOverloadedNoMatchingOperationError() throws Exception JavaDoc {
318         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch_error.wsdl";
319         URL JavaDoc url = getClass().getResource(fileName);
320         URI JavaDoc uri = url.toURI();
321         
322         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
331         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch_error.wsdl";
332         URL JavaDoc url = getClass().getResource(fileName);
333         URI JavaDoc uri = url.toURI();
334         
335         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
344         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingRRFMultiOpsNonUniqueOpNameNoMatch2_error.wsdl";
345         URL JavaDoc url = getClass().getResource(fileName);
346         URI JavaDoc uri = url.toURI();
347         
348         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
357         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/bindingTests/operations/bindingOperationSignatureSameAsPortTypeOperation_valid.wsdl";
358         URL JavaDoc url = getClass().getResource(fileName);
359         URI JavaDoc uri = url.toURI();
360         
361         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
362         validate(uri, expectedErrors);
363     }
364     
365             
366     public void testServicePortInvalidBinding() throws Exception JavaDoc {
367         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/servicePortTests/servicePortBogusBinding_error.wsdl";
368         URL JavaDoc url = getClass().getResource(fileName);
369         URI JavaDoc uri = url.toURI();
370         
371         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
380         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/Z_Flight.wsdl";
381         URL JavaDoc url = getClass().getResource(fileName);
382         URI JavaDoc uri = url.toURI();
383         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
384        
385         validate(uri, expectedErrors);
386     }
387    
388      
389     public void testEmptyInlineSchemaValid() throws Exception JavaDoc {
390         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/emptyInlineSchema.wsdl";
391         URL JavaDoc url = getClass().getResource(fileName);
392         URI JavaDoc uri = url.toURI();
393         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
394        
395         validate(uri, expectedErrors);
396     }
397     
398     
399      public void testInlineCrossReferenceAttributeValid() throws Exception JavaDoc {
400         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/MultipleInlineSchemaReferingAttributes.wsdl";
401         URL JavaDoc url = getClass().getResource(fileName);
402         URI JavaDoc uri = url.toURI();
403         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
404        
405         validate(uri, expectedErrors);
406     }
407     
408      public void testMultipleTypesInValid() throws Exception JavaDoc {
409         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/typesMultiTypes_error.wsdl";
410         URL JavaDoc url = getClass().getResource(fileName);
411         URI JavaDoc uri = url.toURI();
412         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
420         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperatorparamOrder_valid.wsdl";
421         URL JavaDoc url = getClass().getResource(fileName);
422         URI JavaDoc uri = url.toURI();
423         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
424         
425         validate(uri, expectedErrors);
426      }
427      
428      
429      public void testRequestReplyOperationParameterOrderBogusPartsInvalid() throws Exception JavaDoc {
430         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperatorparamOrderBogusPartNames_error.wsdl";
431         URL JavaDoc url = getClass().getResource(fileName);
432         URI JavaDoc uri = url.toURI();
433         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
440         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/RequestResponse/portTypeRRFOperatorparamOrderMoreThanOneOutputMessagePartMissing_error.wsdl";
441         URL JavaDoc url = getClass().getResource(fileName);
442         URI JavaDoc uri = url.toURI();
443         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
450         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeSRFOperationparmOrder_valid.wsdl";
451                           
452         URL JavaDoc url = getClass().getResource(fileName);
453         URI JavaDoc uri = url.toURI();
454         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
455         
456         validate(uri, expectedErrors);
457      }
458      
459      
460      public void testSolicitResponseOperationParameterOrderBogusPartsInvalid() throws Exception JavaDoc {
461         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeSRFOperationparmOrderBogusPartNames_error.wsdl";
462         URL JavaDoc url = getClass().getResource(fileName);
463         URI JavaDoc uri = url.toURI();
464         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc {
471         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/portTypeTests/OperationTests/SolicitResponse/portTypeSRFOperationparmOrderrMoreThanOneOutputMessagePartMissing_error.wsdl";
472         URL JavaDoc url = getClass().getResource(fileName);
473         URI JavaDoc uri = url.toURI();
474         HashSet JavaDoc<String JavaDoc> expectedErrors = new HashSet JavaDoc<String JavaDoc>();
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 JavaDoc relativePath) throws Exception JavaDoc {
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 JavaDoc relativePath, Set JavaDoc<String JavaDoc> expectedErrors)
492         throws Exception JavaDoc {
493         System.out.println(relativePath);
494         ValidationResult result = validate(relativePath);
495         Iterator JavaDoc<ResultItem> it = result.getValidationResult().iterator();
496         ValidationHelper.dumpExpecedErrors(expectedErrors);
497         while (it.hasNext()) {
498             ResultItem item = it.next();
499 // System.out.println(" " + item.getDescription());
500
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 JavaDoc format(String JavaDoc value) {
508         return MessageFormat.format(value, new Object JavaDoc[]{});
509     }
510 }
511
Popular Tags