mock refactor

This commit is contained in:
温少
2012-06-06 08:40:01 +08:00
parent c509b2db6a
commit ffeb629f0d
7 changed files with 43 additions and 89 deletions
@@ -108,6 +108,10 @@ public class MockConnection extends ConnectionBase implements Connection {
throw new MockConnectionClosedException();
}
return createMockStatement();
}
private MockStatement createMockStatement() {
return new MockStatement(this);
}
@@ -189,7 +193,7 @@ public class MockConnection extends ConnectionBase implements Connection {
throw new MockConnectionClosedException();
}
MockStatement stmt = new MockStatement(this);
MockStatement stmt = createMockStatement();
stmt.setResultSetType(resultSetType);
stmt.setResultSetConcurrency(resultSetConcurrency);
@@ -273,7 +277,7 @@ public class MockConnection extends ConnectionBase implements Connection {
throw new MockConnectionClosedException();
}
MockStatement stmt = new MockStatement(this);
MockStatement stmt = createMockStatement();
stmt.setResultSetType(resultSetType);
stmt.setResultSetConcurrency(resultSetConcurrency);
@@ -300,10 +304,7 @@ public class MockConnection extends ConnectionBase implements Connection {
private MockPreparedStatement createMockPreparedStatement(String sql) {
if (driver != null) {
MockPreparedStatementFactory preparedStatementFactory = driver.getPreparedStatementFactory();
if (preparedStatementFactory != null) {
return preparedStatementFactory.createMockPreparedStatement(this, sql);
}
return driver.createMockPreparedStatement(this, sql);
}
return new MockPreparedStatement(this, sql);
}