1 package org.apache.maven.surefire.booter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.surefire.report.ReporterConfiguration;
23 import org.apache.maven.surefire.util.internal.DumpFileUtils;
24
25 import java.io.File;
26
27 import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
28
29
30
31
32
33
34
35
36 public final class DumpErrorSingleton
37 {
38 public static final String DUMP_FILE_EXT = ".dump";
39 public static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
40 private static final DumpErrorSingleton SINGLETON = new DumpErrorSingleton();
41
42 private File dumpFile;
43 private File dumpStreamFile;
44
45 private DumpErrorSingleton()
46 {
47 }
48
49 public static DumpErrorSingleton getSingleton()
50 {
51 return SINGLETON;
52 }
53
54 public synchronized void init( String dumpFileName, ReporterConfiguration configuration )
55 {
56 dumpFile = createDumpFile( dumpFileName, configuration );
57 dumpStreamFile = createDumpStreamFile( dumpFileName, configuration );
58 }
59
60 public synchronized void dumpException( Throwable t, String msg )
61 {
62 DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpFile );
63 }
64
65 public synchronized void dumpException( Throwable t )
66 {
67 DumpFileUtils.dumpException( t, dumpFile );
68 }
69
70 public synchronized void dumpText( String msg )
71 {
72 DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpFile );
73 }
74
75 public synchronized void dumpStreamException( Throwable t, String msg )
76 {
77 DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpStreamFile );
78 }
79
80 public synchronized void dumpStreamException( Throwable t )
81 {
82 DumpFileUtils.dumpException( t, dumpStreamFile );
83 }
84
85 public synchronized void dumpStreamText( String msg )
86 {
87 DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpStreamFile );
88 }
89
90 private File createDumpFile( String dumpFileName, ReporterConfiguration configuration )
91 {
92 return newDumpFile( dumpFileName + DUMP_FILE_EXT, configuration );
93 }
94
95 private File createDumpStreamFile( String dumpFileName, ReporterConfiguration configuration )
96 {
97 return newDumpFile( dumpFileName + DUMPSTREAM_FILE_EXT, configuration );
98 }
99 }