I need to write a JUnit Test, which tests reading from one database schema and writing to another. I have liquibase changelogs from two applications which own their respective database schemas, to define the databases.
The liquibase changelogs use classpath: urls to import subordinate changelogs. That is a feature of Bootique's liquibase support, which the other applications use to run their changelogs.
I have managed to run one of the changelogs for one database by using Bootique's Liquibase support in my test, but I cannot run the second one against the same schema; both changelogs contain DDL that conflicts, when run against the same schema - besides, there would only be one changelog table for two changelogs. So each changelog needs to be applied to its own schema.
Unfortunately, Bootique's Liquibase support does not seem to allow me to run two changelogs against two different schemas. Its JUnit4 support can define two database connections, but it can only apply Liquibase changelogs to one of them (here: test):
jdbc:
test:
url: jdbc:derby:target/derby/migrations1;create=true
maxActive: 2
liquibase:
datasource: test
changeLogs:
- classpath:io.bootique.liquibase.demo/changeset1.sql
Likewise, the JUnit5 integration does not allow me to specify the database schema to use:
@BQTest
public class DerbyTest {
@BQTestTool
static final DbTester tester = DerbyTester.db();
}
https://bootique.io/docs/2.x/bootique-jdbc-docs/#_in_memory_derby_db
So my question is: how can I run two different Liquibase changelogs with classpath:
URLs inside against two different in-memory database schemas in a JUnit test of a non-Spring Boot application?