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.panels.teststeps;
14  
15  import java.sql.SQLException;
16  import java.sql.Statement;
17  
18  import javax.xml.parsers.ParserConfigurationException;
19  import javax.xml.transform.TransformerConfigurationException;
20  import javax.xml.transform.TransformerException;
21  
22  import com.eviware.soapui.model.support.AbstractResponse;
23  import com.eviware.soapui.support.xml.XmlUtils;
24  
25  public class JdbcResponse extends AbstractResponse<JdbcRequest>
26  {
27  	private String responseContent;
28  	private long timeTaken;
29  	private long timestamp;
30  	private final String rawSql;
31  
32  	public JdbcResponse( JdbcRequest request, Statement statement, String rawSql ) throws SQLException,
33  			ParserConfigurationException, TransformerConfigurationException, TransformerException
34  	{
35  		super( request );
36  		this.rawSql = rawSql;
37  
38  		responseContent = XmlUtils.createJdbcXmlResult( statement );
39  	}
40  
41  	public String getContentAsString()
42  	{
43  		return responseContent;
44  	}
45  
46  	public String getContentType()
47  	{
48  		return "text/xml";
49  	}
50  
51  	@Override
52  	public byte[] getRawRequestData()
53  	{
54  		return rawSql.getBytes();
55  	}
56  
57  	public String getRequestContent()
58  	{
59  		return getRequest().getTestStep().getQuery();
60  	}
61  
62  	public long getTimeTaken()
63  	{
64  		return timeTaken;
65  	}
66  
67  	public long getTimestamp()
68  	{
69  		return timestamp;
70  	}
71  
72  	public void setContentAsString( String xml )
73  	{
74  		responseContent = xml;
75  	}
76  
77  	public void setTimeTaken( long timeTaken )
78  	{
79  		this.timeTaken = timeTaken;
80  	}
81  
82  	public void setTimestamp( long timestamp )
83  	{
84  		this.timestamp = timestamp;
85  	}
86  }