1 21 22 package org.dbunit.database.statement; 23 24 import com.mockobjects.ExpectationCounter; 25 import com.mockobjects.Verifiable; 26 import org.dbunit.database.IDatabaseConnection; 27 28 import java.sql.SQLException ; 29 30 35 public class MockStatementFactory implements IStatementFactory, Verifiable 36 { 37 private IBatchStatement _batchStatement = null; 38 private ExpectationCounter _createStatementCalls = 40 new ExpectationCounter("MockStatementFactory.createBatchStatement");; 41 private ExpectationCounter _createPreparedStatementCalls = 42 new ExpectationCounter("MockStatementFactory.createPreparedBatchStatement");; 43 44 public void setupStatement(IBatchStatement batchStatement) 45 { 46 _batchStatement = batchStatement; 47 } 48 49 54 public void setExpectedCreateStatementCalls(int callsCount) 55 { 56 _createStatementCalls.setExpected(callsCount); 57 } 58 59 public void setExpectedCreatePreparedStatementCalls(int callsCount) 60 { 61 _createPreparedStatementCalls.setExpected(callsCount); 62 } 63 64 65 68 public void verify() 69 { 70 _createStatementCalls.verify(); 71 _createPreparedStatementCalls.verify(); 72 } 73 74 77 public IBatchStatement createBatchStatement(IDatabaseConnection connection) 78 throws SQLException 79 { 80 _createStatementCalls.inc(); 81 return _batchStatement; 82 } 83 84 public IPreparedBatchStatement createPreparedBatchStatement(String sql, 85 IDatabaseConnection connection) throws SQLException 86 { 87 _createPreparedStatementCalls.inc(); 88 return new BatchStatementDecorator(sql, _batchStatement); 89 } 90 } 91 92 93 94 | Popular Tags |