1 19 20 package org.netbeans.modules.xml.wsdl.model.extensions.bpel.validation; 21 22 import java.net.URI ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.regex.Pattern ; 26 import org.netbeans.modules.xml.wsdl.model.extensions.TestCatalogModel; 27 import org.netbeans.modules.xml.xam.spi.Validation; 28 import org.netbeans.modules.xml.xam.spi.Validation.ValidationType; 29 import org.netbeans.modules.xml.xam.spi.ValidationResult; 30 import org.netbeans.modules.xml.xam.spi.Validator.ResultItem; 31 32 36 public class ValidationHelper { 37 38 private static Pattern p = Pattern.compile("\"?+\\{\\d\\}\"?+"); 39 40 41 public ValidationHelper() { 42 } 43 44 public static void dumpExpecedErrors(HashSet <String > expectedErrors) { 45 int counter = 1; 46 Iterator <String > it = expectedErrors.iterator(); 47 while(it.hasNext()) { 48 String expectedError = it.next(); 49 System.out.println("expected error :"+ counter + " " + expectedError); 50 counter++; 51 } 52 } 53 54 public static boolean containsExpectedError(HashSet <String > expectedErrors, String actualError) { 55 boolean result = false; 56 Iterator <String > it = expectedErrors.iterator(); 57 while(it.hasNext()) { 58 String [] needToMatch = null; 59 String expectedError = it.next(); 60 needToMatch = p.split(expectedError); 61 62 if(needToMatch != null) { 64 boolean foundMatch = true; 66 for(int i = 0; i < needToMatch.length; i++) { 67 String match = needToMatch[i]; 68 if(!actualError.contains(match)) { 69 foundMatch = false; 71 break; 72 } 73 } 74 75 result = foundMatch; 76 if(result) { 77 break; 78 } 79 } 80 81 } 82 return result; 83 } 84 } 85 | Popular Tags |