|
|
@ -36,6 +36,7 @@ import org.apache.kafka.common.serialization.LongDeserializer;
|
|
|
|
import org.apache.kafka.common.serialization.LongSerializer;
|
|
|
|
import org.apache.kafka.common.serialization.LongSerializer;
|
|
|
|
import org.apache.kafka.streams.StreamsBuilder;
|
|
|
|
import org.apache.kafka.streams.StreamsBuilder;
|
|
|
|
import org.apache.kafka.streams.StreamsConfig;
|
|
|
|
import org.apache.kafka.streams.StreamsConfig;
|
|
|
|
|
|
|
|
import org.assertj.core.api.InstanceOfAssertFactories;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
@ -50,6 +51,7 @@ import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
|
|
|
import org.springframework.kafka.config.KafkaListenerContainerFactory;
|
|
|
|
import org.springframework.kafka.config.KafkaListenerContainerFactory;
|
|
|
|
import org.springframework.kafka.config.KafkaStreamsConfiguration;
|
|
|
|
import org.springframework.kafka.config.KafkaStreamsConfiguration;
|
|
|
|
import org.springframework.kafka.config.StreamsBuilderFactoryBean;
|
|
|
|
import org.springframework.kafka.config.StreamsBuilderFactoryBean;
|
|
|
|
|
|
|
|
import org.springframework.kafka.core.CleanupConfig;
|
|
|
|
import org.springframework.kafka.core.ConsumerFactory;
|
|
|
|
import org.springframework.kafka.core.ConsumerFactory;
|
|
|
|
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
|
|
|
|
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
|
|
|
|
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
|
|
|
|
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
|
|
|
@ -340,6 +342,26 @@ class KafkaAutoConfigurationTests {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void streamsWithCleanupConfig() {
|
|
|
|
|
|
|
|
this.contextRunner
|
|
|
|
|
|
|
|
.withUserConfiguration(EnableKafkaStreamsConfiguration.class, TestKafkaStreamsConfiguration.class)
|
|
|
|
|
|
|
|
.withPropertyValues("spring.application.name=my-test-app",
|
|
|
|
|
|
|
|
"spring.kafka.bootstrap-servers=localhost:9092,localhost:9093",
|
|
|
|
|
|
|
|
"spring.kafka.streams.auto-startup=false", "spring.kafka.streams.cleanup.on-startup=true",
|
|
|
|
|
|
|
|
"spring.kafka.streams.cleanup.on-shutdown=false")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
StreamsBuilderFactoryBean streamsBuilderFactoryBean = context
|
|
|
|
|
|
|
|
.getBean(StreamsBuilderFactoryBean.class);
|
|
|
|
|
|
|
|
assertThat(streamsBuilderFactoryBean)
|
|
|
|
|
|
|
|
.extracting("cleanupConfig", InstanceOfAssertFactories.type(CleanupConfig.class))
|
|
|
|
|
|
|
|
.satisfies((cleanupConfig) -> {
|
|
|
|
|
|
|
|
assertThat(cleanupConfig.cleanupOnStart()).isTrue();
|
|
|
|
|
|
|
|
assertThat(cleanupConfig.cleanupOnStop()).isFalse();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void streamsApplicationIdIsMandatory() {
|
|
|
|
void streamsApplicationIdIsMandatory() {
|
|
|
|
this.contextRunner.withUserConfiguration(EnableKafkaStreamsConfiguration.class).run((context) -> {
|
|
|
|
this.contextRunner.withUserConfiguration(EnableKafkaStreamsConfiguration.class).run((context) -> {
|
|
|
|