Upgrade Spring Cloud Build to 2.1.0

This upgrades to Spring Boot 2.1.0
Fix tests where the beans need to get overridden
Minor cleaning up
Polishing

Resolves #1426
This commit is contained in:
Soby Chacko
2018-08-03 21:30:36 -04:00
committed by Oleg Zhurakousky
parent fa1b6257d5
commit cb105ab0ec
52 changed files with 211 additions and 35 deletions

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>2.0.2.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath/>
</parent>
<scm>

View File

@@ -41,7 +41,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { ContentTypeOutboundSourceTests.TestSource.class })
@SpringBootTest(classes = { ContentTypeOutboundSourceTests.TestSource.class },
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class ContentTypeOutboundSourceTests {
@Autowired

View File

@@ -44,7 +44,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = CustomHeaderPropagationTests.HeaderPropagationProcessor.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = "spring.cloud.stream.integration.messageHandlerNotPropagatedHeaders=bar,contentType")
properties = {"spring.cloud.stream.integration.messageHandlerNotPropagatedHeaders=bar,contentType",
"--spring.main.allow-bean-definition-overriding=true"})
public class CustomHeaderPropagationTests {
@Autowired

View File

@@ -51,7 +51,8 @@ import static org.hamcrest.Matchers.notNullValue;
* @author Janne Valkealahti
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = CustomMessageConverterTests.TestSource.class)
@SpringBootTest(classes = CustomMessageConverterTests.TestSource.class,
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class CustomMessageConverterTests {
@Autowired

View File

@@ -43,7 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = DefaultHeaderPropagationTests.HeaderPropagationProcessor.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE)
webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class DefaultHeaderPropagationTests {
@Autowired

View File

@@ -44,7 +44,8 @@ import static org.junit.Assert.assertEquals;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = DefaultHeaderPropagationWithApplicationProvidedHeaderTests.HeaderPropagationProcessor.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE)
webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class DefaultHeaderPropagationWithApplicationProvidedHeaderTests {
@Autowired

View File

@@ -43,7 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = DeserializeJSONToJavaTypeTests.FooProcessor.class)
@SpringBootTest(classes = DeserializeJSONToJavaTypeTests.FooProcessor.class,
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class DeserializeJSONToJavaTypeTests {
@Autowired

View File

@@ -45,7 +45,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = InboundJsonToTupleConversionTest.FooProcessor.class)
@SpringBootTest(classes = InboundJsonToTupleConversionTest.FooProcessor.class,
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class InboundJsonToTupleConversionTest {
@Autowired

View File

@@ -43,7 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { LegacyContentTypeTests.LegacyTestSink.class})
@SpringBootTest(classes = { LegacyContentTypeTests.LegacyTestSink.class},
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class LegacyContentTypeTests {
@Autowired

View File

@@ -53,7 +53,8 @@ import static org.junit.Assert.assertNull;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { MessageChannelConfigurerTests.TestSink.class,
MessageChannelConfigurerTests.TestSource.class, SpelExpressionConverterConfiguration.class})
MessageChannelConfigurerTests.TestSource.class, SpelExpressionConverterConfiguration.class},
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class MessageChannelConfigurerTests {
@Autowired

View File

@@ -41,7 +41,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Soby Chacko
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { MessageChannelWithNativeDecodingTests.NativeDecodingSink.class})
@SpringBootTest(classes = { MessageChannelWithNativeDecodingTests.NativeDecodingSink.class},
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class MessageChannelWithNativeDecodingTests {
@Autowired

View File

@@ -39,7 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Soby Chacko
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { MessageChannelWithNativeEncodingTests.NativeEncodingSource.class})
@SpringBootTest(classes = { MessageChannelWithNativeEncodingTests.NativeEncodingSource.class},
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class MessageChannelWithNativeEncodingTests {
@Autowired

View File

@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -49,6 +50,11 @@ import static org.springframework.cloud.stream.binding.StreamListenerErrorMessag
*/
public class StreamListenerAnnotatedMethodArgumentsTests {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
@SuppressWarnings("unchecked")
public void testAnnotatedArguments() throws Exception {

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.config.BeanPostProcessor;
@@ -46,6 +47,11 @@ import static org.springframework.cloud.stream.config.BindingServiceConfiguratio
*/
public class StreamListenerAnnotationBeanPostProcessorOverrideTest {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
@SuppressWarnings("unchecked")
public void testOverrideStreamListenerAnnotationBeanPostProcessor() throws Exception {

View File

@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -74,6 +75,11 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class StreamListenerAsMetaAnnotationTests {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testCustomAnnotation() {
ConfigurableApplicationContext context = SpringApplication.run(TestPojoWithCustomAnnotatedArguments.class,

View File

@@ -22,6 +22,7 @@ import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -40,6 +41,11 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class StreamListenerContentTypeConversionTests {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testContentTypeConversion() throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(TestSinkWithContentTypeConversion.class,

View File

@@ -16,6 +16,7 @@
package org.springframework.cloud.stream.config;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
@@ -39,6 +40,11 @@ import static org.junit.Assert.fail;
*/
public class StreamListenerDuplicateMappingTests {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
@SuppressWarnings("unchecked")
public void testMultipleMappingsWithReturnValue() {

View File

@@ -24,6 +24,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -57,6 +58,11 @@ public class StreamListenerHandlerBeanTests {
private Class<?> configClass;
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
public StreamListenerHandlerBeanTests(Class<?> configClass) {
this.configClass = configClass;
}

View File

@@ -19,6 +19,7 @@ package org.springframework.cloud.stream.config;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -67,6 +68,11 @@ import static org.springframework.cloud.stream.binding.StreamListenerErrorMessag
*/
public class StreamListenerHandlerMethodTests {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testInvalidInputOnMethod() throws Exception {
try {

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -56,6 +57,11 @@ public class StreamListenerMessageArgumentTests {
this.configClass = configClass;
}
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Parameterized.Parameters
public static Collection<?> InputConfigs() {
return Arrays.asList(new Class[] { TestPojoWithMessageArgument1.class, TestPojoWithMessageArgument2.class });

View File

@@ -41,7 +41,7 @@ import static org.mockito.Mockito.verify;
* @author Soby Chacko
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@SpringBootTest(properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class StreamListenerMethodRegisteredOnlyOnceTest {
@Autowired

View File

@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -66,6 +67,11 @@ public class StreamListenerMethodReturnWithConversionTests extends Suite {
super(klass, builder);
}
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@RunWith(Parameterized.class)
public static class TestReturnConversion {

View File

@@ -55,7 +55,7 @@ import static org.mockito.Mockito.verify;
* @author Soby Chacko
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@SpringBootTest(properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class StreamListenerMethodSetupOrchestratorTests {
@SpyBean

View File

@@ -24,6 +24,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -57,6 +58,11 @@ public class StreamListenerMethodWithReturnMessageTests {
this.configClass = configClass;
}
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Parameterized.Parameters
public static Collection<?> InputConfigs() {
return Arrays.asList(new Class[] { TestPojoWithMessageReturn1.class, TestPojoWithMessageReturn2.class });

View File

@@ -24,6 +24,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -56,6 +57,11 @@ public class StreamListenerMethodWithReturnValueTests {
this.configClass = configClass;
}
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Parameterized.Parameters
public static Collection<?> InputConfigs() {
return Arrays.asList(new Class[] { TestStringProcessor1.class, TestStringProcessor2.class });

View File

@@ -18,6 +18,7 @@ package org.springframework.cloud.stream.config;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -49,6 +50,11 @@ import static org.springframework.cloud.stream.binding.StreamListenerErrorMessag
*/
public class StreamListenerWithAnnotatedInputOutputArgsTests {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testInputOutputArgs() throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(TestInputOutputArgs.class, "--server.port=0", "--spring.cloud.stream.bindings.output.contentType=text/plain", "--spring.jmx.enabled=false");

View File

@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -42,6 +43,11 @@ import static org.assertj.core.api.Assertions.fail;
*/
public class StreamListenerWithConditionsTest {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testAnnotatedArgumentsWithConditionalClass() throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(TestPojoWithAnnotatedArguments.class,

View File

@@ -44,7 +44,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 1.2
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = TextPlainConversionTest.FooProcessor.class, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@SpringBootTest(classes = TextPlainConversionTest.FooProcessor.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = {"--spring.main.allow-bean-definition-overriding=true"})
public class TextPlainConversionTest {
@Autowired

View File

@@ -47,7 +47,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 1.2
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = TextPlainToJsonConversionTest.FooProcessor.class, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@SpringBootTest(classes = TextPlainToJsonConversionTest.FooProcessor.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = {"--spring.main.allow-bean-definition-overriding=true"}
)
public class TextPlainToJsonConversionTest {
@Autowired

View File

@@ -46,6 +46,7 @@ public class AggregateApplicationTests {
@Before
public void before() {
System.setProperty("server.port", "0");
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test

View File

@@ -26,6 +26,7 @@ import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Output;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -59,6 +60,11 @@ public class ContentTypeTests {
private ObjectMapper mapper = new ObjectMapper();
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testSendWithDefaultContentType() throws Exception {
try (ConfigurableApplicationContext context = SpringApplication.run(

View File

@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -54,6 +55,11 @@ public class StreamListenerReactiveInputOutputArgsTests {
this.configClass = configClass;
}
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Parameterized.Parameters
public static Collection<?> InputConfigs() {
return Collections.singletonList(ReactorTestInputOutputArgs.class);

View File

@@ -16,6 +16,7 @@
package org.springframework.cloud.stream.reactive;
import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Flux;
@@ -37,6 +38,11 @@ import static org.springframework.cloud.stream.binding.StreamListenerErrorMessag
*/
public class StreamListenerReactiveMethodTests {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testReactiveInvalidInputValueWithOutputMethodParameters() {
try {

View File

@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -55,6 +56,11 @@ public class StreamListenerReactiveMethodWithReturnTypeTests {
this.configClass = configClass;
}
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Parameterized.Parameters
public static Collection<?> InputConfigs() {
return Arrays.asList(ReactorTestReturn1.class, ReactorTestReturn2.class, ReactorTestReturn3.class,

View File

@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -55,6 +56,11 @@ public class StreamListenerReactiveReturnWithFailureTests {
this.configClass = configClass;
}
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@Parameterized.Parameters
public static Collection<?> InputConfigs() {
return Arrays.asList(ReactorTestReturnWithFailure1.class, ReactorTestReturnWithFailure2.class,

View File

@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -61,6 +62,11 @@ public class StreamListenerReactiveReturnWithMessageTests {
ReactorTestReturnWithMessage3.class, ReactorTestReturnWithMessage4.class);
}
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@SuppressWarnings("unchecked")
private static void sendMessageAndValidate(ConfigurableApplicationContext context) throws InterruptedException {
Processor processor = context.getBean(Processor.class);

View File

@@ -44,7 +44,8 @@ import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER
* @author Ilayaperumal Gopinathan
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
properties = {"--spring.main.allow-bean-definition-overriding=true"})
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
public class SchemaRegistryServerAvroTests {

View File

@@ -67,6 +67,7 @@ public class AvroMessageConverterSerializationTests {
@Before
public void setup() {
System.setProperty("--spring.main.allow-bean-definition-overriding", "true");
schemaRegistryServerContext = SpringApplication
.run(SchemaRegistryServerApplication.class);
}

View File

@@ -22,6 +22,7 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -52,6 +53,11 @@ public class AvroSchemaMessageConverterTests {
static StubSchemaRegistryClient stubSchemaRegistryClient = new StubSchemaRegistryClient();
@Before
public void setup() {
System.setProperty("--spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testSendMessageWithLocation() throws Exception {
ConfigurableApplicationContext sourceContext = SpringApplication.run(AvroSourceApplication.class,

View File

@@ -21,11 +21,14 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.cache.support.NoOpCacheManager;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
@@ -54,6 +57,11 @@ public class AvroSchemaRegistryClientMessageConverterTests {
static SchemaRegistryClient stubSchemaRegistryClient = new StubSchemaRegistryClient();
@Before
public void setup() {
System.setProperty("--spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testSendMessage() throws Exception {
@@ -159,10 +167,16 @@ public class AvroSchemaRegistryClientMessageConverterTests {
@Configuration
public static class NoCacheConfiguration {
@Bean
@StreamMessageConverter
AvroSchemaRegistryClientMessageConverter avroSchemaRegistryClientMessageConverter() {
return new AvroSchemaRegistryClientMessageConverter(new DefaultSchemaRegistryClient(), new NoOpCacheManager());
}
@Bean
ServletWebServerFactory servletWebServerFactory(){
return new TomcatServletWebServerFactory();
}
}
}

View File

@@ -21,6 +21,7 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -45,6 +46,11 @@ public class AvroStubSchemaRegistryClientMessageConverterTests {
static SchemaRegistryClient stubSchemaRegistryClient = new StubSchemaRegistryClient();
@Before
public void setup() {
System.setProperty("--spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testSendMessage() throws Exception {
ConfigurableApplicationContext sourceContext = SpringApplication.run(AvroSourceApplication.class,

View File

@@ -19,6 +19,7 @@ package org.springframework.cloud.schema.avro;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
@@ -42,6 +43,11 @@ public class SubjectNamingStrategyTest {
static StubSchemaRegistryClient stubSchemaRegistryClient = new StubSchemaRegistryClient();
@Before
public void setup() {
System.setProperty("--spring.main.allow-bean-definition-overriding", "true");
}
@Test
public void testCustomNamingStrategy() throws Exception {
ConfigurableApplicationContext sourceContext = SpringApplication.run(AvroSourceApplication.class,

View File

@@ -42,7 +42,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Marius Bogoevici
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = AggregateWithBeanTest.ChainedProcessors.class, properties = { "server.port=-1","--spring.cloud.stream.bindings.input.contentType=text/plain","--spring.cloud.stream.bindings.output.contentType=text/plain" })
@SpringBootTest(classes = AggregateWithBeanTest.ChainedProcessors.class, properties = { "server.port=-1","--spring.cloud.stream.bindings.input.contentType=text/plain",
"--spring.cloud.stream.bindings.output.contentType=text/plain",
"--spring.main.allow-bean-definition-overriding=true"})
public class AggregateWithBeanTest {
@Autowired

View File

@@ -46,6 +46,7 @@ public class AggregateWithMainTest {
@Before
public void before() {
System.setProperty("server.port", "0");
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
}
@SuppressWarnings("unchecked")

View File

@@ -39,7 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* correctly.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = ExampleTest.MyProcessor.class, properties = { "server.port=-1", "--spring.cloud.stream.bindings.input.contentType=text/plain", "--spring.cloud.stream.bindings.output.contentType=text/plain" })
@SpringBootTest(classes = ExampleTest.MyProcessor.class, properties = { "server.port=-1", "--spring.cloud.stream.bindings.input.contentType=text/plain", "--spring.cloud.stream.bindings.output.contentType=text/plain",
"--spring.main.allow-bean-definition-overriding=true"})
@DirtiesContext
public class ExampleTest {

View File

@@ -28,14 +28,14 @@ import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;
import org.springframework.context.Lifecycle;
import org.springframework.core.AttributeAccessor;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.integration.StaticMessageHeaderAccessor;
import org.springframework.integration.acks.AckUtils;
import org.springframework.integration.acks.AcknowledgmentCallback;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.support.AckUtils;
import org.springframework.integration.support.AcknowledgmentCallback;
import org.springframework.integration.support.DefaultErrorMessageStrategy;
import org.springframework.integration.support.ErrorMessageStrategy;
import org.springframework.integration.support.ErrorMessageUtils;
import org.springframework.integration.support.StaticMessageHeaderAccessor;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;

View File

@@ -118,7 +118,9 @@ public class BinderAwareChannelResolver extends BeanFactoryMessageChannelDestina
MessageChannel channel = this.bindingTargetFactory.createOutput(channelName);
this.beanFactory.registerSingleton(channelName, channel);
this.instrumentChannelWithGlobalInterceptors(channel, channelName);
//TODO: Investigate if the following call is necessary.
//initializeBean call on the next line also calling the addMatchingInterceptors method in GlobalChannelInterceptorProcessor
//this.instrumentChannelWithGlobalInterceptors(channel, channelName);
channel = (MessageChannel) this.beanFactory.initializeBean(channel, channelName);
if (this.newBindingCallback != null) {

View File

@@ -51,9 +51,9 @@ import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Role;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.integration.config.GlobalChannelInterceptorProcessor;
import org.springframework.integration.config.HandlerMethodArgumentResolversHolder;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.handler.support.HandlerMethodArgumentResolversHolder;
import org.springframework.integration.router.AbstractMappingMessageRouter;
import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageChannel;

View File

@@ -169,7 +169,7 @@ class DefaultDestinationPublishingMeterRegistry extends MeterRegistry implements
@Override
protected Timer newTimer(Id id, DistributionStatisticConfig distributionStatisticConfig,
PauseDetector pauseDetector) {
return new StepTimer(id, clock, distributionStatisticConfig, pauseDetector, getBaseTimeUnit());
return new StepTimer(id, clock, distributionStatisticConfig, pauseDetector, getBaseTimeUnit(), metricsPublisherConfig.step().toMillis(), false);
}
@Override
@@ -191,7 +191,7 @@ class DefaultDestinationPublishingMeterRegistry extends MeterRegistry implements
@Override
protected DistributionSummary newDistributionSummary(Id id, DistributionStatisticConfig distributionStatisticConfig, double scale) {
return new StepDistributionSummary(id, clock, distributionStatisticConfig, scale);
return new StepDistributionSummary(id, clock, distributionStatisticConfig, scale, metricsPublisherConfig.step().toMillis(), false);
}
@Override

View File

@@ -64,6 +64,7 @@ public class AggregationTest {
@Before
public void before() {
System.setProperty("spring.main.allow-bean-definition-overriding", "true");
System.setProperty("server.port", "0");
}

View File

@@ -94,6 +94,8 @@ public class BinderAwareChannelResolverTests {
@SuppressWarnings("unchecked")
@Before
public void setupContext() throws Exception {
//System.setProperty("spring.main.allow-bean-definition-overriding", "true");
this.context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(BinderAwareChannelResolverTests.InterceptorConfiguration.class))
.web(WebApplicationType.NONE).run();

View File

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.actuate.health.CompositeHealthIndicator;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.HealthIndicatorRegistry;
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -83,11 +84,12 @@ public class HealthIndicatorsConfigurationTests {
CompositeHealthIndicator.class);
DirectFieldAccessor directFieldAccessor = new DirectFieldAccessor(bindersHealthIndicator);
assertThat(bindersHealthIndicator).isNotNull();
assertThat(context.getBean("testHealthIndicator1", CompositeHealthIndicator.class)).isNotNull();
assertThat(context.getBean("testHealthIndicator2", CompositeHealthIndicator.class)).isNotNull();
@SuppressWarnings("unchecked")
Map<String, HealthIndicator> healthIndicators = (Map<String, HealthIndicator>) directFieldAccessor
.getPropertyValue("indicators");
assertThat(context.getBean("test1HealthIndicator1", CompositeHealthIndicator.class)).isNotNull();
assertThat(context.getBean("test2HealthIndicator2", CompositeHealthIndicator.class)).isNotNull();
HealthIndicatorRegistry registry = (HealthIndicatorRegistry)directFieldAccessor.getPropertyValue("registry");
Map<String, HealthIndicator> healthIndicators = registry.getAll();
assertThat(healthIndicators).containsKey("binder1");
assertThat(healthIndicators.get("binder1").health().getStatus()).isEqualTo(Status.UP);
assertThat(healthIndicators).containsKey("binder2");
@@ -113,8 +115,8 @@ public class HealthIndicatorsConfigurationTests {
}
catch (NoSuchBeanDefinitionException e) {
}
assertThat(context.getBean("testHealthIndicator1", CompositeHealthIndicator.class)).isNotNull();
assertThat(context.getBean("testHealthIndicator2", CompositeHealthIndicator.class)).isNotNull();
assertThat(context.getBean("test1HealthIndicator1", CompositeHealthIndicator.class)).isNotNull();
assertThat(context.getBean("test2HealthIndicator2", CompositeHealthIndicator.class)).isNotNull();
context.close();
}
@@ -126,12 +128,12 @@ public class HealthIndicatorsConfigurationTests {
static class TestConfig {
@Bean
public CompositeHealthIndicator testHealthIndicator1() {
public CompositeHealthIndicator test1HealthIndicator1() {
return new CompositeHealthIndicator(new OrderedHealthAggregator());
}
@Bean
public CompositeHealthIndicator testHealthIndicator2() {
public CompositeHealthIndicator test2HealthIndicator2() {
return new CompositeHealthIndicator(new OrderedHealthAggregator());
}
}