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