View Javadoc

1   /**
2    * 
3    */
4   package com.github.smokestack.jdbc;
5   
6   import static org.hamcrest.MatcherAssert.assertThat;
7   
8   import java.sql.Connection;
9   import java.sql.ResultSet;
10  import java.sql.SQLException;
11  import java.sql.SQLWarning;
12  import java.sql.Statement;
13  import java.util.ArrayList;
14  import java.util.List;
15  
16  import org.apache.commons.lang.builder.ReflectionToStringBuilder;
17  import org.apache.commons.lang.builder.ToStringStyle;
18  import org.hamcrest.core.AnyOf;
19  import org.hamcrest.core.Is;
20  import org.hamcrest.core.IsNot;
21  
22  import com.github.smokestack.exception.NeedsMockDefinitionException;
23  import com.github.smokestack.exception.NotYetImplementedException;
24  
25  /**
26   * @author gliptak
27   *
28   */
29  public class MockStatement implements Statement {
30  
31  	private static long autoId = 0;
32  	private long id;
33  	private int direction;
34  	private Connection connection;
35  	private MockConnection parent;
36  	
37  	private List<MockResultSet> mockResultSets=new ArrayList<MockResultSet>();
38  
39  	public enum StatementState {NEW, CLOSE, COMPLETE, AUTOCLOSE};
40  	
41  	protected StatementState mockState=StatementState.NEW;
42  	private int fetchSize;
43  	private List<String> batchSQLs = new ArrayList<String>();
44  	private int maxFieldSize;
45  	private int maxRows;
46  	private int queryTimeout;
47  	private int resultSetConcurrency;
48  	private int resultSetHoldability;
49  	private int resultSetType;
50  	private int updateCount;
51  	private String cursorName;
52  	private boolean escapeProcessing;
53  
54  	public MockStatement(Connection connection) {
55  		this.connection=connection;
56  		this.parent = (MockConnection) connection;
57  		this.id = ++autoId;
58  	}
59  
60  	/* (non-Javadoc)
61  	 * @see java.sql.Statement#addBatch(java.lang.String)
62  	 */
63  	public void addBatch(String sql) throws SQLException {
64  		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
65  		assertThat("Auto Commit State", parent.autoCommitState, Is.is(MockConnection.AutoCommitState.DISABLED));
66  		_addBatch(sql);
67  		batchSQLs.add(new String());
68  	}
69  
70  	public void _addBatch(String sql) {
71  	}
72  
73  	/* (non-Javadoc)
74  	 * @see java.sql.Statement#cancel()
75  	 */
76  	public void cancel() throws SQLException {
77  		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
78  		_cancel();
79  		this.mockState = StatementState.NEW;
80  	}
81  
82  	public void _cancel() throws SQLException {
83  	}
84  
85  	/* (non-Javadoc)
86  	 * @see java.sql.Statement#clearBatch()
87  	 */
88  	public void clearBatch() throws SQLException {
89  		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
90  		assertThat("Auto Commit State", parent.autoCommitState, Is.is(MockConnection.AutoCommitState.DISABLED));
91  		_clearBatch();
92  		batchSQLs.clear();
93  	}
94  
95  	public void _clearBatch() {
96  	}
97  
98  	/* (non-Javadoc)
99  	 * @see java.sql.Statement#clearWarnings()
100 	 */
101 	public void clearWarnings() throws SQLException {
102 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
103 		_clearWarnings();
104 		this.mockState = StatementState.NEW;
105 	}
106 
107 	public void _clearWarnings() {
108 	}
109 
110 	/* (non-Javadoc)
111 	 * @see java.sql.Statement#close()
112 	 */
113 	public void close() throws SQLException {
114 		assertThat("Statement State", mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
115 		assertThat("Statement State", mockState, Is.is(StatementState.COMPLETE));
116 		_close();
117 		this.mockState=StatementState.CLOSE;
118 	}
119 
120 	public void _close() throws SQLException {
121 	}
122 
123 	/* (non-Javadoc)
124 	 * @see java.sql.Statement#execute(java.lang.String)
125 	 */
126 	public boolean execute(String sql) throws SQLException {
127 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
128 		mockState = StatementState.COMPLETE;
129 		parent.completeOtherStatements(this);
130 		return _execute(sql);
131 	}
132 
133 	/* (non-Javadoc)
134 	 * @see java.sql.Statement#execute(java.lang.String)
135 	 */
136 	public boolean _execute(String sql) throws SQLException {
137 		throw new NeedsMockDefinitionException();	
138 	}
139 
140 	/* (non-Javadoc)
141 	 * @see java.sql.Statement#execute(java.lang.String, int)
142 	 */
143 	public boolean execute(String sql, int autoGeneratedKeys)
144 			throws SQLException {
145 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
146 		mockState = StatementState.COMPLETE;
147 		parent.completeOtherStatements(this);
148 		return _execute(sql, autoGeneratedKeys);
149 	}
150 
151 	public boolean _execute(String sql, int autoGeneratedKeys) {
152 		throw new NeedsMockDefinitionException();	
153 	}
154 
155 	/* (non-Javadoc)
156 	 * @see java.sql.Statement#execute(java.lang.String, int[])
157 	 */
158 	public boolean execute(String sql, int[] columnIndexes) throws SQLException {
159 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
160 		mockState = StatementState.COMPLETE;
161 		parent.completeOtherStatements(this);
162 		return _execute(sql, columnIndexes);
163 	}
164 
165 	public boolean _execute(String sql, int[] columnIndexes) {
166 		throw new NeedsMockDefinitionException();	
167 	}
168 
169 	/* (non-Javadoc)
170 	 * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])
171 	 */
172 	public boolean execute(String sql, String[] columnNames)
173 			throws SQLException {
174 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
175 		mockState = StatementState.COMPLETE;
176 		parent.completeOtherStatements(this);
177 		return _execute(sql, columnNames);
178 	}
179 
180 	public boolean _execute(String sql, String[] columnNames) {
181 		throw new NeedsMockDefinitionException();	
182 	}
183 
184 	/* (non-Javadoc)
185 	 * @see java.sql.Statement#executeBatch()
186 	 */
187 	public int[] executeBatch() throws SQLException {
188 		assertThat("mock State", mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
189 		assertThat("Auto Commit State", parent.autoCommitState, Is.is(MockConnection.AutoCommitState.DISABLED));
190 		int[] b = null;
191 		try{
192 			b = _executeBatch();
193 			mockState = StatementState.COMPLETE;
194 			parent.completeOtherStatements(this);
195 		}catch (SQLException se){
196 			parent.mockTransactionState= MockConnection.TransactionState.ROLLBACK;
197 		}
198 		return b;
199 	}
200 
201 	public int[] _executeBatch() throws SQLException {
202 		throw new NeedsMockDefinitionException();	
203 	}
204 
205 	/* (non-Javadoc)
206 	 * @see java.sql.Statement#executeQuery(java.lang.String)
207 	 */
208 	public ResultSet executeQuery(String sql) throws SQLException {
209 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
210 		MockResultSet rs=new MockResultSet(sql);
211 		rs.setParent(this);
212 		mockResultSets.add(rs);
213 		mockState = StatementState.COMPLETE;
214 		parent.completeOtherStatements(this);
215 		_executeQuery(sql);
216 		return rs;
217 	}
218 
219 	public void _executeQuery(String sql) {
220 	}
221 
222 	/* (non-Javadoc)
223 	 * @see java.sql.Statement#executeUpdate(java.lang.String)
224 	 */
225 	public int executeUpdate(String sql) throws SQLException {
226 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
227 		int b = 0;
228 		parent.mockTransactionState= MockConnection.TransactionState.AUTOCOMMIT;
229 		try{
230 			mockState = StatementState.COMPLETE;
231 			parent.completeOtherStatements(this);
232 			b = _executeUpdate(sql);
233 		}catch (SQLException se){
234 			parent.mockTransactionState= MockConnection.TransactionState.ROLLBACK;
235 		}		
236 		return b;
237 	}
238 
239 	/* (non-Javadoc)
240 	 * @see java.sql.Statement#executeUpdate(java.lang.String)
241 	 */
242 	public int _executeUpdate(String sql) throws SQLException {
243 		throw new NeedsMockDefinitionException();	
244 	}	
245 	/* (non-Javadoc)
246 	 * @see java.sql.Statement#executeUpdate(java.lang.String, int)
247 	 */
248 	public int executeUpdate(String sql, int autoGeneratedKeys)
249 			throws SQLException {
250 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
251 		int b = 0;
252 		parent.mockTransactionState= MockConnection.TransactionState.AUTOCOMMIT;
253 		try{
254 			mockState = StatementState.COMPLETE;
255 			parent.completeOtherStatements(this);
256 			b = _executeUpdate(sql, autoGeneratedKeys);
257 		}catch (SQLException se){
258 			parent.mockTransactionState= MockConnection.TransactionState.ROLLBACK;
259 		}		
260 		return b;
261 	}
262 
263 	public int _executeUpdate(String sql, int autoGeneratedKeys) throws SQLException{
264 		throw new NeedsMockDefinitionException();	
265 	}
266 
267 	/* (non-Javadoc)
268 	 * @see java.sql.Statement#executeUpdate(java.lang.String, int[])
269 	 */
270 	public int executeUpdate(String sql, int[] columnIndexes)
271 			throws SQLException {
272 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
273 		int b = 0;
274 		parent.mockTransactionState= MockConnection.TransactionState.AUTOCOMMIT;
275 		try{
276 			mockState = StatementState.COMPLETE;
277 			parent.completeOtherStatements(this);
278 			b = _executeUpdate(sql, columnIndexes);
279 		}catch (SQLException se){
280 			parent.mockTransactionState= MockConnection.TransactionState.ROLLBACK;
281 		}		
282 		return b;
283 	}
284 
285 	public int _executeUpdate(String sql, int[] columnIndexes) throws SQLException{
286 		throw new NeedsMockDefinitionException();	
287 	}
288 
289 	/* (non-Javadoc)
290 	 * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])
291 	 */
292 	public int executeUpdate(String sql, String[] columnNames)
293 			throws SQLException {
294 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
295 		int b = 0;
296 		parent.mockTransactionState= MockConnection.TransactionState.AUTOCOMMIT;
297 		try{
298 			mockState = StatementState.COMPLETE;
299 			parent.completeOtherStatements(this);
300 			b = _executeUpdate(sql, columnNames);
301 		}catch (SQLException se){
302 			parent.mockTransactionState= MockConnection.TransactionState.ROLLBACK;
303 		}		
304 		return b;
305 	}
306 
307 	public int _executeUpdate(String sql, String[] columnNames) throws SQLException{
308 		throw new NeedsMockDefinitionException();	
309 	}
310 
311 	/* (non-Javadoc)
312 	 * @see java.sql.Statement#getConnection()
313 	 */
314 	public Connection getConnection() throws SQLException {
315 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
316 		_getConnection();
317 		return connection;
318 	}
319 
320 	public Connection _getConnection() {
321 		return null; 
322 	}
323 
324 	/* (non-Javadoc)
325 	 * @see java.sql.Statement#getFetchDirection()
326 	 */
327 	public int getFetchDirection() throws SQLException {
328 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
329 		_getFetchDirection();
330 		return direction;
331 	}
332 
333 	public int _getFetchDirection() {
334 		return -1;
335 	}
336 
337 	/* (non-Javadoc)
338 	 * @see java.sql.Statement#getFetchSize()
339 	 */
340 	public int getFetchSize() throws SQLException {
341 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
342 		_getFetchSize();
343 		return fetchSize;
344 	}
345 
346 	public int _getFetchSize() {
347 		return -1;
348 	}
349 
350 	/* (non-Javadoc)
351 	 * @see java.sql.Statement#getGeneratedKeys()
352 	 */
353 	public ResultSet getGeneratedKeys() throws SQLException {
354 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
355 		throw new NotYetImplementedException();
356 	}
357 
358 	/* (non-Javadoc)
359 	 * @see java.sql.Statement#getMaxFieldSize()
360 	 */
361 	public int getMaxFieldSize() throws SQLException {
362 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
363 		_getMaxFieldSize();
364 		return maxFieldSize;
365 	}
366 
367 	public int _getMaxFieldSize() {
368 		return -1;
369 	}
370 
371 	/* (non-Javadoc)
372 	 * @see java.sql.Statement#getMaxRows()
373 	 */
374 	public int getMaxRows() throws SQLException {
375 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
376 		_getMaxRows();
377 		return maxRows;
378 	}
379 
380 	public int _getMaxRows() {
381 		return -1;
382 	}
383 
384 	/* (non-Javadoc)
385 	 * @see java.sql.Statement#getMoreResults()
386 	 */
387 	public boolean getMoreResults() throws SQLException {
388 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
389 		return _getMoreResults();
390 	}
391 
392 	public boolean _getMoreResults() {
393 		throw new NeedsMockDefinitionException();
394 	}
395 
396 	/* (non-Javadoc)
397 	 * @see java.sql.Statement#getMoreResults(int)
398 	 */
399 	public boolean getMoreResults(int current) throws SQLException {
400 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
401 		return _getMoreResults(current);
402 	}
403 
404 	public boolean _getMoreResults(int current) {
405 		throw new NeedsMockDefinitionException();
406 	}
407 
408 	/* (non-Javadoc)
409 	 * @see java.sql.Statement#getQueryTimeout()
410 	 */
411 	public int getQueryTimeout() throws SQLException {
412 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
413 		_getQueryTimeout();
414 		return queryTimeout;
415 	}
416 
417 	public int _getQueryTimeout() {
418 		return -1;
419 	}
420 
421 	/* (non-Javadoc)
422 	 * @see java.sql.Statement#getResultSet()
423 	 */
424 	public ResultSet getResultSet() throws SQLException {
425 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
426 		_getResultSet();
427 		return this.mockResultSets.get(mockResultSets.size()-1);
428 	}
429 
430 	public ResultSet _getResultSet() {
431 		return null; 
432 	}
433 
434 	/* (non-Javadoc)
435 	 * @see java.sql.Statement#getResultSetConcurrency()
436 	 */
437 	public int getResultSetConcurrency() throws SQLException {
438 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
439 		_getResultSetConcurrency();
440 		return resultSetConcurrency;
441 	}
442 
443 	public int _getResultSetConcurrency() {
444 		return -1;
445 	}
446 
447 	/* (non-Javadoc)
448 	 * @see java.sql.Statement#getResultSetHoldability()
449 	 */
450 	public int getResultSetHoldability() throws SQLException {
451 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
452 		_getResultSetHoldability();
453 		return resultSetHoldability;
454 	}
455 
456 	public int _getResultSetHoldability() {
457 		return -1;
458 	}
459 
460 	/* (non-Javadoc)
461 	 * @see java.sql.Statement#getResultSetType()
462 	 */
463 	public int getResultSetType() throws SQLException {
464 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
465 		_getResultSetType();
466 		return resultSetType;
467 	}
468 
469 	public int _getResultSetType() {
470 		return -1;
471 	}
472 
473 	/* (non-Javadoc)
474 	 * @see java.sql.Statement#getUpdateCount()
475 	 */
476 	public int getUpdateCount() throws SQLException {
477 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
478 		return _getUpdateCount();
479 	}
480 
481 	public int _getUpdateCount() {
482 		throw new NeedsMockDefinitionException();
483 	}
484 
485 	/* (non-Javadoc)
486 	 * @see java.sql.Statement#getWarnings()
487 	 */
488 	public SQLWarning getWarnings() throws SQLException {
489 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
490 		return _getWarnings();
491 	}
492 
493 	public SQLWarning _getWarnings() {
494 		throw new NeedsMockDefinitionException();
495 	}
496 
497 	/* (non-Javadoc)
498 	 * @see java.sql.Statement#setCursorName(java.lang.String)
499 	 */
500 	public void setCursorName(String name) throws SQLException {
501 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
502 		_setCursorName( name);
503 		this.cursorName = name;
504 	}
505 
506 	public void _setCursorName(String name) {
507 	}
508 
509 	/* (non-Javadoc)
510 	 * @see java.sql.Statement#setEscapeProcessing(boolean)
511 	 */
512 	public void setEscapeProcessing(boolean enable) throws SQLException {
513 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
514 		_setEscapeProcessing(enable);
515 		this.escapeProcessing = enable;
516 	}
517 
518 	public void _setEscapeProcessing(boolean enable) {
519 	}
520 
521 	/* (non-Javadoc)
522 	 * @see java.sql.Statement#setFetchDirection(int)
523 	 */
524 	public void setFetchDirection(int direction) throws SQLException {
525 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
526 		_setFetchDirection( direction);
527 		this.direction=direction;
528 	}
529 
530 	public void _setFetchDirection(int direction) {
531 	}
532 
533 	/* (non-Javadoc)
534 	 * @see java.sql.Statement#setFetchSize(int)
535 	 */
536 	public void setFetchSize(int rows) throws SQLException {
537 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
538 		_setFetchSize(rows);
539 		this.fetchSize = rows;
540 	}
541 
542 	public void _setFetchSize(int rows) {
543 	}
544 
545 	/* (non-Javadoc)
546 	 * @see java.sql.Statement#setMaxFieldSize(int)
547 	 */
548 	public void setMaxFieldSize(int max) throws SQLException {
549 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
550 		_setMaxFieldSize(max);
551 		this.maxFieldSize = max;
552 	}
553 
554 	public void _setMaxFieldSize(int max) {
555 	}
556 
557 	/* (non-Javadoc)
558 	 * @see java.sql.Statement#setMaxRows(int)
559 	 */
560 	public void setMaxRows(int max) throws SQLException {
561 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
562 		_setMaxRows(max);
563 		this.maxRows = max;
564 	}
565 
566 	public void _setMaxRows(int max) {
567 	}
568 
569 	/* (non-Javadoc)
570 	 * @see java.sql.Statement#setQueryTimeout(int)
571 	 */
572 	public void setQueryTimeout(int seconds) throws SQLException {
573 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
574 		_setQueryTimeout(seconds);
575 		this.queryTimeout = seconds;
576 	}
577 
578 	public void _setQueryTimeout(int seconds) {
579 	}
580 
581 	/**
582 	 * @return the mockResultSets
583 	 */
584 	public List<MockResultSet> getMockResultSets() {
585 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
586 		return mockResultSets;
587 	}
588 
589 	protected void autoClose() {
590 		assertThat(mockState, AnyOf.anyOf(IsNot.not(StatementState.CLOSE), IsNot.not(StatementState.AUTOCLOSE)));
591 		this.mockState=StatementState.AUTOCLOSE;
592 	}
593 
594 	public void complete() {
595 		mockState = StatementState.COMPLETE;
596 	}
597 
598 	public long getId() {
599 		// TODO Auto-generated method stub
600 		return id;
601 	}
602 
603 	public void setParent(MockConnection mockConnection) {
604 		this.parent = mockConnection;
605 	}
606 
607 	public void setId(int id) {
608 		this.id = id;
609 	}
610 
611 	public void setResultType(int resultSetType) {
612 		this.resultSetType = resultSetType;
613 	}
614 
615 	public void setResultSetConcurrency(int resultSetConcurrency) {
616 		this.resultSetConcurrency = resultSetConcurrency;
617 	}
618 
619 	public void setHoldability(int resultSetHoldability) {
620 		this.resultSetHoldability = resultSetHoldability;
621 	}
622 	
623 	public void assertExplicitClose() {
624 		assertThat(mockState, Is.is(StatementState.CLOSE));
625 		for(MockResultSet rs: mockResultSets){
626 			rs.assertExplicitClose();
627 		}
628 	}
629 
630 	//CLOSE is super-state of AUTOCLOSE
631 	public void assertClosed() {
632 		assertThat(mockState, AnyOf.anyOf(Is.is(StatementState.CLOSE), Is.is(StatementState.AUTOCLOSE)));
633 		for(MockResultSet rs: mockResultSets){
634 			rs.assertClosed();
635 		}
636 	}
637 	
638 	@Override
639 	public String toString(){
640 		return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
641 	}
642 }