@Test(expected = SystemException.class) public void testGetConnection_FailToLoadDriver() throws Exception { ComboPooledDataSource cpds = createMock(ComboPooledDataSource.class); expectNew(ComboPooledDataSource.class).andReturn(cpds); cpds.setDriverClass("org.postgresql.Driver"); expectLastCall().andThrow(new RuntimeException("driver not found")); replay(cpds, ComboPooledDataSource.class); datasource.getConnection("host", "port", "user", "password"); }
Connection getConnection(String host, String port, String user, String password) throws SystemException, SQLException { LOG.debug("Getting connection for = {}:{}:{}", host, port, user); String key = composeKey(host, port, user, password); if (!key.equals(dataSourceKey)) { resetDataSource(host, port, user, password); } Connection conn = dataSource.getConnection(); LOG.debug("Acquired connection = {}", conn); return conn; }
HAWQDataSource { Connection getConnection(String host, String port, String user, String password) throws SystemException, SQLException { LOG.debug("Getting connection for = {}:{}:{}", host, port, user); String key = composeKey(host, port, user, password); if (!key.equals(dataSourceKey)) { resetDataSource(host, port, user, password); } Connection conn = dataSource.getConnection(); LOG.debug("Acquired connection = {}", conn); return conn; } }
HAWQDataSource { Connection getConnection(String host, String port, String user, String password) throws SystemException, SQLException { LOG.debug("Getting connection for = {}:{}:{}", host, port, user); String key = composeKey(host, port, user, password); if (!key.equals(dataSourceKey)) { resetDataSource(host, port, user, password); } Connection conn = dataSource.getConnection(); LOG.debug("Acquired connection = {}", conn); return conn; }  }
HAWQDataSource { Connection getConnection(String host, String port, String user, String password) throws SystemException, SQLException { LOG.debug("Getting connection for = {}:{}:{}", host, port, user); String key = composeKey(host, port, user, password); if (!key.equals(dataSourceKey)) { resetDataSource(host, port, user, password); } Connection conn = dataSource.getConnection(); LOG.debug("Acquired connection = {}", conn); return conn; }   }
HAWQDataSource { Connection getConnection(String host, String port, String user, String password) throws SystemException, SQLException { LOG.debug("Getting connection for = {}:{}:{}", host, port, user); String key = composeKey(host, port, user, password); if (!key.equals(dataSourceKey)) { resetDataSource(host, port, user, password); } Connection conn = dataSource.getConnection(); LOG.debug("Acquired connection = {}", conn); return conn; }    }