1 package org.apache.maven.surefire.report;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import java.io.PrintWriter;
24 import java.io.StringWriter;
25
26
27
28
29
30
31 public class PojoStackTraceWriter
32 implements StackTraceWriter
33 {
34 private final Throwable t;
35
36 protected final String testClass;
37
38 protected final String testMethod;
39
40 public PojoStackTraceWriter( String testClass, String testMethod, Throwable t )
41 {
42 this.testClass = testClass;
43 this.testMethod = testMethod;
44 this.t = t;
45 }
46
47 public String writeTraceToString()
48 {
49 StringWriter w = new StringWriter();
50 if ( t != null )
51 {
52 t.printStackTrace( new PrintWriter( w ) );
53 w.flush();
54 }
55 return w.toString();
56 }
57
58 public String smartTrimmedStackTrace()
59 {
60 SmartStackTraceParser parser = new SmartStackTraceParser( testClass, t, testMethod );
61 return parser.getString();
62 }
63
64 public String writeTrimmedTraceToString()
65 {
66 return SmartStackTraceParser.innerMostWithFocusOnClass( t, testClass );
67 }
68
69 public SafeThrowable getThrowable()
70 {
71 return new SafeThrowable( t );
72 }
73 }