package bluej.debugger.jdi;

import java.io.*;
import java.util.Arrays;
import java.util.stream.Collectors;

import bluej.debugger.DebuggerTestResult;
import bluej.debugger.SourceLocation;
import bluej.utility.Utility;
import threadchecker.OnThread;
import threadchecker.Tag;


| Represents the result of running a single test method. | @OnThread(Tag.Any) public class JdiTestResult extends DebuggerTestResult{ protected String className; protected String methodName; protected String exceptionMsg, traceMsg; protected int runTimeMs; JdiTestResult(String className, String methodName, int runTimeMs) { if (className == null || methodName == null) throw new NullPointerException("constructing JdiTestResult"); this.className = className; this.methodName = methodName; this.runTimeMs = runTimeMs; this.exceptionMsg = null; this.traceMsg = null; } public String getQualifiedClassName() { return className; } public String getMethodName() { return methodName; }
| @see bluej.debugger.DebuggerTestResult#getExceptionMessage() | public String getExceptionMessage() { throw new IllegalStateException("getting Exception message from successful test"); }
| | @see bluej.debugger.DebuggerTestResult#getRunTimeMs() | public int getRunTimeMs() { return runTimeMs; }
| | @see bluej.debugger.DebuggerTestResult#getTrace() | public String getTrace() { throw new IllegalStateException("getting stack trace from successful test"); }
| (non-Javadoc) | @see bluej.debugger.DebuggerTestResult#getExceptionLocation() | public SourceLocation getExceptionLocation() { throw new IllegalStateException("getting stack trace from successful test"); }
| (non-Javadoc) | @see bluej.debugger.DebuggerTestResult#isError() | public boolean isError() { return false; }
| (non-Javadoc) | @see bluej.debugger.DebuggerTestResult#isFailure() | public boolean isFailure() { return false; }
| (non-Javadoc) | @see bluej.debugger.DebuggerTestResult#isSuccess() | public boolean isSuccess() { return true; }
| Filters stack frames from internal JUnit classes | public static String getFilteredTrace(String stack) { String[] lines = Utility.splitLines(stack); int lastLine = lines.length - 1; while (lastLine >= 0) { if (filterLine(lines[lastLine])) { lastLine -= 1; } else { break; } } return Arrays.stream(lines, 0, lastLine + 1).collect(Collectors.joining("\n")); } p.public static boolean filterLine(String line) { String[] patterns= new String[] { "junit.framework.TestCase", "junit.framework.TestResult", "junit.framework.TestSuite", "junit.framework.Assert.", "junit.swingui.TestRunner", "junit.awtui.TestRunner", "junit.textui.TestRunner", "org.junit.runner", "org.junit.internal", "sun.reflect.", "jdk.internal.reflect.", "bluej.", "java.lang.reflect.Method.invoke(" }; for (int i= 0; i < patterns.length; i++) { if (line.indexOf(patterns[i]) > 0) return true; } return false; } }
top, use, map, class JdiTestResult

.   getQualifiedClassName
.   getMethodName
.   getExceptionMessage
.   getRunTimeMs
.   getTrace
.   getExceptionLocation
.   isError
.   isFailure
.   isSuccess
.   getFilteredTrace
.   filterLine




169 neLoCode + 13 LoComm