use of com.zaxxer.hikari.pool.HikariProxyConnection in project backend by CatalogueOfLife.
the class InitDbUtils method toPgConnection.
public static PgConnection toPgConnection(Connection c) throws SQLException {
PgConnection pgc;
if (c instanceof HikariProxyConnection) {
HikariProxyConnection hpc = (HikariProxyConnection) c;
pgc = hpc.unwrap(PgConnection.class);
} else {
pgc = (PgConnection) c;
}
return pgc;
}
use of com.zaxxer.hikari.pool.HikariProxyConnection in project pxf by greenplum-db.
the class ConnectionManagerTest method testGetConnectionPoolEnabledNoPoolProps.
@Test
public void testGetConnectionPoolEnabledNoPoolProps() throws SQLException {
Driver mockDriver = mock(Driver.class);
when(mockDriverManagerWrapper.getDriver("test-url")).thenReturn(mockDriver);
when(mockDriver.connect("test-url", connProps)).thenReturn(mockConnection);
when(mockDriver.acceptsURL("test-url")).thenReturn(true);
DriverManager.registerDriver(mockDriver);
Driver mockDriver2 = mock(Driver.class);
when(mockDriverManagerWrapper.getDriver("test-url-2")).thenReturn(mockDriver2);
Connection mockConnection2 = mock(Connection.class);
when(mockDriver2.connect("test-url-2", connProps)).thenReturn(mockConnection2);
when(mockDriver2.acceptsURL("test-url-2")).thenReturn(true);
DriverManager.registerDriver(mockDriver2);
Connection conn;
for (int i = 0; i < 5; i++) {
conn = manager.getConnection("test-server", "test-url", connProps, true, poolProps, null);
assertNotNull(conn);
assertTrue(conn instanceof HikariProxyConnection);
assertSame(mockConnection, conn.unwrap(Connection.class));
conn.close();
}
Connection conn2 = manager.getConnection("test-server", "test-url-2", connProps, true, poolProps, null);
assertNotNull(conn2);
assertTrue(conn2 instanceof HikariProxyConnection);
assertSame(mockConnection2, conn2.unwrap(Connection.class));
verify(mockDriver, times(1)).connect("test-url", connProps);
verify(mockDriver2, times(1)).connect("test-url-2", connProps);
DriverManager.deregisterDriver(mockDriver);
DriverManager.deregisterDriver(mockDriver2);
}
Aggregations