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 WsdlRequest getRequest()
    41     {
    42        return request;
    43     }
    44
    45     public WsdlResponse getResponse()
    46     {
    47        return response;
    48     }
    49
    50  	public void setResponse( WsdlResponse response )
    51  	{
    52  		this.response = response;
    53  	}
    54
    55  	public String getRequestContent()
    56  	{
    57  		if( requestContent != null )
    58  			return requestContent;
    59
    60  		if( response == null )
    61  			response = request.getResponse();
    62
    63  		return response == null ? request.getRequestContent() : response.getRequestContent();
    64  	}
    65
    66  	public StringToStringMap getRequestHeaders()
    67  	{
    68  		return response == null ? request.getRequestHeaders() : response.getRequestHeaders();
    69  	}
    70
    71  	public Attachment[] getRequestAttachments()
    72  	{
    73  		return request.getAttachments();
    74  	}
    75
    76  	public Attachment[] getResponseAttachments()
    77  	{
    78  		if( response == null )
    79  			response = request.getResponse();
    80
    81  		return response == null ? null : response.getAttachments();
    82  	}
    83
    84  	public String getResponseContent()
    85  	{
    86  		if( response == null )
    87  			response = request.getResponse();
    88
    89  		return response == null ? null : response.getContentAsString();
    90  	}
    91
    92  	public StringToStringMap getResponseHeaders()
    93  	{
    94  		if( response == null )
    95  			response = request.getResponse();
    96
    97  		return response == null ? null : response.getResponseHeaders();
    98  	}
    99
    100 	public WsdlOperation getOperation()
    101 	{
    102 		return request.getOperation();
    103 	}
    104
    105 	public long getTimeTaken()
    106 	{
    107 		if( response == null )
    108 			response = request.getResponse();
    109
    110 		return response == null ? 0 : response.getTimeTaken();
    111 	}
    112
    113 	public long getTimestamp()
    114 	{
    115 		if( response == null )
    116 			response = request.getResponse();
    117
    118 		return response == null ? 0 : response.getTimestamp();
    119 	}
    120
    121 	public void setRequestContent( String requestContent )
    122 	{
    123 		this.requestContent = requestContent;
    124 	}
    125 }