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