1 19 20 package org.netbeans.modules.xml.tools.actions; 21 22 import java.util.Arrays ; 23 import org.netbeans.tests.xml.XTest; 24 import org.openide.nodes.Node; 25 26 public abstract class AbstractCheckTest extends XTest { 27 28 29 public AbstractCheckTest(String testName) { 30 super(testName); 31 } 32 33 34 abstract protected QaIOReporter performAction(Node[] nodes); 35 36 38 39 protected void performAction(String name, int bugCount) { 40 QaIOReporter reporter = performAction(name); 41 String message = "\nUnexpected bug count, expected: " + bugCount + " reported: "+ reporter.getBugCount(); 42 assertEquals(message, bugCount, reporter.getBugCount()); 43 } 44 45 46 protected void performAction(String name, int[] errLines) { 47 QaIOReporter reporter = performAction(name); 48 int[] report = reporter.getErrLines(); 49 Arrays.sort(errLines); 50 Arrays.sort(report); 51 52 if (!!! Arrays.equals(errLines, report)) { 53 String pattern = arrayToString(errLines); 54 String result = arrayToString(report); 55 fail("\nUnexpected Validation result.\nPattern: " + pattern + "\nResult: " + result); 56 } 57 } 58 59 60 protected QaIOReporter performAction(String name) { 61 Node node = null; 62 try { 63 node = TestUtil.THIS.findData(name).getNodeDelegate(); 64 } catch (Exception ex) { 65 ex.printStackTrace(dbg); 66 fail("Cannot get Node Delegate for 'data/" + name +"' due:\n" + ex); 67 } 68 QaIOReporter reporter = performAction(new Node[] {node}); 69 return reporter; 70 } 71 72 private static String arrayToString(int[] array) { 73 StringBuffer buf = new StringBuffer ("["); 74 for (int i = 0; i < array.length; i++) { 75 buf.append(array[i]); 76 buf.append(", "); 77 } 78 buf.replace(buf.length() - 2, buf.length(), "]"); 79 return buf.toString(); 80 } 81 } 82 | Popular Tags |