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  
31  	public JdbcResponse( JdbcRequest request, Statement statement ) throws SQLException, ParserConfigurationException, TransformerConfigurationException, TransformerException
32  	{
33  		super( request );
34  		
35  		org.w3c.dom.Document xmlDocumentResult = XmlUtils.createJdbcXmlResult( statement );
36  		responseContent = XmlUtils.serializePretty( xmlDocumentResult );
37  	}
38  
39  	public String getContentAsString()
40  	{
41  		return responseContent;
42  	}
43  
44  	public String getContentType()
45  	{
46  		return "text/xml";
47  	}
48  
49  	public String getRequestContent()
50  	{
51  		return getRequest().getTestStep().getQuery();
52  	}
53  
54  	public long getTimeTaken()
55  	{
56  		return timeTaken;
57  	}
58  
59  	public long getTimestamp()
60  	{
61  		return timestamp;
62  	}
63  
64  	public void setContentAsString( String xml )
65  	{
66  		responseContent = xml;
67  	}
68  
69  	public void setTimeTaken( long timeTaken )
70  	{
71  		this.timeTaken = timeTaken;
72  	}
73  
74  	public void setTimestamp( long timestamp )
75  	{
76  		this.timestamp = timestamp;
77  	}
78  }