2222import io .rsocket .transport .ClientTransport ;
2323import io .rsocket .transport .netty .client .TcpClientTransport ;
2424import org .junit .jupiter .api .Test ;
25- import reactor .core .publisher .Mono ;
2625
2726import org .springframework .beans .DirectFieldAccessor ;
2827import org .springframework .boot .autoconfigure .AutoConfigurations ;
28+ import org .springframework .boot .autoconfigure .flyway .FlywayAutoConfiguration ;
2929import org .springframework .boot .autoconfigure .integration .IntegrationAutoConfiguration .IntegrationComponentScanConfiguration ;
3030import org .springframework .boot .autoconfigure .jdbc .DataSourceAutoConfiguration ;
3131import org .springframework .boot .autoconfigure .jdbc .DataSourceTransactionManagerAutoConfiguration ;
4949import org .springframework .integration .annotation .MessagingGateway ;
5050import org .springframework .integration .config .IntegrationManagementConfigurer ;
5151import org .springframework .integration .context .IntegrationContextUtils ;
52- import org .springframework .integration .core .MessageSource ;
5352import org .springframework .integration .endpoint .MessageProcessorMessageSource ;
5453import org .springframework .integration .gateway .RequestReplyExchanger ;
55- import org .springframework .integration .handler .MessageProcessor ;
5654import org .springframework .integration .rsocket .ClientRSocketConnector ;
5755import org .springframework .integration .rsocket .IntegrationRSocketEndpoint ;
5856import org .springframework .integration .rsocket .ServerRSocketConnector ;
@@ -170,6 +168,27 @@ void integrationJdbcDataSourceInitializerEnabled() {
170168 });
171169 }
172170
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+
173192 @ Test
174193 void integrationJdbcDataSourceInitializerDisabled () {
175194 this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class )
@@ -398,8 +417,9 @@ interface TestGateway extends RequestReplyExchanger {
398417 static class MessageSourceConfiguration {
399418
400419 @ 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 ));
403423 }
404424
405425 }
@@ -412,7 +432,7 @@ IntegrationRSocketEndpoint mockIntegrationRSocketEndpoint() {
412432 return new IntegrationRSocketEndpoint () {
413433
414434 @ Override
415- public Mono <Void > handleMessage (Message <?> message ) {
435+ public reactor . core . publisher . Mono <Void > handleMessage (Message <?> message ) {
416436 return null ;
417437 }
418438
0 commit comments