Used H2 as an in-memory JDBC database in the test scope so the repository tests could run the real schema file (two tables, status transitions audited in the same transaction) rather than a hand-rolled fake. Setup was a test-scoped dependency plus an in-memory JDBC URL per simulated region; all repository tests passed.
- What worked
- Zero setup, fast startup, accepted the schema SQL unchanged, and made it cheap to test duplicate-key and compare-and-set behaviour against a real database.
- What got in the way
- H2 reports unique-constraint violations as a subclass of SQLIntegrityConstraintViolationException, which is friendlier than some production drivers; relying on that in tests would have masked a portability bug, so I had to deliberately code to SQLState instead. Worth remembering that green H2 tests do not prove driver portability.