2020import org .junit .Test ;
2121
2222import org .springframework .boot .autoconfigure .jdbc .DataSourceAutoConfiguration ;
23+ import org .springframework .boot .autoconfigure .jdbc .EmbeddedDataSourceConfiguration ;
2324import org .springframework .boot .autoconfigure .liquibase .LiquibaseAutoConfiguration ;
2425import org .springframework .boot .test .util .TestPropertyValues ;
2526import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
@@ -48,18 +49,19 @@ public void invoke() throws Exception {
4849
4950 @ Test
5051 public void invokeWithCustomSchema () throws Exception {
52+ this .context .close ();
5153 this .context = new AnnotationConfigApplicationContext ();
5254 TestPropertyValues .of ("liquibase.default-schema=CUSTOMSCHEMA" ,
5355 "spring.datasource.generate-unique-name=true" ,
5456 "spring.datasource.schema=classpath:/db/create-custom-schema.sql" )
5557 .applyTo (this .context );
56- this .context .register (Config .class );
58+ this .context .register (CustomSchemaConfig .class );
5759 this .context .refresh ();
5860 assertThat (getEndpointBean ().invoke ()).hasSize (1 );
5961 }
6062
6163 @ Configuration
62- @ Import ({ DataSourceAutoConfiguration .class , LiquibaseAutoConfiguration .class })
64+ @ Import ({ EmbeddedDataSourceConfiguration .class , LiquibaseAutoConfiguration .class })
6365 public static class Config {
6466
6567 private final SpringLiquibase liquibase ;
@@ -75,4 +77,21 @@ public LiquibaseEndpoint endpoint() {
7577
7678 }
7779
80+ @ Configuration
81+ @ Import ({ DataSourceAutoConfiguration .class , LiquibaseAutoConfiguration .class })
82+ public static class CustomSchemaConfig {
83+
84+ private final SpringLiquibase liquibase ;
85+
86+ public CustomSchemaConfig (SpringLiquibase liquibase ) {
87+ this .liquibase = liquibase ;
88+ }
89+
90+ @ Bean
91+ public LiquibaseEndpoint endpoint () {
92+ return new LiquibaseEndpoint (this .liquibase );
93+ }
94+
95+ }
96+
7897}
0 commit comments