22
22
import io .rsocket .transport .ClientTransport ;
23
23
import io .rsocket .transport .netty .client .TcpClientTransport ;
24
24
import org .junit .jupiter .api .Test ;
25
- import reactor .core .publisher .Mono ;
26
25
27
26
import org .springframework .beans .DirectFieldAccessor ;
28
27
import org .springframework .boot .autoconfigure .AutoConfigurations ;
28
+ import org .springframework .boot .autoconfigure .flyway .FlywayAutoConfiguration ;
29
29
import org .springframework .boot .autoconfigure .integration .IntegrationAutoConfiguration .IntegrationComponentScanConfiguration ;
30
30
import org .springframework .boot .autoconfigure .jdbc .DataSourceAutoConfiguration ;
31
31
import org .springframework .boot .autoconfigure .jdbc .DataSourceTransactionManagerAutoConfiguration ;
49
49
import org .springframework .integration .annotation .MessagingGateway ;
50
50
import org .springframework .integration .config .IntegrationManagementConfigurer ;
51
51
import org .springframework .integration .context .IntegrationContextUtils ;
52
- import org .springframework .integration .core .MessageSource ;
53
52
import org .springframework .integration .endpoint .MessageProcessorMessageSource ;
54
53
import org .springframework .integration .gateway .RequestReplyExchanger ;
55
- import org .springframework .integration .handler .MessageProcessor ;
56
54
import org .springframework .integration .rsocket .ClientRSocketConnector ;
57
55
import org .springframework .integration .rsocket .IntegrationRSocketEndpoint ;
58
56
import org .springframework .integration .rsocket .ServerRSocketConnector ;
@@ -170,6 +168,27 @@ void integrationJdbcDataSourceInitializerEnabled() {
170
168
});
171
169
}
172
170
171
+ @ Test
172
+ void whenIntegrationJdbcDataSourceInitializerIsEnabledThenFlywayCanBeUsed () {
173
+ this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class )
174
+ .withConfiguration (AutoConfigurations .of (DataSourceTransactionManagerAutoConfiguration .class ,
175
+ JdbcTemplateAutoConfiguration .class , IntegrationAutoConfiguration .class ,
176
+ FlywayAutoConfiguration .class ))
177
+ .withPropertyValues ("spring.datasource.generate-unique-name=true" ,
178
+ "spring.integration.jdbc.initialize-schema=always" )
179
+ .run ((context ) -> {
180
+ IntegrationProperties properties = context .getBean (IntegrationProperties .class );
181
+ assertThat (properties .getJdbc ().getInitializeSchema ())
182
+ .isEqualTo (DataSourceInitializationMode .ALWAYS );
183
+ JdbcOperations jdbc = context .getBean (JdbcOperations .class );
184
+ assertThat (jdbc .queryForList ("select * from INT_MESSAGE" )).isEmpty ();
185
+ assertThat (jdbc .queryForList ("select * from INT_GROUP_TO_MESSAGE" )).isEmpty ();
186
+ assertThat (jdbc .queryForList ("select * from INT_MESSAGE_GROUP" )).isEmpty ();
187
+ assertThat (jdbc .queryForList ("select * from INT_LOCK" )).isEmpty ();
188
+ assertThat (jdbc .queryForList ("select * from INT_CHANNEL_MESSAGE" )).isEmpty ();
189
+ });
190
+ }
191
+
173
192
@ Test
174
193
void integrationJdbcDataSourceInitializerDisabled () {
175
194
this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class )
@@ -398,8 +417,9 @@ interface TestGateway extends RequestReplyExchanger {
398
417
static class MessageSourceConfiguration {
399
418
400
419
@ Bean
401
- MessageSource <?> myMessageSource () {
402
- return new MessageProcessorMessageSource (mock (MessageProcessor .class ));
420
+ org .springframework .integration .core .MessageSource <?> myMessageSource () {
421
+ return new MessageProcessorMessageSource (
422
+ mock (org .springframework .integration .handler .MessageProcessor .class ));
403
423
}
404
424
405
425
}
@@ -412,7 +432,7 @@ IntegrationRSocketEndpoint mockIntegrationRSocketEndpoint() {
412
432
return new IntegrationRSocketEndpoint () {
413
433
414
434
@ Override
415
- public Mono <Void > handleMessage (Message <?> message ) {
435
+ public reactor . core . publisher . Mono <Void > handleMessage (Message <?> message ) {
416
436
return null ;
417
437
}
418
438
0 commit comments