1 2 3 package org.quilt.runner; 4 5 import java.io.BufferedReader ; 6 import java.io.PrintWriter ; 7 import java.io.StringReader ; 8 import java.io.StringWriter ; 9 10 import junit.framework.*; 11 import org.apache.tools.ant.util.StringUtils; 12 13 import org.quilt.framework.QuiltTest; 14 import org.quilt.reports.Formatter; 15 16 19 public abstract class Runner extends QuiltTest 20 implements RunnerConst, TestListener { 21 22 public abstract void run (); public abstract int getRetCode(); 24 25 public static String getFilteredTrace(Throwable t, boolean filtertrace) { 27 String trace = StringUtils.getStackTrace(t); 28 return filterStack(trace, filtertrace); 29 } 30 31 35 40 public static String filterStack(String stack, boolean filtertrace) { 41 if ( ! filtertrace ) { 42 return stack; 43 } 44 StringWriter sw = new StringWriter (); 45 PrintWriter pw = new PrintWriter (sw); 46 StringReader sr = new StringReader (stack); 47 BufferedReader br = new BufferedReader (sr); 48 49 String line; 50 try { 51 while ((line = br.readLine()) != null) { 52 if (!filterLine(line)) { 53 pw.println(line); 54 } 55 } 56 } catch (Exception IOException) { 57 return stack; } 59 return sw.toString(); 60 } 61 62 private static boolean filterLine(String line) { 63 for (int i = 0; i < DEFAULT_TRACE_FILTERS.length; i++) { 64 if (line.indexOf(DEFAULT_TRACE_FILTERS[i]) > 0) { 65 return true; 66 } 67 } 68 return false; 69 } 70 72 public abstract void addFormatter(Formatter f); 73 75 public abstract void addFailure(Test test, Throwable t); 76 77 public abstract void addFailure(Test test, AssertionFailedError t); 78 79 public abstract void addError(Test test, Throwable t); 80 81 public abstract void startTest(Test t); 82 83 public abstract void endTest(Test test); 84 85 public abstract void handleOutput(String line); 86 87 public abstract void handleErrorOutput(String line); 88 89 public abstract void handleFlush(String line); 90 91 public abstract void handleErrorFlush(String line); 92 } 93 | Popular Tags |