View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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 java.lang.ref.SoftReference;
16  
17  import com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcResponse;
18  import com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathsContainer;
19  import com.eviware.soapui.impl.wsdl.teststeps.actions.ShowMessageExchangeAction;
20  import com.eviware.soapui.model.ModelItem;
21  import com.eviware.soapui.model.iface.Attachment;
22  import com.eviware.soapui.model.iface.MessageExchange;
23  import com.eviware.soapui.model.iface.Operation;
24  import com.eviware.soapui.model.testsuite.AssertedXPath;
25  import com.eviware.soapui.support.action.swing.ActionList;
26  import com.eviware.soapui.support.types.StringToStringMap;
27  
28  public class JdbcTestStepResult extends WsdlTestStepResult implements AssertedXPathsContainer, MessageExchange
29  {
30  	private JdbcResponse response;
31  	private SoftReference<JdbcResponse> softResponse;
32  	private String requestContent;
33  	private boolean addedAction;
34  
35  	public JdbcTestStepResult( WsdlTestStep testStep )
36  	{
37  		super( testStep );
38  	}
39  
40  	public void setResponse( JdbcResponse response, boolean useSoftReference )
41  	{
42  		if( useSoftReference )
43  			this.softResponse = new SoftReference<JdbcResponse>( response );
44  		else
45  			this.response = response;
46  	}
47  
48  	public void setRequestContent( String requestContent )
49  	{
50  		this.requestContent = requestContent;
51  	}
52  
53  	public void addAssertedXPath( AssertedXPath assertedXPath )
54  	{
55  	}
56  	
57  	@Override
58  	public ActionList getActions()
59  	{
60  		if( !addedAction )
61  		{
62  			addAction( new ShowMessageExchangeAction( this, "TestStep" ), true );
63  			addedAction = true;
64  		}
65  
66  		return super.getActions();
67  	}
68  
69  	public ModelItem getModelItem()
70  	{
71  		return getTestStep();
72  	}
73  
74  	public Operation getOperation()
75  	{
76  		return null;
77  	}
78  
79  	public StringToStringMap getProperties()
80  	{
81  		return new StringToStringMap();
82  	}
83  
84  	public String getProperty( String name )
85  	{
86  		return null;
87  	}
88  
89  	public byte[] getRawRequestData()
90  	{
91  		return hasResponse() ? getResponse().getRequestContent().getBytes() : null;
92  	}
93  
94  	public byte[] getRawResponseData()
95  	{
96  		return getResponseContent().getBytes();
97  	}
98  
99  	public Attachment[] getRequestAttachments()
100 	{
101 		return new Attachment[0];
102 	}
103 
104 	public Attachment[] getRequestAttachmentsForPart( String partName )
105 	{
106 		return new Attachment[0];
107 	}
108 
109 	public String getRequestContent()
110 	{
111 		return requestContent != null ? requestContent : hasResponse() ? getResponse().getRequestContent() : null;
112 	}
113 
114 	public JdbcResponse getResponse()
115 	{
116 		return softResponse != null ? softResponse.get() : response;
117 	}
118 
119 	public String getRequestContentAsXml()
120 	{
121 		return null;
122 	}
123 
124 	public StringToStringMap getRequestHeaders()
125 	{
126 		return new StringToStringMap();
127 	}
128 
129 	public Attachment[] getResponseAttachments()
130 	{
131 		return new Attachment[0];
132 	}
133 
134 	public Attachment[] getResponseAttachmentsForPart( String partName )
135 	{
136 		return new Attachment[0];
137 	}
138 
139 	public String getResponseContent()
140 	{
141 		return hasResponse() ? getResponse().getContentAsString() : null;
142 	}
143 
144 	public String getResponseContentAsXml()
145 	{
146 		return getResponseContent();
147 	}
148 
149 	public StringToStringMap getResponseHeaders()
150 	{
151 		return new StringToStringMap();
152 	}
153 
154 	public long getTimestamp()
155 	{
156 		return hasResponse() ? getResponse().getTimestamp() : -1;
157 	}
158 
159 	public boolean hasRawData()
160 	{
161 		return true;
162 	}
163 
164 	public boolean hasRequest( boolean ignoreEmpty )
165 	{
166 		return hasResponse();
167 	}
168 
169 	public boolean hasResponse()
170 	{
171 		return getResponse() != null;
172 	}
173 
174 	public String getEndpoint()
175 	{
176 		// TODO Auto-generated method stub
177 		return null;
178 	}
179 
180 }