1 18 package org.apache.batik.test; 19 20 import java.io.PrintWriter ; 21 import java.io.StringWriter ; 22 23 30 public class TestErrorConditionException extends Exception { 31 34 protected String errorCode; 35 36 39 protected TestErrorConditionException(){ 40 } 41 42 45 public TestErrorConditionException(String errorCode){ 46 this.errorCode = errorCode; 47 } 48 49 52 public TestReport getTestReport(Test test){ 53 DefaultTestReport report = new DefaultTestReport(test); 54 if(errorCode != null){ 55 report.setErrorCode(errorCode); 56 } else { 57 report.setErrorCode(TestReport.ERROR_TEST_FAILED); 58 } 59 60 report.setPassed(false); 61 addStackTraceDescription(report); 62 return report; 63 } 64 65 69 public void addStackTraceDescription(TestReport report){ 70 StringWriter trace = new StringWriter (); 71 printStackTrace(new PrintWriter (trace)); 72 73 report.addDescriptionEntry 74 (TestReport.ENTRY_KEY_ERROR_CONDITION_STACK_TRACE, 75 trace.toString()); 76 } 77 } 78 | Popular Tags |