Disable DB init for JDBC Source and Sink (#325)

* Disable DB init for JDBC Source and Sink

The `IntegrationAutoConfiguration` provides mechanism
to initialize DB with some out-of-the-box scripts.
The default behavior is `EMBEDDED` even if we don't use
any components for those DB objects, e.g. no `JdbcMessageStore` bean.

* Add `spring.integration.jdbc.initialize-schema=NEVER` to the
`jdbc-consumer` and `jdbc-supplier` to not attempt to initialize DB
* Fix Checkstyle violations in other modules
This commit is contained in:
Artem Bilan
2022-09-21 11:31:18 -04:00
committed by GitHub
parent 90cb6d7e6a
commit 2c5d83f926
5 changed files with 21 additions and 3 deletions

View File

@@ -0,0 +1 @@
spring.integration.jdbc.initialize-schema=NEVER

View File

@@ -23,7 +23,6 @@ import java.util.function.Function;
import reactor.core.publisher.Flux;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;

View File

@@ -0,0 +1 @@
spring.integration.jdbc.initialize-schema=NEVER

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2020 the original author or authors.
* Copyright 2020-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,10 +26,13 @@ import reactor.test.StepVerifier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.messaging.Message;
import org.springframework.test.annotation.DirtiesContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = "jdbc.supplier.query=select id, name from test order by id")
@@ -39,6 +42,9 @@ public class DefaultJdbcSupplierTests {
@Autowired
Supplier<Flux<Message<?>>> jdbcSupplier;
@Autowired
JdbcTemplate jdbcTemplate;
@Test
void testExtraction() {
final Flux<Message<?>> messageFlux = jdbcSupplier.get();
@@ -76,6 +82,18 @@ public class DefaultJdbcSupplierTests {
stepVerifier.verify();
}
/*
The test to verify that DB is not initialized with Spring Integration DDL
(spring.integration.jdbc.initialize-schema=NEVER) what happens by default via IntegrationAutoConfiguration.IntegrationJdbcConfiguration.
This is not a functionality of this JDBC Supplier.
*/
@Test
void verifyNoIntMessageGroupTable() {
assertThatExceptionOfType(BadSqlGrammarException.class)
.isThrownBy(() -> this.jdbcTemplate.queryForList("SELECT * FROM INT_MESSAGE_GROUP"))
.withMessageContaining("Table \"INT_MESSAGE_GROUP\" not found;");
}
@SpringBootApplication
static class JdbcSupplierTestApplication {
}

View File

@@ -24,7 +24,6 @@ import java.util.function.Supplier;
import javax.mail.URLName;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import org.springframework.beans.factory.annotation.Autowired;