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.teststeps;
014:
015: import java.io.PrintWriter;
016:
017: import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
018: import com.eviware.soapui.impl.wsdl.teststeps.actions.ShowMessageExchangeAction;
019: import com.eviware.soapui.support.types.StringToStringMap;
020: import com.eviware.soapui.support.xml.XmlUtils;
021:
022: /**
023: * TestStep Result for a WsdlMessageExchange
024: *
025: * @author ole.matzura
026: */
027:
028: public class WsdlMessageExchangeStepResult extends WsdlTestStepResult {
029: private WsdlMessageExchange messageExchange;
030: private StringToStringMap properties;
031:
032: public WsdlMessageExchangeStepResult(WsdlTestStep step) {
033: super (step);
034: }
035:
036: public void setMessageExchange(WsdlMessageExchange messageExchange) {
037: this .messageExchange = messageExchange;
038: addAction(new ShowMessageExchangeAction(messageExchange,
039: "StepResult"), true);
040: }
041:
042: public String getRequestContent() {
043: if (isDiscarded())
044: return "<discarded>";
045:
046: return messageExchange == null ? null : messageExchange
047: .getRequestContent();
048: }
049:
050: public void addProperty(String name, String value) {
051: if (isDiscarded())
052: return;
053:
054: if (properties == null)
055: properties = new StringToStringMap();
056:
057: properties.put(name, value);
058: }
059:
060: public void discard() {
061: super .discard();
062:
063: messageExchange = null;
064: properties = null;
065: }
066:
067: public void writeTo(PrintWriter writer) {
068: super .writeTo(writer);
069:
070: if (isDiscarded())
071: return;
072:
073: writer
074: .println("---------------- Properties ------------------------");
075: if (properties == null) {
076: writer.println("Missing Properties");
077: } else {
078: for (String name : properties.keySet())
079: writer.println(name + ": " + properties.get(name));
080: }
081:
082: writer
083: .println("---------------- Message Exchange ------------------");
084: if (messageExchange == null) {
085: writer.println("Missing MessageExchange");
086: } else {
087: writer.println("--- Request");
088: if (messageExchange.getRequestHeaders() != null)
089: writer.println("Request Headers: "
090: + messageExchange.getRequestHeaders()
091: .toString());
092:
093: writer.println(XmlUtils.prettyPrintXml(messageExchange
094: .getRequestContent()));
095:
096: writer.println("--- Response");
097: if (messageExchange.getResponseHeaders() != null)
098: writer.println("Response Headers: "
099: + messageExchange.getResponseHeaders()
100: .toString());
101:
102: writer.println(XmlUtils.prettyPrintXml(messageExchange
103: .getResponseContent()));
104: }
105: }
106:
107: public StringToStringMap getProperties() {
108: return properties;
109: }
110: }
|