Add @EnableTestBinder annotation (#2947)
* Add @EnableTestBinder annotation * Use @EnableTestBinder in tests * Update copyright and author tag * Add javadoc * Update explanation to use @EnableTestBinder Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2931
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2023 the original author or authors.
|
||||
* Copyright 2017-2024 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.
|
||||
@@ -29,14 +29,13 @@ import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.function.json.JsonMapper;
|
||||
import org.springframework.cloud.stream.binder.test.EnableTestBinder;
|
||||
import org.springframework.cloud.stream.binder.test.InputDestination;
|
||||
import org.springframework.cloud.stream.binder.test.OutputDestination;
|
||||
import org.springframework.cloud.stream.binder.test.TestChannelBinder;
|
||||
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
@@ -58,6 +57,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Byungjun You
|
||||
* @author Kotaro Matsumoto
|
||||
*
|
||||
*/
|
||||
class ContentTypeTckTests {
|
||||
@@ -518,7 +518,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class CollectionWithParameterizedTypes {
|
||||
|
||||
@@ -531,7 +531,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class PojoToPojoConfiguration {
|
||||
|
||||
@@ -541,7 +541,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class PojoToStringConfiguration {
|
||||
|
||||
@@ -551,7 +551,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class PojoToByteArrayConfiguration {
|
||||
|
||||
@@ -561,7 +561,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class ByteArrayToPojoConfiguration {
|
||||
|
||||
@@ -571,7 +571,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class StringToPojoConfiguration {
|
||||
|
||||
@@ -581,7 +581,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class TypelessToPojoConfiguration {
|
||||
|
||||
@@ -593,7 +593,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class TypelessMessageToPojoConfiguration {
|
||||
|
||||
@@ -605,7 +605,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class TypelessToMessageConfiguration {
|
||||
|
||||
@@ -616,7 +616,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class TypelessToMessageTextOnlyContentTypeConfiguration {
|
||||
|
||||
@@ -630,7 +630,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class ByteArrayToByteArrayConfiguration {
|
||||
|
||||
@@ -640,7 +640,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class StringToStringConfiguration {
|
||||
|
||||
@@ -650,7 +650,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class StringToMapMessageConfiguration {
|
||||
|
||||
@@ -663,7 +663,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class PojoMessageToStringMessageConfiguration {
|
||||
|
||||
@@ -799,7 +799,7 @@ class ContentTypeTckTests {
|
||||
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class MapInputConfiguration {
|
||||
|
||||
@@ -809,7 +809,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class ListInputConfiguration {
|
||||
@Bean
|
||||
@@ -818,7 +818,7 @@ class ContentTypeTckTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class MessageHeadersInputConfiguration {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2023 the original author or authors.
|
||||
* Copyright 2015-2024 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.
|
||||
@@ -52,7 +52,7 @@ import org.springframework.cloud.stream.binder.ConsumerProperties;
|
||||
import org.springframework.cloud.stream.binder.DefaultBinderFactory;
|
||||
import org.springframework.cloud.stream.binder.DefaultBinderTypeRegistry;
|
||||
import org.springframework.cloud.stream.binder.ProducerProperties;
|
||||
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
|
||||
import org.springframework.cloud.stream.binder.test.EnableTestBinder;
|
||||
import org.springframework.cloud.stream.config.BindingProperties;
|
||||
import org.springframework.cloud.stream.config.BindingServiceConfiguration;
|
||||
import org.springframework.cloud.stream.config.BindingServiceProperties;
|
||||
@@ -61,7 +61,6 @@ import org.springframework.cloud.stream.utils.IntegrationTestsMockBinderConfigur
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -90,6 +89,7 @@ import static org.mockito.Mockito.when;
|
||||
* @author Michael Michailidis
|
||||
* @author Chris Bono
|
||||
* @author Artem Bilan
|
||||
* @author Kotaro Matsumoto
|
||||
*/
|
||||
class BindingServiceTests {
|
||||
|
||||
@@ -591,13 +591,13 @@ class BindingServiceTests {
|
||||
return bindingServiceProperties;
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class DefaultConsumerPropertiesTestSink {
|
||||
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class FooConfiguration {
|
||||
|
||||
@@ -608,7 +608,7 @@ class BindingServiceTests {
|
||||
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class BarConfiguration {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2023 the original author or authors.
|
||||
* Copyright 2018-2024 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.
|
||||
@@ -29,9 +29,8 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesBindException;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
|
||||
import org.springframework.cloud.stream.binder.test.EnableTestBinder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -41,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Soby Chacko
|
||||
* @author Kotaro Matsumoto
|
||||
*
|
||||
*/
|
||||
class BindingHandlerAdviseTests {
|
||||
@@ -76,7 +76,7 @@ class BindingHandlerAdviseTests {
|
||||
.run("--spring.jmx.enabled=false"));
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class NonValidatedConfiguration {
|
||||
|
||||
@@ -105,7 +105,7 @@ class BindingHandlerAdviseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class ValidatedConfiguration {
|
||||
|
||||
@@ -136,7 +136,7 @@ class BindingHandlerAdviseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
@EnableConfigurationProperties(ValidatedProps.class)
|
||||
class SampleConfiguration {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2023 the original author or authors.
|
||||
* Copyright 2018-2024 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.
|
||||
@@ -29,10 +29,9 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.stream.annotation.StreamRetryTemplate;
|
||||
import org.springframework.cloud.stream.binder.AbstractBinder;
|
||||
import org.springframework.cloud.stream.binder.ConsumerProperties;
|
||||
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
|
||||
import org.springframework.cloud.stream.binder.test.EnableTestBinder;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -40,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Soby Chacko
|
||||
* @author Kotaro Matsumoto
|
||||
*/
|
||||
class RetryTemplateTests {
|
||||
|
||||
@@ -82,7 +82,7 @@ class RetryTemplateTests {
|
||||
assertThat(retryTemplate).isEqualTo(retryTemplateTwo);
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class SpecificCustomRetryTemplateConfiguration {
|
||||
|
||||
@@ -107,7 +107,7 @@ class RetryTemplateTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@EnableTestBinder
|
||||
@EnableAutoConfiguration
|
||||
public static class SingleCustomRetryTemplateConfiguration {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user