Skip to content

Database connection

Lukas Cardot edited this page Feb 16, 2020 · 1 revision

Database connection

To specify on which database the assertion will be made you can define a specific connection. If you use the same database for several assertions, you should use the Builder to avoid too many connections on the same database.

JDBC

assertThatQuery("SELECT id, code, label FROM table_test")
     .using(DriverManager.getConnection("jdbc://localhost:5432/database-name", "username", "password"))
     .isValidAgainst(loadFile("table_currency_expected.json"));

Cassandra

CQL:

assertThatCollection("select * from cassandra_table_type")
     .using(new CassandraDataSource("cassandra_dc_test", "localhost", 5425))
     .isValidAgainst(loadFile("table_currency_expected.json"));

Query Builder:

assertThatCollection(QueryBuilder.selectFrom("cassandratest", "cassandra_table_type").all())
     .using(new CassandraDataSource("cassandra_dc_test", "localhost", 5425))
     .isValidAgainst(loadFile("table_currency_expected.json"));
Clone this wiki locally