Add DbDriver, with support for a few popular JDBC drivers.
[squelch.git] / src / test / java / net / jaekl / squelch / db / ConnectionMock.java
1 package net.jaekl.squelch.db;
2
3 import java.sql.Array;
4 import java.sql.Blob;
5 import java.sql.CallableStatement;
6 import java.sql.Clob;
7 import java.sql.Connection;
8 import java.sql.DatabaseMetaData;
9 import java.sql.NClob;
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;
19 import java.util.Map;
20 import java.util.Properties;
21 import java.util.concurrent.Executor;
22
23 public class ConnectionMock implements Connection {
24         private ArrayList<String> m_executedQueries;
25         
26         public ConnectionMock() {
27                 m_executedQueries = new ArrayList<String>();
28         }
29         
30         public ResultSetMock mock_executeQuery(PreparedStatementMock psm)
31         {
32                 m_executedQueries.add(psm.toString());
33                 return new ResultSetMock();
34         }
35         
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);
40         }
41
42         @Override
43         public boolean isWrapperFor(Class<?> arg0) throws SQLException {
44                 // TODO Auto-generated method stub
45                 return false;
46         }
47
48         @Override
49         public <T> T unwrap(Class<T> arg0) throws SQLException {
50                 // TODO Auto-generated method stub
51                 return null;
52         }
53
54         @Override
55         public void abort(Executor executor) throws SQLException {
56                 // TODO Auto-generated method stub
57
58         }
59
60         @Override
61         public void clearWarnings() throws SQLException {
62                 // TODO Auto-generated method stub
63
64         }
65
66         @Override
67         public void close() throws SQLException {
68                 // TODO Auto-generated method stub
69
70         }
71
72         @Override
73         public void commit() throws SQLException {
74                 // TODO Auto-generated method stub
75
76         }
77
78         @Override
79         public Array createArrayOf(String typeName, Object[] elements)
80                         throws SQLException {
81                 // TODO Auto-generated method stub
82                 return null;
83         }
84
85         @Override
86         public Blob createBlob() throws SQLException {
87                 // TODO Auto-generated method stub
88                 return null;
89         }
90
91         @Override
92         public Clob createClob() throws SQLException {
93                 // TODO Auto-generated method stub
94                 return null;
95         }
96
97         @Override
98         public NClob createNClob() throws SQLException {
99                 // TODO Auto-generated method stub
100                 return null;
101         }
102
103         @Override
104         public SQLXML createSQLXML() throws SQLException {
105                 // TODO Auto-generated method stub
106                 return null;
107         }
108
109         @Override
110         public Statement createStatement() throws SQLException {
111                 // TODO Auto-generated method stub
112                 return null;
113         }
114
115         @Override
116         public Statement createStatement(int resultSetType, int resultSetConcurrency)
117                         throws SQLException {
118                 // TODO Auto-generated method stub
119                 return null;
120         }
121
122         @Override
123         public Statement createStatement(int resultSetType,
124                         int resultSetConcurrency, int resultSetHoldability)
125                         throws SQLException {
126                 // TODO Auto-generated method stub
127                 return null;
128         }
129
130         @Override
131         public Struct createStruct(String typeName, Object[] attributes)
132                         throws SQLException {
133                 // TODO Auto-generated method stub
134                 return null;
135         }
136
137         @Override
138         public boolean getAutoCommit() throws SQLException {
139                 // TODO Auto-generated method stub
140                 return false;
141         }
142
143         @Override
144         public String getCatalog() throws SQLException {
145                 // TODO Auto-generated method stub
146                 return null;
147         }
148
149         @Override
150         public Properties getClientInfo() throws SQLException {
151                 // TODO Auto-generated method stub
152                 return null;
153         }
154
155         @Override
156         public String getClientInfo(String name) throws SQLException {
157                 // TODO Auto-generated method stub
158                 return null;
159         }
160
161         @Override
162         public int getHoldability() throws SQLException {
163                 // TODO Auto-generated method stub
164                 return 0;
165         }
166
167         @Override
168         public DatabaseMetaData getMetaData() throws SQLException {
169                 DatabaseMetaData result = new DatabaseMetaDataMock();
170                 return result;
171         }
172
173         @Override
174         public int getNetworkTimeout() throws SQLException {
175                 // TODO Auto-generated method stub
176                 return 0;
177         }
178
179         @Override
180         public String getSchema() throws SQLException {
181                 // TODO Auto-generated method stub
182                 return null;
183         }
184
185         @Override
186         public int getTransactionIsolation() throws SQLException {
187                 // TODO Auto-generated method stub
188                 return 0;
189         }
190
191         @Override
192         public Map<String, Class<?>> getTypeMap() throws SQLException {
193                 // TODO Auto-generated method stub
194                 return null;
195         }
196
197         @Override
198         public SQLWarning getWarnings() throws SQLException {
199                 // TODO Auto-generated method stub
200                 return null;
201         }
202
203         @Override
204         public boolean isClosed() throws SQLException {
205                 // TODO Auto-generated method stub
206                 return false;
207         }
208
209         @Override
210         public boolean isReadOnly() throws SQLException {
211                 // TODO Auto-generated method stub
212                 return false;
213         }
214
215         @Override
216         public boolean isValid(int timeout) throws SQLException {
217                 // TODO Auto-generated method stub
218                 return false;
219         }
220
221         @Override
222         public String nativeSQL(String sql) throws SQLException {
223                 // TODO Auto-generated method stub
224                 return null;
225         }
226
227         @Override
228         public CallableStatement prepareCall(String sql) throws SQLException {
229                 // TODO Auto-generated method stub
230                 return null;
231         }
232
233         @Override
234         public CallableStatement prepareCall(String sql, int resultSetType,
235                         int resultSetConcurrency) throws SQLException {
236                 // TODO Auto-generated method stub
237                 return null;
238         }
239
240         @Override
241         public CallableStatement prepareCall(String sql, int resultSetType,
242                         int resultSetConcurrency, int resultSetHoldability)
243                         throws SQLException {
244                 // TODO Auto-generated method stub
245                 return null;
246         }
247
248         @Override
249         public PreparedStatement prepareStatement(String sql) throws SQLException {
250                 return new PreparedStatementMock(this, sql);
251         }
252
253         @Override
254         public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
255                         throws SQLException {
256                 // TODO Auto-generated method stub
257                 return null;
258         }
259
260         @Override
261         public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
262                         throws SQLException {
263                 // TODO Auto-generated method stub
264                 return null;
265         }
266
267         @Override
268         public PreparedStatement prepareStatement(String sql, String[] columnNames)
269                         throws SQLException {
270                 // TODO Auto-generated method stub
271                 return null;
272         }
273
274         @Override
275         public PreparedStatement prepareStatement(String sql, int resultSetType,
276                         int resultSetConcurrency) throws SQLException {
277                 // TODO Auto-generated method stub
278                 return null;
279         }
280
281         @Override
282         public PreparedStatement prepareStatement(String sql, int resultSetType,
283                         int resultSetConcurrency, int resultSetHoldability)
284                         throws SQLException {
285                 // TODO Auto-generated method stub
286                 return null;
287         }
288
289         @Override
290         public void releaseSavepoint(Savepoint savepoint) throws SQLException {
291                 // TODO Auto-generated method stub
292
293         }
294
295         @Override
296         public void rollback() throws SQLException {
297                 // TODO Auto-generated method stub
298
299         }
300
301         @Override
302         public void rollback(Savepoint savepoint) throws SQLException {
303                 // TODO Auto-generated method stub
304
305         }
306
307         @Override
308         public void setAutoCommit(boolean autoCommit) throws SQLException {
309                 // TODO Auto-generated method stub
310
311         }
312
313         @Override
314         public void setCatalog(String catalog) throws SQLException {
315                 // TODO Auto-generated method stub
316
317         }
318
319         @Override
320         public void setClientInfo(Properties properties)
321                         throws SQLClientInfoException {
322                 // TODO Auto-generated method stub
323
324         }
325
326         @Override
327         public void setClientInfo(String name, String value)
328                         throws SQLClientInfoException {
329                 // TODO Auto-generated method stub
330
331         }
332
333         @Override
334         public void setHoldability(int holdability) throws SQLException {
335                 // TODO Auto-generated method stub
336
337         }
338
339         @Override
340         public void setNetworkTimeout(Executor executor, int milliseconds)
341                         throws SQLException {
342                 // TODO Auto-generated method stub
343
344         }
345
346         @Override
347         public void setReadOnly(boolean readOnly) throws SQLException {
348                 // TODO Auto-generated method stub
349
350         }
351
352         @Override
353         public Savepoint setSavepoint() throws SQLException {
354                 // TODO Auto-generated method stub
355                 return null;
356         }
357
358         @Override
359         public Savepoint setSavepoint(String name) throws SQLException {
360                 // TODO Auto-generated method stub
361                 return null;
362         }
363
364         @Override
365         public void setSchema(String schema) throws SQLException {
366                 // TODO Auto-generated method stub
367
368         }
369
370         @Override
371         public void setTransactionIsolation(int level) throws SQLException {
372                 // TODO Auto-generated method stub
373
374         }
375
376         @Override
377         public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
378                 // TODO Auto-generated method stub
379
380         }
381
382 }
383