use of org.davidmoten.rx.jdbc.Database in project rxjava2-jdbc by davidmoten.
the class PoolTest method testConnectionPoolRecylesMany.
@Test
public void testConnectionPoolRecylesMany() throws SQLException {
Database db = DatabaseCreator.create(2);
TestSubscriber<Connection> ts = //
db.connections().test(//
4);
//
ts.assertNoErrors().assertValueCount(//
2).assertNotTerminated();
List<Connection> list = new ArrayList<>(ts.values());
// should release a connection
list.get(1).close();
//
ts.assertValueCount(3).assertNotTerminated().assertValues(list.get(0), list.get(1), list.get(1));
list.get(0).close();
//
ts.assertValues(list.get(0), list.get(1), list.get(1), list.get(0)).assertValueCount(//
4).assertNotTerminated();
}
use of org.davidmoten.rx.jdbc.Database in project rxjava2-jdbc by davidmoten.
the class PoolTest method testConnectionPoolRecylesFirst.
@Test
public void testConnectionPoolRecylesFirst() {
Database db = DatabaseCreator.create(2);
TestSubscriber<Connection> ts = //
db.connections().doOnNext(//
System.out::println).doOnNext(c -> {
c.close();
}).test(//
4);
//
ts.assertValueCount(4).assertNotTerminated();
List<Object> list = ts.getEvents().get(0);
// all 4 connections released were the same
assertTrue(list.get(0) == list.get(1));
assertTrue(list.get(0) == list.get(2));
assertTrue(list.get(0) == list.get(3));
}
Aggregations