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.panels.mockoperation;
14  
15  import java.util.Vector;
16  
17  import com.eviware.soapui.impl.wsdl.WsdlOperation;
18  import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
19  import com.eviware.soapui.impl.wsdl.mock.WsdlMockResult;
20  import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
21  import com.eviware.soapui.model.ModelItem;
22  import com.eviware.soapui.model.iface.Attachment;
23  import com.eviware.soapui.support.types.StringToStringMap;
24  
25  /***
26   * WsdlMessageExchange for a WsdlMockResult, required for validations
27   * 
28   * @author ole.matzura
29   */
30  
31  public class WsdlMockResultMessageExchange extends WsdlMessageExchange
32  {
33  	private final WsdlMockResult mockResult;
34  	private WsdlMockResponse mockResponse;
35  
36  	public WsdlMockResultMessageExchange( WsdlMockResult mockResult, WsdlMockResponse mockResponse )
37  	{
38  		this.mockResult = mockResult;
39  		this.mockResponse = mockResponse;
40  	}
41  
42  	public ModelItem getModelItem()
43  	{
44  		return mockResponse;
45  	}
46  
47  	public Attachment[] getRequestAttachments()
48  	{
49  		return mockResult.getMockRequest().getRequestAttachments();
50  	}
51  
52  	public String getRequestContent()
53  	{
54  		if( mockResult == null || mockResult.getMockRequest() == null )
55  			return null;
56  
57  		return mockResult.getMockRequest().getRequestContent();
58  	}
59  
60  	public StringToStringMap getRequestHeaders()
61  	{
62  		return mockResult == null ? null : mockResult.getMockRequest().getRequestHeaders();
63  	}
64  
65  	public Attachment[] getResponseAttachments()
66  	{
67  		return mockResult == null ? null : mockResult.getMockResponse().getAttachments();
68  	}
69  
70  	public String getResponseContent()
71  	{
72  		return mockResult == null ? null : mockResult.getResponseContent();
73  	}
74  
75  	public StringToStringMap getResponseHeaders()
76  	{
77  		return mockResult == null ? null : mockResult.getResponseHeaders();
78  	}
79  
80  	public WsdlOperation getOperation()
81  	{
82  		return mockResponse == null ? null : mockResponse.getMockOperation().getOperation();
83  	}
84  
85  	public long getTimeTaken()
86  	{
87  		return mockResult == null ? -1 : mockResult.getTimeTaken();
88  	}
89  
90  	public long getTimestamp()
91  	{
92  		return mockResult == null ? -1 : mockResult.getTimestamp();
93  	}
94  
95  	public boolean isDiscarded()
96  	{
97  		return mockResponse == null;
98  	}
99  
100 	public void discard()
101 	{
102 		mockResponse = null;
103 	}
104 	
105 	public Vector getRequestWssResult()
106 	{
107 		return mockResult == null ? null : mockResult.getRequestWssResult();
108 	}
109 
110 	public Vector getResponseWssResult()
111 	{
112 		return null;
113 	}
114 }