use of org.apache.commons.dbutils.AsyncQueryRunner in project tutorials by eugenp.
the class DbUtilsUnitTest method givenAsyncRunner_whenExecutingQuery_thenExpectedList.
@Test
public void givenAsyncRunner_whenExecutingQuery_thenExpectedList() throws Exception {
AsyncQueryRunner runner = new AsyncQueryRunner(Executors.newCachedThreadPool());
EmployeeHandler employeeHandler = new EmployeeHandler(connection);
String query = "SELECT * FROM employee";
Future<List<Employee>> future = runner.query(connection, query, employeeHandler);
List<Employee> employeeList = future.get(10, TimeUnit.SECONDS);
assertEquals(employeeList.size(), 5);
}
Aggregations