Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PojoStackTraceWriter |
|
| 1.2;1,2 |
1 | package org.apache.maven.surefire.report; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | ||
23 | import java.io.PrintWriter; | |
24 | import java.io.StringWriter; | |
25 | ||
26 | /** | |
27 | * Write the trace out for a POJO test. | |
28 | * | |
29 | * @author <a href="mailto:brett@apache.org">Brett Porter</a> | |
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 | 1 | { |
42 | 1 | this.testClass = testClass; |
43 | 1 | this.testMethod = testMethod; |
44 | 1 | this.t = t; |
45 | 1 | } |
46 | ||
47 | public String writeTraceToString() | |
48 | { | |
49 | 0 | StringWriter w = new StringWriter(); |
50 | 0 | if ( t != null ) |
51 | { | |
52 | 0 | t.printStackTrace( new PrintWriter( w ) ); |
53 | 0 | w.flush(); |
54 | } | |
55 | 0 | return w.toString(); |
56 | } | |
57 | ||
58 | public String smartTrimmedStackTrace() | |
59 | { | |
60 | 0 | SmartStackTraceParser parser = new SmartStackTraceParser( testClass, t, testMethod ); |
61 | 0 | return parser.getString(); |
62 | } | |
63 | ||
64 | public String writeTrimmedTraceToString() | |
65 | { | |
66 | 1 | return SmartStackTraceParser.innerMostWithFocusOnClass( t, testClass ); |
67 | } | |
68 | ||
69 | public SafeThrowable getThrowable() | |
70 | { | |
71 | 0 | return new SafeThrowable( t ); |
72 | } | |
73 | } |