1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.loadtest.log;
14
15 import java.io.IOException;
16 import java.io.PrintWriter;
17 import java.util.Date;
18
19 import javax.swing.ImageIcon;
20
21 import com.eviware.soapui.model.testsuite.TestStep;
22 import com.eviware.soapui.model.testsuite.TestStepResult;
23 import com.eviware.soapui.support.action.swing.ActionList;
24
25 /***
26 * An error entry in the LoadTest Log
27 *
28 * @author Ole.Matzura
29 */
30
31 public class LoadTestLogErrorEntry implements LoadTestLogEntry
32 {
33 private final String error;
34 private TestStepResult result;
35 private String type;
36 private ImageIcon icon;
37 private long timestamp;
38
39 public LoadTestLogErrorEntry( String type, String error, TestStepResult result, ImageIcon icon)
40 {
41 this.icon = icon;
42 this.type = type;
43 this.error = error;
44 this.result = result;
45
46 timestamp = result == null ? System.currentTimeMillis() : result.getTimeStamp();
47 }
48
49 public LoadTestLogErrorEntry(String type, String message, ImageIcon icon)
50 {
51 this.type = type;
52 this.error = message;
53 this.icon = icon;
54
55 timestamp = System.currentTimeMillis();
56 }
57
58 public String getMessage()
59 {
60 return error;
61 }
62
63 public TestStepResult getTestStepResult()
64 {
65 return result;
66 }
67
68 public long getTimeStamp()
69 {
70 return timestamp;
71 }
72
73 public TestStep getTargetStep()
74 {
75 return result == null ? null : result.getTestStep();
76 }
77
78 public ImageIcon getIcon()
79 {
80 return icon;
81 }
82
83 public String getType()
84 {
85 return type;
86 }
87
88 public boolean isError()
89 {
90 return true;
91 }
92
93 public ActionList getActions()
94 {
95 return result == null ? null : result.getActions();
96 }
97
98 public void exportToFile(String fileName) throws IOException
99 {
100 PrintWriter writer = new PrintWriter(fileName );
101
102 writer.write( new Date( timestamp ).toString() );
103 writer.write( ":" );
104 writer.write( error );
105 writer.println();
106 if( result != null )
107 {
108 writer.println( "----------------------------------------------------" );
109 result.writeTo( writer );
110 }
111
112 writer.close();
113 }
114 }