use of com.zaxxer.hikari.mocks.StubStatement in project HikariCP by brettwooldridge.
the class TestFastList method testOverflow.
@Test
public void testOverflow() {
ArrayList<Statement> verifyList = new ArrayList<>();
FastList<Statement> list = new FastList<>(Statement.class);
for (int i = 0; i < 100; i++) {
StubStatement statement = new StubStatement(null);
list.add(statement);
verifyList.add(statement);
}
for (int i = 0; i < 100; i++) {
assertNotNull("Element " + i, list.get(i));
assertSame(verifyList.get(i), list.get(i));
}
}
use of com.zaxxer.hikari.mocks.StubStatement in project HikariCP by brettwooldridge.
the class TestProxies method testStatementProxy.
@Test
public void testStatementProxy() throws SQLException {
HikariConfig config = newHikariConfig();
config.setMinimumIdle(0);
config.setMaximumPoolSize(1);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
try (HikariDataSource ds = new HikariDataSource(config)) {
Connection conn = ds.getConnection();
PreparedStatement stmt = conn.prepareStatement("some sql");
stmt.executeQuery();
stmt.executeQuery("some sql");
assertFalse(stmt.isClosed());
assertNotNull(stmt.getGeneratedKeys());
assertNotNull(stmt.getResultSet());
assertNotNull(stmt.getConnection());
assertTrue(stmt.unwrap(StubStatement.class) instanceof StubStatement);
try {
stmt.unwrap(TestProxies.class);
fail();
} catch (SQLException e) {
// pass
}
}
}
Aggregations