use of io.vertx.mutiny.sqlclient.Pool in project smallrye-mutiny-vertx-bindings by smallrye.
the class DB2ClientTest method testTransaction.
@Test
public void testTransaction() {
DB2ConnectOptions options = new DB2ConnectOptions().setPort(container.getMappedPort(50000)).setHost(container.getContainerIpAddress()).setDatabase(container.getDatabaseName()).setUser(container.getUsername()).setPassword(container.getPassword());
Pool client = DB2Pool.pool(vertx, options, new PoolOptions().setMaxSize(5));
Uni<Void> uni = client.getConnection().onItem().transformToUni(c -> {
return c.begin().onItem().transformToUni(tx -> c.query("SELECT 1 FROM SYSIBM.SYSDUMMY1").execute().call(() -> c.query("SELECT 1 FROM SYSIBM.SYSDUMMY1").execute()).onItem().transformToUni(results -> tx.commit()).onFailure().recoverWithUni(t -> tx.rollback()));
});
Void v = uni.await().indefinitely();
assertThat(v).isNull();
}
use of io.vertx.mutiny.sqlclient.Pool in project smallrye-mutiny-vertx-bindings by smallrye.
the class PostGreSQLClientTest method testMutinyAPI.
@Test
public void testMutinyAPI() {
PgConnectOptions options = new PgConnectOptions().setPort(container.getMappedPort(5432)).setHost(container.getContainerIpAddress()).setDatabase(container.getDatabaseName()).setUser(container.getUsername()).setPassword(container.getPassword());
Pool client = PgPool.pool(vertx, options, new PoolOptions().setMaxSize(5));
RowSet<?> join = client.query("SELECT 1").executeAndAwait();
assertThat(join).isNotNull();
assertThat(join.size()).isEqualTo(1);
}
use of io.vertx.mutiny.sqlclient.Pool in project smallrye-mutiny-vertx-bindings by smallrye.
the class PostGreSQLClientTest method testSequence.
@Test
public void testSequence() {
PgConnectOptions options = new PgConnectOptions().setPort(container.getMappedPort(5432)).setHost(container.getContainerIpAddress()).setDatabase(container.getDatabaseName()).setUser(container.getUsername()).setPassword(container.getPassword());
Pool client = PgPool.pool(vertx, options, new PoolOptions().setMaxSize(5));
Uni<Tuple2<RowSet<Row>, RowSet<Row>>> uni = client.getConnection().flatMap(c -> Uni.combine().all().unis(c.preparedQuery("SELECT 1").execute(), c.preparedQuery("SELECT 1").execute()).asTuple());
Tuple2<RowSet<Row>, RowSet<Row>> results = uni.await().indefinitely();
assertThat(results).isNotNull();
assertThat(results.size()).isEqualTo(2);
assertThat(results.getItem1()).isNotNull();
assertThat(results.getItem2()).isNotNull();
}
use of io.vertx.mutiny.sqlclient.Pool in project smallrye-mutiny-vertx-bindings by smallrye.
the class MySQLClientTest method testMutinyAPI.
@Test
public void testMutinyAPI() {
MySQLConnectOptions options = new MySQLConnectOptions().setPort(container.getMappedPort(3306)).setHost(container.getContainerIpAddress()).setDatabase(MYSQL_DATABASE).setUser("root").setPassword(MYSQL_ROOT_PASSWORD);
Pool client = MySQLPool.pool(vertx, options, new PoolOptions().setMaxSize(5));
RowSet<?> join = client.query("SELECT 1").executeAndAwait();
assertThat(join).isNotNull();
assertThat(join.size()).isEqualTo(1);
}
use of io.vertx.mutiny.sqlclient.Pool in project smallrye-mutiny-vertx-bindings by smallrye.
the class SqlClientTemplateTest method test.
@Test
public void test() {
PgConnectOptions options = new PgConnectOptions().setPort(container.getMappedPort(5432)).setHost(container.getContainerIpAddress()).setDatabase(container.getDatabaseName()).setUser(container.getUsername()).setPassword(container.getPassword());
Pool client = PgPool.pool(vertx, options, new PoolOptions().setMaxSize(5));
Map<String, Object> parameters = Collections.singletonMap("id", 1);
assertThatThrownBy(() -> SqlTemplate.forQuery(client, "SELECT * FROM users WHERE id=#{id}").executeAndAwait(parameters)).isInstanceOf(// Table not created.
PgException.class);
}
Aggregations