|
C:\devel\mocks\src\com\ociweb\jnb\ex3\MockConnection.java
|
1 package com.ociweb.jnb.ex3;
2
3 import java.sql.Connection;
4
5 public class MockConnection implements Connection {
6
7 public boolean createStatementCalled;
8 public java.sql.Statement createStatementReturn;
9 public Throwable createStatementException;
10 public java.sql.Statement createStatement() throws java.sql.SQLException {
11 createStatementCalled = true;
12 if (createStatementException != null) {
13 if (createStatementException instanceof java.sql.SQLException)
14 throw (java.sql.SQLException) createStatementException;
15 if (createStatementException instanceof RuntimeException)
16 throw (RuntimeException) createStatementException;
17 if (createStatementException instanceof Error)
18 throw (Error) createStatementException;
19 throw new RuntimeException();
20 }
21 return this.createStatementReturn;
22 }
23
24 public boolean prepareStatementCalled;
25 public java.sql.PreparedStatement prepareStatementReturn;
26 public Throwable prepareStatementException;
27 public String prepareStatementSql;
28 public java.sql.PreparedStatement prepareStatement(String sql) throws java.sql.SQLException {
29 prepareStatementCalled = true;
30 this.prepareStatementSql = sql;
31 if (prepareStatementException != null) {
32 if (prepareStatementException instanceof java.sql.SQLException)
33 throw (java.sql.SQLException) prepareStatementException;
34 if (prepareStatementException instanceof RuntimeException)
35 throw (RuntimeException) prepareStatementException;
36 if (prepareStatementException instanceof Error)
37 throw (Error) prepareStatementException;
38 throw new RuntimeException();
39 }
40 return this.prepareStatementReturn;
41 }
42
43 public boolean prepareCallCalled;
44 public java.sql.CallableStatement prepareCallReturn;
45 public Throwable prepareCallException;
46 public String prepareCallSql;
47 public java.sql.CallableStatement prepareCall(String sql) throws java.sql.SQLException {
48 prepareCallCalled = true;
49 this.prepareCallSql = sql;
50 if (prepareCallException != null) {
51 if (prepareCallException instanceof java.sql.SQLException)
52 throw (java.sql.SQLException) prepareCallException;
53 if (prepareCallException instanceof RuntimeException)
54 throw (RuntimeException) prepareCallException;
55 if (prepareCallException instanceof Error)
56 throw (Error) prepareCallException;
57 throw new RuntimeException();
58 }
59 return this.prepareCallReturn;
60 }
61
62 public boolean nativeSQLCalled;
63 public String nativeSQLReturn;
64 public Throwable nativeSQLException;
65 public String nativeSQLSql;
66 public String nativeSQL(String sql) throws java.sql.SQLException {
67 nativeSQLCalled = true;
68 this.nativeSQLSql = sql;
69 if (nativeSQLException != null) {
70 if (nativeSQLException instanceof java.sql.SQLException)
71 throw (java.sql.SQLException) nativeSQLException;
72 if (nativeSQLException instanceof RuntimeException)
73 throw (RuntimeException) nativeSQLException;
74 if (nativeSQLException instanceof Error)
75 throw (Error) nativeSQLException;
76 throw new RuntimeException();
77 }
78 return this.nativeSQLReturn;
79 }
80
81 public boolean setAutoCommitCalled;
82 public Throwable setAutoCommitException;
83 public boolean setAutoCommitAutoCommit;
84 public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException {
85 setAutoCommitCalled = true;
86 this.setAutoCommitAutoCommit = autoCommit;
87 if (setAutoCommitException != null) {
88 if (setAutoCommitException instanceof java.sql.SQLException)
89 throw (java.sql.SQLException) setAutoCommitException;
90 if (setAutoCommitException instanceof RuntimeException)
91 throw (RuntimeException) setAutoCommitException;
92 if (setAutoCommitException instanceof Error)
93 throw (Error) setAutoCommitException;
94 throw new RuntimeException();
95 }
96 }
97
98 public boolean getAutoCommitCalled;
99 public boolean getAutoCommitReturn;
100 public Throwable getAutoCommitException;
101 public boolean getAutoCommit() throws java.sql.SQLException {
102 getAutoCommitCalled = true;
103 if (getAutoCommitException != null) {
104 if (getAutoCommitException instanceof java.sql.SQLException)
105 throw (java.sql.SQLException) getAutoCommitException;
106 if (getAutoCommitException instanceof RuntimeException)
107 throw (RuntimeException) getAutoCommitException;
108 if (getAutoCommitException instanceof Error)
109 throw (Error) getAutoCommitException;
110 throw new RuntimeException();
111 }
112 return this.getAutoCommitReturn;
113 }
114
115 public boolean commitCalled;
116 public Throwable commitException;
117 public void commit() throws java.sql.SQLException {
118 commitCalled = true;
119 if (commitException != null) {
120 if (commitException instanceof java.sql.SQLException)
121 throw (java.sql.SQLException) commitException;
122 if (commitException instanceof RuntimeException)
123 throw (RuntimeException) commitException;
124 if (commitException instanceof Error)
125 throw (Error) commitException;
126 throw new RuntimeException();
127 }
128 }
129
130 public boolean rollbackCalled;
131 public Throwable rollbackException;
132 public void rollback() throws java.sql.SQLException {
133 rollbackCalled = true;
134 if (rollbackException != null) {
135 if (rollbackException instanceof java.sql.SQLException)
136 throw (java.sql.SQLException) rollbackException;
137 if (rollbackException instanceof RuntimeException)
138 throw (RuntimeException) rollbackException;
139 if (rollbackException instanceof Error)
140 throw (Error) rollbackException;
141 throw new RuntimeException();
142 }
143 }
144
145 public boolean closeCalled;
146 public Throwable closeException;
147 public void close() throws java.sql.SQLException {
148 closeCalled = true;
149 if (closeException != null) {
150 if (closeException instanceof java.sql.SQLException)
151 throw (java.sql.SQLException) closeException;
152 if (closeException instanceof RuntimeException)
153 throw (RuntimeException) closeException;
154 if (closeException instanceof Error)
155 throw (Error) closeException;
156 throw new RuntimeException();
157 }
158 }
159
160 public boolean isClosedCalled;
161 public boolean isClosedReturn;
162 public Throwable isClosedException;
163 public boolean isClosed() throws java.sql.SQLException {
164 isClosedCalled = true;
165 if (isClosedException != null) {
166 if (isClosedException instanceof java.sql.SQLException)
167 throw (java.sql.SQLException) isClosedException;
168 if (isClosedException instanceof RuntimeException)
169 throw (RuntimeException) isClosedException;
170 if (isClosedException instanceof Error)
171 throw (Error) isClosedException;
172 throw new RuntimeException();
173 }
174 return this.isClosedReturn;
175 }
176
177 public boolean getMetaDataCalled;
178 public java.sql.DatabaseMetaData getMetaDataReturn;
179 public Throwable getMetaDataException;
180 public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException {
181 getMetaDataCalled = true;
182 if (getMetaDataException != null) {
183 if (getMetaDataException instanceof java.sql.SQLException)
184 throw (java.sql.SQLException) getMetaDataException;
185 if (getMetaDataException instanceof RuntimeException)
186 throw (RuntimeException) getMetaDataException;
187 if (getMetaDataException instanceof Error)
188 throw (Error) getMetaDataException;
189 throw new RuntimeException();
190 }
191 return this.getMetaDataReturn;
192 }
193
194 public boolean setReadOnlyCalled;
195 public Throwable setReadOnlyException;
196 public boolean setReadOnlyReadOnly;
197 public void setReadOnly(boolean readOnly) throws java.sql.SQLException {
198 setReadOnlyCalled = true;
199 this.setReadOnlyReadOnly = readOnly;
200 if (setReadOnlyException != null) {
201 if (setReadOnlyException instanceof java.sql.SQLException)
202 throw (java.sql.SQLException) setReadOnlyException;
203 if (setReadOnlyException instanceof RuntimeException)
204 throw (RuntimeException) setReadOnlyException;
205 if (setReadOnlyException instanceof Error)
206 throw (Error) setReadOnlyException;
207 throw new RuntimeException();
208 }
209 }
210
211 public boolean isReadOnlyCalled;
212 public boolean isReadOnlyReturn;
213 public Throwable isReadOnlyException;
214 public boolean isReadOnly() throws java.sql.SQLException {
215 isReadOnlyCalled = true;
216 if (isReadOnlyException != null) {
217 if (isReadOnlyException instanceof java.sql.SQLException)
218 throw (java.sql.SQLException) isReadOnlyException;
219 if (isReadOnlyException instanceof RuntimeException)
220 throw (RuntimeException) isReadOnlyException;
221 if (isReadOnlyException instanceof Error)
222 throw (Error) isReadOnlyException;
223 throw new RuntimeException();
224 }
225 return this.isReadOnlyReturn;
226 }
227
228 public boolean setCatalogCalled;
229 public Throwable setCatalogException;
230 public String setCatalogCatalog;
231 public void setCatalog(String catalog) throws java.sql.SQLException {
232 setCatalogCalled = true;
233 this.setCatalogCatalog = catalog;
234 if (setCatalogException != null) {
235 if (setCatalogException instanceof java.sql.SQLException)
236 throw (java.sql.SQLException) setCatalogException;
237 if (setCatalogException instanceof RuntimeException)
238 throw (RuntimeException) setCatalogException;
239 if (setCatalogException instanceof Error)
240 throw (Error) setCatalogException;
241 throw new RuntimeException();
242 }
243 }
244
245 public boolean getCatalogCalled;
246 public String getCatalogReturn;
247 public Throwable getCatalogException;
248 public String getCatalog() throws java.sql.SQLException {
249 getCatalogCalled = true;
250 if (getCatalogException != null) {
251 if (getCatalogException instanceof java.sql.SQLException)
252 throw (java.sql.SQLException) getCatalogException;
253 if (getCatalogException instanceof RuntimeException)
254 throw (RuntimeException) getCatalogException;
255 if (getCatalogException instanceof Error)
256 throw (Error) getCatalogException;
257 throw new RuntimeException();
258 }
259 return this.getCatalogReturn;
260 }
261
262 public boolean setTransactionIsolationCalled;
263 public Throwable setTransactionIsolationException;
264 public int setTransactionIsolationLevel;
265 public void setTransactionIsolation(int level) throws java.sql.SQLException {
266 setTransactionIsolationCalled = true;
267 this.setTransactionIsolationLevel = level;
268 if (setTransactionIsolationException != null) {
269 if (setTransactionIsolationException instanceof java.sql.SQLException)
270 throw (java.sql.SQLException) setTransactionIsolationException;
271 if (setTransactionIsolationException instanceof RuntimeException)
272 throw (RuntimeException) setTransactionIsolationException;
273 if (setTransactionIsolationException instanceof Error)
274 throw (Error) setTransactionIsolationException;
275 throw new RuntimeException();
276 }
277 }
278
279 public boolean getTransactionIsolationCalled;
280 public int getTransactionIsolationReturn;
281 public Throwable getTransactionIsolationException;
282 public int getTransactionIsolation() throws java.sql.SQLException {
283 getTransactionIsolationCalled = true;
284 if (getTransactionIsolationException != null) {
285 if (getTransactionIsolationException instanceof java.sql.SQLException)
286 throw (java.sql.SQLException) getTransactionIsolationException;
287 if (getTransactionIsolationException instanceof RuntimeException)
288 throw (RuntimeException) getTransactionIsolationException;
289 if (getTransactionIsolationException instanceof Error)
290 throw (Error) getTransactionIsolationException;
291 throw new RuntimeException();
292 }
293 return this.getTransactionIsolationReturn;
294 }
295
296 public boolean getWarningsCalled;
297 public java.sql.SQLWarning getWarningsReturn;
298 public Throwable getWarningsException;
299 public java.sql.SQLWarning getWarnings() throws java.sql.SQLException {
300 getWarningsCalled = true;
301 if (getWarningsException != null) {
302 if (getWarningsException instanceof java.sql.SQLException)
303 throw (java.sql.SQLException) getWarningsException;
304 if (getWarningsException instanceof RuntimeException)
305 throw (RuntimeException) getWarningsException;
306 if (getWarningsException instanceof Error)
307 throw (Error) getWarningsException;
308 throw new RuntimeException();
309 }
310 return this.getWarningsReturn;
311 }
312
313 public boolean clearWarningsCalled;
314 public Throwable clearWarningsException;
315 public void clearWarnings() throws java.sql.SQLException {
316 clearWarningsCalled = true;
317 if (clearWarningsException != null) {
318 if (clearWarningsException instanceof java.sql.SQLException)
319 throw (java.sql.SQLException) clearWarningsException;
320 if (clearWarningsException instanceof RuntimeException)
321 throw (RuntimeException) clearWarningsException;
322 if (clearWarningsException instanceof Error)
323 throw (Error) clearWarningsException;
324 throw new RuntimeException();
325 }
326 }
327
328 public boolean createStatement2Called;
329 public java.sql.Statement createStatement2Return;
330 public Throwable createStatement2Exception;
331 public int createStatement2ResultSetType;
332 public int createStatement2ResultSetConcurrency;
333 public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException {
334 createStatement2Called = true;
335 this.createStatement2ResultSetType = resultSetType;
336 this.createStatement2ResultSetConcurrency = resultSetConcurrency;
337 if (createStatement2Exception != null) {
338 if (createStatement2Exception instanceof java.sql.SQLException)
339 throw (java.sql.SQLException) createStatement2Exception;
340 if (createStatement2Exception instanceof RuntimeException)
341 throw (RuntimeException) createStatement2Exception;
342 if (createStatement2Exception instanceof Error)
343 throw (Error) createStatement2Exception;
344 throw new RuntimeException();
345 }
346 return this.createStatement2Return;
347 }
348
349 public boolean prepareStatement2Called;
350 public java.sql.PreparedStatement prepareStatement2Return;
351 public Throwable prepareStatement2Exception;
352 public String prepareStatement2Sql;
353 public int prepareStatement2ResultSetType;
354 public int prepareStatement2ResultSetConcurrency;
355 public java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException {
356 prepareStatement2Called = true;
357 this.prepareStatement2Sql = sql;
358 this.prepareStatement2ResultSetType = resultSetType;
359 this.prepareStatement2ResultSetConcurrency = resultSetConcurrency;
360 if (prepareStatement2Exception != null) {
361 if (prepareStatement2Exception instanceof java.sql.SQLException)
362 throw (java.sql.SQLException) prepareStatement2Exception;
363 if (prepareStatement2Exception instanceof RuntimeException)
364 throw (RuntimeException) prepareStatement2Exception;
365 if (prepareStatement2Exception instanceof Error)
366 throw (Error) prepareStatement2Exception;
367 throw new RuntimeException();
368 }
369 return this.prepareStatement2Return;
370 }
371
372 public boolean prepareCall2Called;
373 public java.sql.CallableStatement prepareCall2Return;
374 public Throwable prepareCall2Exception;
375 public String prepareCall2Sql;
376 public int prepareCall2ResultSetType;
377 public int prepareCall2ResultSetConcurrency;
378 public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException {
379 prepareCall2Called = true;
380 this.prepareCall2Sql = sql;
381 this.prepareCall2ResultSetType = resultSetType;
382 this.prepareCall2ResultSetConcurrency = resultSetConcurrency;
383 if (prepareCall2Exception != null) {
384 if (prepareCall2Exception instanceof java.sql.SQLException)
385 throw (java.sql.SQLException) prepareCall2Exception;
386 if (prepareCall2Exception instanceof RuntimeException)
387 throw (RuntimeException) prepareCall2Exception;
388 if (prepareCall2Exception instanceof Error)
389 throw (Error) prepareCall2Exception;
390 throw new RuntimeException();
391 }
392 return this.prepareCall2Return;
393 }
394
395 public boolean getTypeMapCalled;
396 public java.util.Map getTypeMapReturn;
397 public Throwable getTypeMapException;
398 public java.util.Map getTypeMap() throws java.sql.SQLException {
399 getTypeMapCalled = true;
400 if (getTypeMapException != null) {
401 if (getTypeMapException instanceof java.sql.SQLException)
402 throw (java.sql.SQLException) getTypeMapException;
403 if (getTypeMapException instanceof RuntimeException)
404 throw (RuntimeException) getTypeMapException;
405 if (getTypeMapException instanceof Error)
406 throw (Error) getTypeMapException;
407 throw new RuntimeException();
408 }
409 return this.getTypeMapReturn;
410 }
411
412 public boolean setTypeMapCalled;
413 public Throwable setTypeMapException;
414 public java.util.Map setTypeMapMap;
415 public void setTypeMap(java.util.Map map) throws java.sql.SQLException {
416 setTypeMapCalled = true;
417 this.setTypeMapMap = map;
418 if (setTypeMapException != null) {
419 if (setTypeMapException instanceof java.sql.SQLException)
420 throw (java.sql.SQLException) setTypeMapException;
421 if (setTypeMapException instanceof RuntimeException)
422 throw (RuntimeException) setTypeMapException;
423 if (setTypeMapException instanceof Error)
424 throw (Error) setTypeMapException;
425 throw new RuntimeException();
426 }
427 }
428
429 public boolean setHoldabilityCalled;
430 public Throwable setHoldabilityException;
431 public int setHoldabilityHoldability;
432 public void setHoldability(int holdability) throws java.sql.SQLException {
433 setHoldabilityCalled = true;
434 this.setHoldabilityHoldability = holdability;
435 if (setHoldabilityException != null) {
436 if (setHoldabilityException instanceof java.sql.SQLException)
437 throw (java.sql.SQLException) setHoldabilityException;
438 if (setHoldabilityException instanceof RuntimeException)
439 throw (RuntimeException) setHoldabilityException;
440 if (setHoldabilityException instanceof Error)
441 throw (Error) setHoldabilityException;
442 throw new RuntimeException();
443 }
444 }
445
446 public boolean getHoldabilityCalled;
447 public int getHoldabilityReturn;
448 public Throwable getHoldabilityException;
449 public int getHoldability() throws java.sql.SQLException {
450 getHoldabilityCalled = true;
451 if (getHoldabilityException != null) {
452 if (getHoldabilityException instanceof java.sql.SQLException)
453 throw (java.sql.SQLException) getHoldabilityException;
454 if (getHoldabilityException instanceof RuntimeException)
455 throw (RuntimeException) getHoldabilityException;
456 if (getHoldabilityException instanceof Error)
457 throw (Error) getHoldabilityException;
458 throw new RuntimeException();
459 }
460 return this.getHoldabilityReturn;
461 }
462
463 public boolean setSavepointCalled;
464 public java.sql.Savepoint setSavepointReturn;
465 public Throwable setSavepointException;
466 public java.sql.Savepoint setSavepoint() throws java.sql.SQLException {
467 setSavepointCalled = true;
468 if (setSavepointException != null) {
469 if (setSavepointException instanceof java.sql.SQLException)
470 throw (java.sql.SQLException) setSavepointException;
471 if (setSavepointException instanceof RuntimeException)
472 throw (RuntimeException) setSavepointException;
473 if (setSavepointException instanceof Error)
474 throw (Error) setSavepointException;
475 throw new RuntimeException();
476 }
477 return this.setSavepointReturn;
478 }
479
480 public