001: /*
002: * soapUI, copyright (C) 2004-2007 eviware.com
003: *
004: * soapUI is free software; you can redistribute it and/or modify it under the
005: * terms of version 2.1 of the GNU Lesser General Public License as published by
006: * the Free Software Foundation.
007: *
008: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: * See the GNU Lesser General Public License for more details at gnu.org.
011: */
012:
013: package com.eviware.soapui.impl.wsdl.loadtest.log;
014:
015: import java.io.IOException;
016: import java.io.PrintWriter;
017: import java.util.Date;
018:
019: import javax.swing.ImageIcon;
020:
021: import com.eviware.soapui.model.testsuite.TestStep;
022: import com.eviware.soapui.model.testsuite.TestStepResult;
023: import com.eviware.soapui.support.action.swing.ActionList;
024:
025: /**
026: * An error entry in the LoadTest Log
027: *
028: * @author Ole.Matzura
029: */
030:
031: public class LoadTestLogErrorEntry implements LoadTestLogEntry {
032: private final String error;
033: private TestStepResult result;
034: private String type;
035: private ImageIcon icon;
036: private long timestamp;
037:
038: public LoadTestLogErrorEntry(String type, String error,
039: TestStepResult result, ImageIcon icon) {
040: this .icon = icon;
041: this .type = type;
042: this .error = error;
043: this .result = result;
044:
045: timestamp = result == null ? System.currentTimeMillis()
046: : result.getTimeStamp();
047: }
048:
049: public LoadTestLogErrorEntry(String type, String message,
050: ImageIcon icon) {
051: this .type = type;
052: this .error = message;
053: this .icon = icon;
054:
055: timestamp = System.currentTimeMillis();
056: }
057:
058: public String getMessage() {
059: return error;
060: }
061:
062: public TestStepResult getTestStepResult() {
063: return result;
064: }
065:
066: public long getTimeStamp() {
067: return timestamp;
068: }
069:
070: public TestStep getTargetStep() {
071: return result == null ? null : result.getTestStep();
072: }
073:
074: public ImageIcon getIcon() {
075: return icon;
076: }
077:
078: public String getType() {
079: return type;
080: }
081:
082: public boolean isError() {
083: return true;
084: }
085:
086: public ActionList getActions() {
087: return result == null ? null : result.getActions();
088: }
089:
090: public void exportToFile(String fileName) throws IOException {
091: PrintWriter writer = new PrintWriter(fileName);
092:
093: writer.write(new Date(timestamp).toString());
094: writer.write(":");
095: writer.write(error);
096: writer.println();
097: if (result != null) {
098: writer
099: .println("----------------------------------------------------");
100: result.writeTo(writer);
101: }
102:
103: writer.close();
104: }
105: }
|