1 package net.jaekl.squelch.db;
5 import java.sql.CallableStatement;
7 import java.sql.Connection;
8 import java.sql.DatabaseMetaData;
10 import java.sql.PreparedStatement;
11 import java.sql.SQLClientInfoException;
12 import java.sql.SQLException;
13 import java.sql.SQLWarning;
14 import java.sql.SQLXML;
15 import java.sql.Savepoint;
16 import java.sql.Statement;
17 import java.sql.Struct;
18 import java.util.ArrayList;
20 import java.util.Properties;
21 import java.util.concurrent.Executor;
23 public class ConnectionMock implements Connection {
24 private ArrayList<String> m_executedQueries;
26 public ConnectionMock() {
27 m_executedQueries = new ArrayList<String>();
30 public ResultSetMock mock_executeQuery(PreparedStatementMock psm)
32 m_executedQueries.add(psm.toString());
33 return new ResultSetMock();
36 public boolean mock_queryWasExecuted(String sql) {
37 // There's an assumption here that we don't try a large number of queries in a single test.
38 // If that assumption is false, then we should change this to be more efficient.
39 return m_executedQueries.contains(sql);
43 public boolean isWrapperFor(Class<?> arg0) throws SQLException {
44 // TODO Auto-generated method stub
49 public <T> T unwrap(Class<T> arg0) throws SQLException {
50 // TODO Auto-generated method stub
55 public void abort(Executor executor) throws SQLException {
56 // TODO Auto-generated method stub
61 public void clearWarnings() throws SQLException {
62 // TODO Auto-generated method stub
67 public void close() throws SQLException {
68 // TODO Auto-generated method stub
73 public void commit() throws SQLException {
74 // TODO Auto-generated method stub
79 public Array createArrayOf(String typeName, Object[] elements)
81 // TODO Auto-generated method stub
86 public Blob createBlob() throws SQLException {
87 // TODO Auto-generated method stub
92 public Clob createClob() throws SQLException {
93 // TODO Auto-generated method stub
98 public NClob createNClob() throws SQLException {
99 // TODO Auto-generated method stub
104 public SQLXML createSQLXML() throws SQLException {
105 // TODO Auto-generated method stub
110 public Statement createStatement() throws SQLException {
111 // TODO Auto-generated method stub
116 public Statement createStatement(int resultSetType, int resultSetConcurrency)
117 throws SQLException {
118 // TODO Auto-generated method stub
123 public Statement createStatement(int resultSetType,
124 int resultSetConcurrency, int resultSetHoldability)
125 throws SQLException {
126 // TODO Auto-generated method stub
131 public Struct createStruct(String typeName, Object[] attributes)
132 throws SQLException {
133 // TODO Auto-generated method stub
138 public boolean getAutoCommit() throws SQLException {
139 // TODO Auto-generated method stub
144 public String getCatalog() throws SQLException {
145 // TODO Auto-generated method stub
150 public Properties getClientInfo() throws SQLException {
151 // TODO Auto-generated method stub
156 public String getClientInfo(String name) throws SQLException {
157 // TODO Auto-generated method stub
162 public int getHoldability() throws SQLException {
163 // TODO Auto-generated method stub
168 public DatabaseMetaData getMetaData() throws SQLException {
169 DatabaseMetaData result = new DatabaseMetaDataMock();
174 public int getNetworkTimeout() throws SQLException {
175 // TODO Auto-generated method stub
180 public String getSchema() throws SQLException {
181 // TODO Auto-generated method stub
186 public int getTransactionIsolation() throws SQLException {
187 // TODO Auto-generated method stub
192 public Map<String, Class<?>> getTypeMap() throws SQLException {
193 // TODO Auto-generated method stub
198 public SQLWarning getWarnings() throws SQLException {
199 // TODO Auto-generated method stub
204 public boolean isClosed() throws SQLException {
205 // TODO Auto-generated method stub
210 public boolean isReadOnly() throws SQLException {
211 // TODO Auto-generated method stub
216 public boolean isValid(int timeout) throws SQLException {
217 // TODO Auto-generated method stub
222 public String nativeSQL(String sql) throws SQLException {
223 // TODO Auto-generated method stub
228 public CallableStatement prepareCall(String sql) throws SQLException {
229 // TODO Auto-generated method stub
234 public CallableStatement prepareCall(String sql, int resultSetType,
235 int resultSetConcurrency) throws SQLException {
236 // TODO Auto-generated method stub
241 public CallableStatement prepareCall(String sql, int resultSetType,
242 int resultSetConcurrency, int resultSetHoldability)
243 throws SQLException {
244 // TODO Auto-generated method stub
249 public PreparedStatement prepareStatement(String sql) throws SQLException {
250 return new PreparedStatementMock(this, sql);
254 public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
255 throws SQLException {
256 // TODO Auto-generated method stub
261 public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
262 throws SQLException {
263 // TODO Auto-generated method stub
268 public PreparedStatement prepareStatement(String sql, String[] columnNames)
269 throws SQLException {
270 // TODO Auto-generated method stub
275 public PreparedStatement prepareStatement(String sql, int resultSetType,
276 int resultSetConcurrency) throws SQLException {
277 // TODO Auto-generated method stub
282 public PreparedStatement prepareStatement(String sql, int resultSetType,
283 int resultSetConcurrency, int resultSetHoldability)
284 throws SQLException {
285 // TODO Auto-generated method stub
290 public void releaseSavepoint(Savepoint savepoint) throws SQLException {
291 // TODO Auto-generated method stub
296 public void rollback() throws SQLException {
297 // TODO Auto-generated method stub
302 public void rollback(Savepoint savepoint) throws SQLException {
303 // TODO Auto-generated method stub
308 public void setAutoCommit(boolean autoCommit) throws SQLException {
309 // TODO Auto-generated method stub
314 public void setCatalog(String catalog) throws SQLException {
315 // TODO Auto-generated method stub
320 public void setClientInfo(Properties properties)
321 throws SQLClientInfoException {
322 // TODO Auto-generated method stub
327 public void setClientInfo(String name, String value)
328 throws SQLClientInfoException {
329 // TODO Auto-generated method stub
334 public void setHoldability(int holdability) throws SQLException {
335 // TODO Auto-generated method stub
340 public void setNetworkTimeout(Executor executor, int milliseconds)
341 throws SQLException {
342 // TODO Auto-generated method stub
347 public void setReadOnly(boolean readOnly) throws SQLException {
348 // TODO Auto-generated method stub
353 public Savepoint setSavepoint() throws SQLException {
354 // TODO Auto-generated method stub
359 public Savepoint setSavepoint(String name) throws SQLException {
360 // TODO Auto-generated method stub
365 public void setSchema(String schema) throws SQLException {
366 // TODO Auto-generated method stub
371 public void setTransactionIsolation(int level) throws SQLException {
372 // TODO Auto-generated method stub
377 public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
378 // TODO Auto-generated method stub