private static synchronized PrepPipeline createOrFindPreparer ( DatabasePreparer preparer , Iterable < Consumer < Builder > > customizers ) throws IOException , SQLException { final ClusterKey key = new ClusterKey ( preparer , customizers ) ; PrepPipeline result = CLUSTERS . get ( key ) ; if ( result != null ) { return result ; } final Builder builder = EmbeddedPostgres . builder ( ) ; customizers . forEach ( c -> c . accept ( builder ) ) ; final EmbeddedPostgres pg = builder . start ( ) ; preparer . prepare ( pg . getTemplateDatabase ( ) ) ; result = new PrepPipeline ( pg ) . start ( ) ; CLUSTERS . put ( key , result ) ; return result ; }
Each schema set has its own database cluster . The template1 database has the schema preloaded so that each test case need only create a new database and not re - invoke your preparer .