View Javadoc

    1   /*
    2    *  soapUI, copyright (C) 2004-2007 eviware.com
    3    *
    4    *  soapUI is free software; you can redistribute it and/or modify it under the
    5    *  terms of version 2.1 of the GNU Lesser General Public License as published by
    6    *  the Free Software Foundation.
    7    *
    8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
    9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    10   *  See the GNU Lesser General Public License for more details at gnu.org.
    11   */
    12
    13  package com.eviware.soapui.impl.wsdl.teststeps;
    14
    15  import com.eviware.soapui.impl.wsdl.WsdlOperation;
    16  import com.eviware.soapui.impl.wsdl.WsdlRequest;
    17  import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
    18  import com.eviware.soapui.impl.wsdl.submit.transports.http.WsdlResponse;
    19  import com.eviware.soapui.model.iface.Attachment;
    20  import com.eviware.soapui.support.types.StringToStringMap;
    21
    22  /***
    23   * WsdlMessageExchange for a WsdlRequest and its response
    24   *
    25   * @author ole.matzura
    26   */
    27
    28  public class WsdlResponseMessageExchange extends WsdlMessageExchange
    29  {
    30  	private final WsdlRequest request;
    31  	private WsdlResponse response;
    32  	private String requestContent;
    33
    34  	public WsdlResponseMessageExchange( WsdlRequest request )
    35  	{
    36  		this.request = request;
    37  		response = request.getResponse();
    38  	}
    39
    40  	public void setResponse( WsdlResponse response )
    41  	{
    42  		this.response = response;
    43  	}
    44
    45  	public String getRequestContent()
    46  	{
    47  		if( requestContent != null )
    48  			return requestContent;
    49
    50  		if( response == null )
    51  			response = request.getResponse();
    52
    53  		return response == null ? request.getRequestContent() : response.getRequestContent();
    54  	}
    55
    56  	public StringToStringMap getRequestHeaders()
    57  	{
    58  		if( response == null )
    59  			response = request.getResponse();
    60
    61  		return response == null ? request.getRequestHeaders() : response.getRequestHeaders();
    62  	}
    63
    64  	public Attachment[] getRequestAttachments()
    65  	{
    66  		return request.getAttachments();
    67  	}
    68
    69  	public Attachment[] getResponseAttachments()
    70  	{
    71  		if( response == null )
    72  			response = request.getResponse();
    73
    74  		return response == null ? null : response.getAttachments();
    75  	}
    76
    77  	public String getResponseContent()
    78  	{
    79  		if( response == null )
    80  			response = request.getResponse();
    81
    82  		return response == null ? null : response.getContentAsString();
    83  	}
    84
    85  	public StringToStringMap getResponseHeaders()
    86  	{
    87  		if( response == null )
    88  			response = request.getResponse();
    89
    90  		return response == null ? null : response.getResponseHeaders();
    91  	}
    92
    93  	public WsdlOperation getOperation()
    94  	{
    95  		return request.getOperation();
    96  	}
    97
    98  	public long getTimeTaken()
    99  	{
    100 		if( response == null )
    101 			response = request.getResponse();
    102
    103 		return response == null ? 0 : response.getTimeTaken();
    104 	}
    105
    106 	public long getTimestamp()
    107 	{
    108 		if( response == null )
    109 			response = request.getResponse();
    110
    111 		return response == null ? 0 : response.getTimestamp();
    112 	}
    113
    114 	public void setRequestContent( String requestContent )
    115 	{
    116 		this.requestContent = requestContent;
    117 	}
    118 }