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 com.eviware.soapui.impl.wsdl.WsdlOperation;
016: import com.eviware.soapui.impl.wsdl.WsdlRequest;
017: import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
018: import com.eviware.soapui.impl.wsdl.submit.transports.http.WsdlResponse;
019: import com.eviware.soapui.model.iface.Attachment;
020: import com.eviware.soapui.support.types.StringToStringMap;
021:
022: /**
023: * WsdlMessageExchange for a WsdlRequest and its response
024: *
025: * @author ole.matzura
026: */
027:
028: public class WsdlResponseMessageExchange extends WsdlMessageExchange {
029: private final WsdlRequest request;
030: private WsdlResponse response;
031: private String requestContent;
032:
033: public WsdlResponseMessageExchange(WsdlRequest request) {
034: this .request = request;
035: response = request.getResponse();
036: }
037:
038: public void setResponse(WsdlResponse response) {
039: this .response = response;
040: }
041:
042: public String getRequestContent() {
043: if (requestContent != null)
044: return requestContent;
045:
046: if (response == null)
047: response = request.getResponse();
048:
049: return response == null ? request.getRequestContent()
050: : response.getRequestContent();
051: }
052:
053: public StringToStringMap getRequestHeaders() {
054: if (response == null)
055: response = request.getResponse();
056:
057: return response == null ? request.getRequestHeaders()
058: : response.getRequestHeaders();
059: }
060:
061: public Attachment[] getRequestAttachments() {
062: return request.getAttachments();
063: }
064:
065: public Attachment[] getResponseAttachments() {
066: if (response == null)
067: response = request.getResponse();
068:
069: return response == null ? null : response.getAttachments();
070: }
071:
072: public String getResponseContent() {
073: if (response == null)
074: response = request.getResponse();
075:
076: return response == null ? null : response.getContentAsString();
077: }
078:
079: public StringToStringMap getResponseHeaders() {
080: if (response == null)
081: response = request.getResponse();
082:
083: return response == null ? null : response.getResponseHeaders();
084: }
085:
086: public WsdlOperation getOperation() {
087: return request.getOperation();
088: }
089:
090: public long getTimeTaken() {
091: if (response == null)
092: response = request.getResponse();
093:
094: return response == null ? 0 : response.getTimeTaken();
095: }
096:
097: public long getTimestamp() {
098: if (response == null)
099: response = request.getResponse();
100:
101: return response == null ? 0 : response.getTimestamp();
102: }
103:
104: public void setRequestContent(String requestContent) {
105: this.requestContent = requestContent;
106: }
107: }
|