20
20
import org .junit .Test ;
21
21
22
22
import org .springframework .boot .autoconfigure .jdbc .DataSourceAutoConfiguration ;
23
+ import org .springframework .boot .autoconfigure .jdbc .EmbeddedDataSourceConfiguration ;
23
24
import org .springframework .boot .autoconfigure .liquibase .LiquibaseAutoConfiguration ;
24
25
import org .springframework .boot .test .util .TestPropertyValues ;
25
26
import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
@@ -48,18 +49,19 @@ public void invoke() throws Exception {
48
49
49
50
@ Test
50
51
public void invokeWithCustomSchema () throws Exception {
52
+ this .context .close ();
51
53
this .context = new AnnotationConfigApplicationContext ();
52
54
TestPropertyValues .of ("liquibase.default-schema=CUSTOMSCHEMA" ,
53
55
"spring.datasource.generate-unique-name=true" ,
54
56
"spring.datasource.schema=classpath:/db/create-custom-schema.sql" )
55
57
.applyTo (this .context );
56
- this .context .register (Config .class );
58
+ this .context .register (CustomSchemaConfig .class );
57
59
this .context .refresh ();
58
60
assertThat (getEndpointBean ().invoke ()).hasSize (1 );
59
61
}
60
62
61
63
@ Configuration
62
- @ Import ({ DataSourceAutoConfiguration .class , LiquibaseAutoConfiguration .class })
64
+ @ Import ({ EmbeddedDataSourceConfiguration .class , LiquibaseAutoConfiguration .class })
63
65
public static class Config {
64
66
65
67
private final SpringLiquibase liquibase ;
@@ -75,4 +77,21 @@ public LiquibaseEndpoint endpoint() {
75
77
76
78
}
77
79
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
+
78
97
}
0 commit comments