1 9 10 package org.netbeans.modules.xml.wsdl.validator; 11 12 import java.util.Iterator ; 13 import java.util.Set ; 14 import java.util.regex.Pattern ; 15 import org.netbeans.modules.xml.xam.spi.Validation; 16 import org.netbeans.modules.xml.xam.spi.ValidationResult; 17 import org.netbeans.modules.xml.xam.spi.Validator; 18 19 23 public class ValidationHelper { 24 25 private static Pattern p = Pattern.compile("\"?+\\{\\d\\}\"?+"); 26 27 28 public ValidationHelper() { 29 } 30 31 public static void dumpExpecedErrors(Set <String > expectedErrors) { 32 int counter = 1; 33 Iterator <String > it = expectedErrors.iterator(); 34 while(it.hasNext()) { 35 String expectedError = it.next(); 36 System.out.println("expected error :"+ counter + " " + expectedError); 37 counter++; 38 } 39 } 40 41 public static boolean containsExpectedError(Set <String > expectedErrors, String actualError) { 42 boolean result = false; 43 Iterator <String > it = expectedErrors.iterator(); 44 while(it.hasNext()) { 45 String [] needToMatch = null; 46 String expectedError = it.next(); 47 needToMatch = p.split(expectedError); 48 49 if(needToMatch != null) { 51 boolean foundMatch = true; 53 for(int i = 0; i < needToMatch.length; i++) { 54 String match = needToMatch[i]; 55 if(!actualError.contains(match)) { 56 foundMatch = false; 58 break; 59 } 60 } 61 62 result = foundMatch; 63 if(result) { 64 break; 65 } 66 } 67 68 } 69 return result; 70 } 71 72 public static void dumpErrors(ValidationResult result) { 73 int counter = 1; 74 75 Iterator <Validator.ResultItem> it = result.getValidationResult().iterator(); 76 while(it.hasNext()) { 77 Validator.ResultItem item = it.next(); 78 String expectedError = item.getDescription(); 79 System.out.println("found error :"+ counter + " " + expectedError); 80 counter++; 81 } 82 } 83 84 } 85 | Popular Tags |