diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/AggregateApplicationBuilder.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/AggregateApplicationBuilder.java index 5c9397797..280389848 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/AggregateApplicationBuilder.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/AggregateApplicationBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 the original author or authors. + * Copyright 2015-2017 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. @@ -56,6 +56,7 @@ import org.springframework.util.StringUtils; * @author Venil Noronha * @author Janne Valkealahti * @author Vinicius Carvalho + * @author Oleg Zhurakousky */ @EnableBinding public class AggregateApplicationBuilder implements AggregateApplication, ApplicationContextAware, @@ -189,7 +190,7 @@ public class AggregateApplicationBuilder implements AggregateApplication, Applic apps.add(sinkConfigurer); } LinkedHashMap, String> appsToEmbed = new LinkedHashMap<>(); - LinkedHashMap appConfigurers = new LinkedHashMap<>(); + LinkedHashMap, String> appConfigurers = new LinkedHashMap<>(); for (int i = 0; i < apps.size(); i++) { AppConfigurer appConfigurer = apps.get(i); Class appToEmbed = appConfigurer.getApp(); @@ -218,16 +219,14 @@ public class AggregateApplicationBuilder implements AggregateApplication, Applic SharedBindingTargetRegistry sharedBindingTargetRegistry = new SharedBindingTargetRegistry(); this.parentContext.getBeanFactory().registerSingleton("sharedBindingTargetRegistry", sharedBindingTargetRegistry); - this.parentContext.getBeanFactory().registerSingleton("sharedChannelRegistry", - new SharedChannelRegistry(sharedBindingTargetRegistry)); } } SharedBindingTargetRegistry sharedBindingTargetRegistry = this.parentContext .getBean(SharedBindingTargetRegistry.class); AggregateApplicationUtils.prepareSharedBindingTargetRegistry(sharedBindingTargetRegistry, appsToEmbed); - for (Map.Entry appConfigurerEntry : appConfigurers.entrySet()) { + for (Map.Entry, String> appConfigurerEntry : appConfigurers.entrySet()) { - AppConfigurer appConfigurer = appConfigurerEntry.getKey(); + AppConfigurer appConfigurer = appConfigurerEntry.getKey(); if (appConfigurerEntry.getValue() == null) { continue; } @@ -302,12 +301,6 @@ public class AggregateApplicationBuilder implements AggregateApplication, Applic public SharedBindingTargetRegistry sharedBindingTargetRegistry() { return new SharedBindingTargetRegistry(); } - - @Bean - @ConditionalOnMissingBean(SharedChannelRegistry.class) - public SharedChannelRegistry sharedChannelRegistry(SharedBindingTargetRegistry sharedBindingTargetRegistry) { - return new SharedChannelRegistry(sharedBindingTargetRegistry); - } } public class SourceConfigurer extends AppConfigurer { diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/AggregateApplicationUtils.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/AggregateApplicationUtils.java index def43c7c2..ca2c5d91a 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/AggregateApplicationUtils.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/AggregateApplicationUtils.java @@ -20,6 +20,7 @@ import java.util.LinkedHashMap; import java.util.Map.Entry; import org.springframework.boot.Banner.Mode; +import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.cloud.stream.internal.InternalPropertyNames; import org.springframework.context.ConfigurableApplicationContext; @@ -44,7 +45,7 @@ abstract class AggregateApplicationUtils { String[] args, final boolean selfContained, boolean webEnvironment, boolean headless) { SpringApplicationBuilder aggregatorParentConfiguration = new SpringApplicationBuilder(); - aggregatorParentConfiguration.sources(sources).web(webEnvironment) + aggregatorParentConfiguration.sources(sources).web(WebApplicationType.NONE) .headless(headless) .properties("spring.jmx.default-domain=" + AggregateApplicationBuilder.ParentConfiguration.class.getName(), @@ -60,7 +61,7 @@ abstract class AggregateApplicationUtils { protected static SpringApplicationBuilder embedApp( ConfigurableApplicationContext parentContext, String namespace, Class app) { - return new SpringApplicationBuilder(app).web(false).main(app).bannerMode(Mode.OFF) + return new SpringApplicationBuilder(app).web(WebApplicationType.NONE).main(app).bannerMode(Mode.OFF) .properties("spring.jmx.default-domain=" + namespace) .properties( InternalPropertyNames.NAMESPACE_PROPERTY_NAME + "=" + namespace) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/SharedBindingTargetRegistry.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/SharedBindingTargetRegistry.java index b17d9eefd..1d1071e2c 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/SharedBindingTargetRegistry.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/SharedBindingTargetRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 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. @@ -30,6 +30,7 @@ public class SharedBindingTargetRegistry { private Map sharedBindingTargets = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER); + @SuppressWarnings("unchecked") public T get(String id, Class bindingTargetType) { Object sharedBindingTarget = this.sharedBindingTargets.get(id); if (sharedBindingTarget == null) { diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/SharedChannelRegistry.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/SharedChannelRegistry.java index 5114a6668..97ba8c683 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/SharedChannelRegistry.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/aggregate/SharedChannelRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 the original author or authors. + * Copyright 2015-2017 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. @@ -28,7 +28,8 @@ import org.springframework.messaging.MessageChannel; * {@link SharedChannelRegistry} in previous versions and will be removed in the future. * * @author Marius Bogoevici - * @deprecated in favour of {@link SharedBindingTargetRegistry} + * @deprecated in favor of {@link SharedBindingTargetRegistry}. Will be removed in 3.0. + * Not currently used by the framework. */ @Deprecated public class SharedChannelRegistry { diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/annotation/EnableBinding.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/annotation/EnableBinding.java index b81eb6758..9d17a1434 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/annotation/EnableBinding.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/annotation/EnableBinding.java @@ -39,6 +39,7 @@ import org.springframework.integration.config.EnableIntegration; * @author Marius Bogoevici * @author David Turanski */ +@SuppressWarnings("deprecation") @Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinder.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinder.java index e26888e7b..e1488e707 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinder.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinder.java @@ -82,6 +82,9 @@ public abstract class AbstractMessageChannelBinder Binder getBinderInstance(String configurationName) { if (!this.binderInstanceCache.containsKey(configurationName)) { BinderConfiguration binderConfiguration = this.binderConfigurations.get(configurationName); @@ -193,7 +196,7 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl .sources(configurationClasses.toArray(new Class[] {})) .bannerMode(Mode.OFF) .logStartupInfo(false) - .web(false); + .web(WebApplicationType.NONE); // If the environment is not customized and a main context is available, we // will set the latter as parent. // This ensures that the defaults and user-defined customizations (e.g. custom @@ -214,7 +217,6 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl } ConfigurableApplicationContext binderProducingContext = springApplicationBuilder .run(args.toArray(new String[args.size()])); - @SuppressWarnings("unchecked") Binder binder = binderProducingContext.getBean(Binder.class); if (this.listeners != null) { for (Listener binderFactoryListener : listeners) { diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/PartitionHandler.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/PartitionHandler.java index 7deb85575..cbac1ca94 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/PartitionHandler.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/PartitionHandler.java @@ -109,8 +109,4 @@ public class PartitionHandler { return this.partitionKeyExtractorStrategy.extractKey(message); } - private int invokePartitionSelector(Object key) { - return this.partitionSelectorStrategy.selectPartition(key, producerProperties.getPartitionCount()); - } - } diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindingBeanDefinitionRegistryUtils.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindingBeanDefinitionRegistryUtils.java index f3c7ee47a..96be7ea66 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindingBeanDefinitionRegistryUtils.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindingBeanDefinitionRegistryUtils.java @@ -39,6 +39,7 @@ import org.springframework.util.StringUtils; * @author Dave Syer * @author Artem Bilan */ +@SuppressWarnings("deprecation") public abstract class BindingBeanDefinitionRegistryUtils { public static void registerInputBindingTargetBeanDefinition(String qualifierValue, String name, @@ -93,6 +94,10 @@ public abstract class BindingBeanDefinitionRegistryUtils { }); } + /** + * @deprecated as of version 2.0 based on deprecated {@link Bindings} annotation. + */ + @Deprecated public static void registerBindingTargetsQualifiedBeanDefinitions(Class parent, Class type, final BeanDefinitionRegistry registry) { diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java index cc1abc54d..a83616a79 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 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. @@ -36,9 +36,9 @@ public final class DynamicDestinationsBindable extends BindableAdapter { /** * Map containing dynamic channel names and their bindings. */ - private Map outputBindings = new HashMap<>(); + private Map> outputBindings = new HashMap<>(); - public void addOutputBinding(String name, Binding binding) { + public void addOutputBinding(String name, Binding binding) { this.outputBindings.put(name, binding); } @@ -49,7 +49,7 @@ public final class DynamicDestinationsBindable extends BindableAdapter { @Override public void unbindOutputs(BindingService adapter) { - for (Map.Entry entry : outputBindings.entrySet()) { + for (Map.Entry> entry : outputBindings.entrySet()) { entry.getValue().unbind(); } outputBindings.clear(); diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamAnnotationCommonMethodUtils.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamAnnotationCommonMethodUtils.java index 1efa65583..55febce0c 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamAnnotationCommonMethodUtils.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamAnnotationCommonMethodUtils.java @@ -53,7 +53,7 @@ public abstract class StreamAnnotationCommonMethodUtils { public static int outputAnnotationCount(Method method) { int outputAnnotationCount = 0; for (int parameterIndex = 0; parameterIndex < method.getParameterTypes().length; parameterIndex++) { - MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(method, parameterIndex); + MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex); if (methodParameter.hasParameterAnnotation(Output.class)) { outputAnnotationCount++; } diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamListenerMethodUtils.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamListenerMethodUtils.java index ef3ace67d..55b01ee2f 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamListenerMethodUtils.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/StreamListenerMethodUtils.java @@ -40,7 +40,7 @@ public class StreamListenerMethodUtils { protected static int inputAnnotationCount(Method method) { int inputAnnotationCount = 0; for (int parameterIndex = 0; parameterIndex < method.getParameterTypes().length; parameterIndex++) { - MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(method, parameterIndex); + MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex); if (methodParameter.hasParameterAnnotation(Input.class)) { inputAnnotationCount++; } @@ -51,7 +51,7 @@ public class StreamListenerMethodUtils { protected static int outputAnnotationCount(Method method) { int outputAnnotationCount = 0; for (int parameterIndex = 0; parameterIndex < method.getParameterTypes().length; parameterIndex++) { - MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(method, parameterIndex); + MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex); if (methodParameter.hasParameterAnnotation(Output.class)) { outputAnnotationCount++; } @@ -90,7 +90,7 @@ public class StreamListenerMethodUtils { Assert.isTrue(!StringUtils.hasText(condition), StreamListenerErrorMessages.CONDITION_ON_DECLARATIVE_METHOD); for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { - MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(method, parameterIndex); + MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex); if (methodParameter.hasParameterAnnotation(Input.class)) { String inboundName = (String) AnnotationUtils .getValue(methodParameter.getParameterAnnotation(Input.class)); @@ -115,7 +115,7 @@ public class StreamListenerMethodUtils { int numAnnotatedMethodParameters = 0; int numPayloadAnnotations = 0; for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { - MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(method, parameterIndex); + MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex); if (methodParameter.hasParameterAnnotations()) { numAnnotatedMethodParameters++; } diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingBeansRegistrar.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingBeansRegistrar.java index 8fab9ed09..705e3dfe2 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingBeansRegistrar.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingBeansRegistrar.java @@ -17,6 +17,7 @@ package org.springframework.cloud.stream.config; import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.cloud.stream.annotation.Bindings; import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.binding.BindingBeanDefinitionRegistryUtils; import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; @@ -27,11 +28,13 @@ import org.springframework.core.type.AnnotationMetadata; import org.springframework.util.ClassUtils; /** + * @deprecated as ov version 2.0 based on deprecation of {@link Bindings} anntoation + * * @author Marius Bogoevici * @author Dave Syer * @author Artem Bilan */ - +@Deprecated public class BindingBeansRegistrar implements ImportBeanDefinitionRegistrar { @Override diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java index a402fc338..173764f3c 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java @@ -188,7 +188,12 @@ public class BindingServiceConfiguration { } + /** + * + * @deprecated as of version 2.0 + */ @Bean + @Deprecated // provided for backwards compatibility scenarios public ChannelBindingServiceProperties channelBindingServiceProperties( BindingServiceProperties bindingServiceProperties) { diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/EnvironmentEntryInitializingTreeMap.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/EnvironmentEntryInitializingTreeMap.java index 0a7c9faa3..45e437f89 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/EnvironmentEntryInitializingTreeMap.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/EnvironmentEntryInitializingTreeMap.java @@ -83,7 +83,7 @@ public class EnvironmentEntryInitializingTreeMap extends AbstractMap handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class); assertThat(handlers.size()).isEqualTo(2); Iterator iterator = handlers.iterator(); @@ -125,7 +124,6 @@ public class AbstractMessageChannelBinderTests { ErrorInfrastructure errorInfra = binder.errorInfrastructure; SubscribableChannel errorChannel = errorInfra.getErrorChannel(); assertThat(errorChannel).isNotNull(); - @SuppressWarnings("unchecked") Set handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class); assertThat(handlers.size()).isEqualTo(2); Iterator iterator = handlers.iterator(); @@ -154,9 +152,8 @@ public class AbstractMessageChannelBinderTests { this(false); } - @SuppressWarnings("unchecked") StubMessageChannelBinder(boolean hasRecoverer) { - super(true, null, Mockito.mock(ProvisioningProvider.class)); + super(null, Mockito.mock(ProvisioningProvider.class)); mockProvisioner(); this.hasRecoverer = hasRecoverer; } diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ArbitraryInterfaceWithBindingTargetsTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ArbitraryInterfaceWithBindingTargetsTests.java index 4333a5dba..64bfd1124 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ArbitraryInterfaceWithBindingTargetsTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ArbitraryInterfaceWithBindingTargetsTests.java @@ -49,7 +49,7 @@ public class ArbitraryInterfaceWithBindingTargetsTests { @Autowired private BinderFactory binderFactory; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Test public void testArbitraryInterfaceChannelsBound() { Binder binder = binderFactory.getBinder(null, MessageChannel.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ArbitraryInterfaceWithDefaultsTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ArbitraryInterfaceWithDefaultsTests.java index 4e7279437..7ff3185f1 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ArbitraryInterfaceWithDefaultsTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ArbitraryInterfaceWithDefaultsTests.java @@ -48,7 +48,7 @@ public class ArbitraryInterfaceWithDefaultsTests { @Autowired private BinderFactory binderFactory; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Test public void testArbitraryInterfaceChannelsBound() { final Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/BinderFactoryConfigurationTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/BinderFactoryConfigurationTests.java index ea56fa8ab..3db70bb48 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/BinderFactoryConfigurationTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/BinderFactoryConfigurationTests.java @@ -23,6 +23,7 @@ import java.net.URLClassLoader; import org.junit.Test; import org.springframework.beans.factory.BeanCreationException; +import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.cloud.stream.annotation.EnableBinding; @@ -66,18 +67,18 @@ public class BinderFactoryConfigurationTests { return new SpringApplicationBuilder(SimpleApplication.class) .resourceLoader(new DefaultResourceLoader(classLoader)) .properties(properties) - .web(false) + .web(WebApplicationType.NONE) .run(); } - private static ConfigurableApplicationContext createBinderTestContextWithSources(Class[] sources, + private static ConfigurableApplicationContext createBinderTestContextWithSources(Class[] sources, String[] additionalClasspathDirectories, String... properties) throws IOException { ClassLoader classLoader = createClassLoader(additionalClasspathDirectories, properties); return new SpringApplicationBuilder(sources) .resourceLoader(new DefaultResourceLoader(classLoader)) .properties(properties) - .web(false) + .web(WebApplicationType.NONE) .run(); } @@ -115,6 +116,7 @@ public class BinderFactoryConfigurationTests { "spring.cloud.stream.internal.selfContained=true"); } + @SuppressWarnings("rawtypes") @Test public void loadBinderTypeRegistryWithOneBinder() throws Exception { ConfigurableApplicationContext context = createBinderTestContext( @@ -136,6 +138,7 @@ public class BinderFactoryConfigurationTests { assertThat(defaultBinder).isSameAs(binder1); } + @SuppressWarnings("rawtypes") @Test public void loadBinderTypeRegistryWithOneBinderAndSharedEnvironment() throws Exception { ConfigurableApplicationContext context = createBinderTestContext( @@ -147,6 +150,7 @@ public class BinderFactoryConfigurationTests { assertThat(binder1).hasFieldOrPropertyWithValue("name", "foo"); } + @SuppressWarnings("rawtypes") @Test public void loadBinderTypeRegistryWithOneCustomBinderAndSharedEnvironment() throws Exception { ConfigurableApplicationContext context = createBinderTestContext( @@ -162,6 +166,7 @@ public class BinderFactoryConfigurationTests { assertThat(binderFactory.getBinder(null, MessageChannel.class)).isSameAs(binder1); } + @SuppressWarnings("rawtypes") @Test public void loadBinderTypeRegistryWithTwoBinders() throws Exception { ConfigurableApplicationContext context = createBinderTestContext(new String[] { "binder1", "binder2" }); @@ -192,6 +197,7 @@ public class BinderFactoryConfigurationTests { assertThat(binder2).isInstanceOf(StubBinder2.class); } + @SuppressWarnings("rawtypes") @Test public void loadBinderTypeRegistryWithCustomNonDefaultCandidate() throws Exception { ConfigurableApplicationContext context = createBinderTestContext( @@ -217,6 +223,7 @@ public class BinderFactoryConfigurationTests { assertThat(binder1).isSameAs(defaultBinder); } + @SuppressWarnings("rawtypes") @Test public void loadDefaultBinderWithTwoBinders() throws Exception { diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ErrorBindingTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ErrorBindingTests.java index d515e73e2..23610619a 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ErrorBindingTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ErrorBindingTests.java @@ -48,37 +48,35 @@ import static org.mockito.Matchers.same; */ public class ErrorBindingTests { + @SuppressWarnings("rawtypes") @Test public void testErrorChannelNotBoundByDefault() { - ConfigurableApplicationContext applicationContext = SpringApplication.run(TestProcessor.class, "--server.port=0"); BinderFactory binderFactory = applicationContext.getBean(BinderFactory.class); - @SuppressWarnings("unchecked") Binder binder = binderFactory.getBinder(null, MessageChannel.class); - Mockito.verify(binder).bindConsumer(eq("input"), isNull(String.class), any(MessageChannel.class), + Mockito.verify(binder).bindConsumer(eq("input"), isNull(), any(MessageChannel.class), any(ConsumerProperties.class)); Mockito.verify(binder).bindProducer(eq("output"), any(MessageChannel.class), any(ProducerProperties.class)); Mockito.verifyNoMoreInteractions(binder); applicationContext.close(); } + @SuppressWarnings("rawtypes") @Test public void testErrorChannelBoundIfConfigured() { - ConfigurableApplicationContext applicationContext = SpringApplication.run(TestProcessor.class, "--spring.cloud.stream.bindings.error.destination=foo", "--server.port=0"); BinderFactory binderFactory = applicationContext.getBean(BinderFactory.class, MessageChannel.class); - @SuppressWarnings("unchecked") Binder binder = binderFactory.getBinder(null, MessageChannel.class); MessageChannel errorChannel = applicationContext.getBean(BindingServiceConfiguration.ERROR_BRIDGE_CHANNEL, MessageChannel.class); - Mockito.verify(binder).bindConsumer(eq("input"), isNull(String.class), any(MessageChannel.class), + Mockito.verify(binder).bindConsumer(eq("input"), isNull(), any(MessageChannel.class), any(ConsumerProperties.class)); Mockito.verify(binder).bindProducer(eq("output"), any(MessageChannel.class), any(ProducerProperties.class)); Mockito.verify(binder).bindProducer(eq("foo"), same(errorChannel), any(ProducerProperties.class)); @@ -139,9 +137,6 @@ public class ErrorBindingTests { } }); - Foo foo = new Foo(); - foo.setFoo("bar"); - errorChannel.send(new GenericMessage<>(new Exception("throwing exception"))); assertThat(received.get()).isTrue(); applicationContext.close(); @@ -157,6 +152,7 @@ public class ErrorBindingTests { private class Foo { String foo; + @SuppressWarnings("unused") // used json ser/deser public String getFoo() { return foo; } diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/HealthIndicatorsConfigurationTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/HealthIndicatorsConfigurationTests.java index f7c81148b..c4418c6e9 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/HealthIndicatorsConfigurationTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/HealthIndicatorsConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 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. @@ -25,6 +25,7 @@ import org.junit.Test; import org.springframework.beans.DirectFieldAccessor; 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.OrderedHealthAggregator; @@ -66,9 +67,10 @@ public class HealthIndicatorsConfigurationTests { BinderFactoryConfigurationTests.class.getClassLoader()); return new SpringApplicationBuilder(SimpleSource.class) .resourceLoader(new DefaultResourceLoader(classLoader)) - .properties(properties).web(false).run(); + .properties(properties).web(WebApplicationType.NONE).run(); } + @SuppressWarnings("rawtypes") @Test public void healthIndicatorsCheck() throws Exception { ConfigurableApplicationContext context = createBinderTestContext(new String[] { "binder1", "binder2" }, @@ -93,6 +95,7 @@ public class HealthIndicatorsConfigurationTests { context.close(); } + @SuppressWarnings("rawtypes") @Test public void healthIndicatorsCheckWhenDisabled() throws Exception { ConfigurableApplicationContext context = createBinderTestContext( diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/InputOutputBindingOrderTest.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/InputOutputBindingOrderTest.java index 97b93ac38..6a71c22ac 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/InputOutputBindingOrderTest.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/InputOutputBindingOrderTest.java @@ -45,7 +45,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; */ public class InputOutputBindingOrderTest { - @SuppressWarnings("unchecked") @Test public void testInputOutputBindingOrder() { ConfigurableApplicationContext applicationContext = SpringApplication.run(TestSource.class, "--server.port=-1"); @@ -83,7 +82,7 @@ public class InputOutputBindingOrderTest { private boolean running; @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") public synchronized void start() { Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); verify(binder).bindProducer(eq("output"), eq(this.processor.output()), Mockito.any()); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ProcessorBindingWithBindingTargetsTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ProcessorBindingWithBindingTargetsTests.java index 0e9ec7512..e154402d6 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ProcessorBindingWithBindingTargetsTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ProcessorBindingWithBindingTargetsTests.java @@ -49,7 +49,7 @@ public class ProcessorBindingWithBindingTargetsTests { @Autowired private Processor testProcessor; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Test public void testSourceOutputChannelBound() { final Binder binder = binderFactory.getBinder(null, MessageChannel.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ProcessorBindingsWithDefaultsTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ProcessorBindingsWithDefaultsTests.java index c183ec296..4e8ec06b2 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ProcessorBindingsWithDefaultsTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/ProcessorBindingsWithDefaultsTests.java @@ -48,7 +48,7 @@ public class ProcessorBindingsWithDefaultsTests { @Autowired private Processor processor; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Test public void testSourceOutputChannelBound() { Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SinkBindingWithDefaultTargetsTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SinkBindingWithDefaultTargetsTests.java index ea716e89e..e390ca5f8 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SinkBindingWithDefaultTargetsTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SinkBindingWithDefaultTargetsTests.java @@ -51,7 +51,7 @@ public class SinkBindingWithDefaultTargetsTests { @Autowired private Sink testSink; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Test public void testSourceOutputChannelBound() { Binder binder = binderFactory.getBinder(null, MessageChannel.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SinkBindingWithDefaultsTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SinkBindingWithDefaultsTests.java index bdfea58e9..873ff1a8d 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SinkBindingWithDefaultsTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SinkBindingWithDefaultsTests.java @@ -49,7 +49,7 @@ public class SinkBindingWithDefaultsTests { @Autowired private Sink testSink; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Test public void testSourceOutputChannelBound() { Binder binder = binderFactory.getBinder(null, MessageChannel.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithBindingTargetsTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithBindingTargetsTests.java index 17a2739f6..f62fa4a0c 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithBindingTargetsTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithBindingTargetsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2017 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; @SpringBootTest(classes = SourceBindingWithBindingTargetsTests.TestSource.class) public class SourceBindingWithBindingTargetsTests { - @SuppressWarnings("rawtypes") @Autowired private BinderFactory binderFactory; @@ -57,7 +56,7 @@ public class SourceBindingWithBindingTargetsTests { @Qualifier(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME) private PublishSubscribeChannel errorChannel; - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") @Test public void testSourceOutputChannelBound() { Binder binder = binderFactory.getBinder(null, MessageChannel.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithDefaultsTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithDefaultsTests.java index 1e3d00519..10a970235 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithDefaultsTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithDefaultsTests.java @@ -41,14 +41,13 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; @SpringBootTest(classes = SourceBindingWithDefaultsTests.TestSource.class) public class SourceBindingWithDefaultsTests { - @SuppressWarnings("rawtypes") @Autowired private BinderFactory binderFactory; @Autowired private Source testSource; - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") @Test public void testSourceOutputChannelBound() { Binder binder = binderFactory.getBinder(null, MessageChannel.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithGlobalPropertiesOnlyTest.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithGlobalPropertiesOnlyTest.java index a1b158c74..84ffb56cc 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithGlobalPropertiesOnlyTest.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithGlobalPropertiesOnlyTest.java @@ -44,7 +44,6 @@ public class SourceBindingWithGlobalPropertiesOnlyTest { @Autowired private BindingServiceProperties bindingServiceProperties; - @SuppressWarnings("unchecked") @Test public void testGlobalPropertiesSet() { BindingProperties bindingProperties = bindingServiceProperties.getBindingProperties(Source.OUTPUT); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithGlobalPropertiesTest.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithGlobalPropertiesTest.java index 2015e447b..fa6b77804 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithGlobalPropertiesTest.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/SourceBindingWithGlobalPropertiesTest.java @@ -25,7 +25,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.config.BindingProperties; -import org.springframework.cloud.stream.config.ChannelBindingServiceProperties; +import org.springframework.cloud.stream.config.BindingServiceProperties; import org.springframework.cloud.stream.messaging.Source; import org.springframework.cloud.stream.utils.MockBinderRegistryConfiguration; import org.springframework.context.annotation.Import; @@ -35,6 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Marius Bogoevici * @author Ilayaperumal Gopinathan * @author Gary Russell + * @author Oleg Zhurakousky */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SourceBindingWithGlobalPropertiesTest.TestSource.class, properties = { @@ -45,12 +46,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; public class SourceBindingWithGlobalPropertiesTest { @Autowired - private ChannelBindingServiceProperties channelBindingServiceProperties; + private BindingServiceProperties serviceProperties; - @SuppressWarnings("unchecked") @Test public void testGlobalPropertiesSet() { - BindingProperties bindingProperties = channelBindingServiceProperties.getBindingProperties(Source.OUTPUT); + BindingProperties bindingProperties = serviceProperties.getBindingProperties(Source.OUTPUT); Assertions.assertThat(bindingProperties.getContentType()).isEqualTo("application/json"); Assertions.assertThat(bindingProperties.getDestination()).isEqualTo("ticktock"); Assertions.assertThat(bindingProperties.getProducer().getRequiredGroups()).containsExactly("someGroup"); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binding/BindingServiceTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binding/BindingServiceTests.java index ffdc9f4ad..b1c6acfc0 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binding/BindingServiceTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binding/BindingServiceTests.java @@ -393,7 +393,7 @@ public class BindingServiceTests { assertThat(bindableType).isSameAs(SomeBindableType.class); } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Test public void testLateBindingConsumer() throws Exception { BindingServiceProperties properties = new BindingServiceProperties(); @@ -432,7 +432,7 @@ public class BindingServiceTests { binderFactory.destroy(); } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Test public void testLateBindingProducer() throws Exception { BindingServiceProperties properties = new BindingServiceProperties(); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binding/CustomPartitionedProducerTest.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binding/CustomPartitionedProducerTest.java index 841461c50..16d075c80 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binding/CustomPartitionedProducerTest.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binding/CustomPartitionedProducerTest.java @@ -57,7 +57,6 @@ public class CustomPartitionedProducerTest { private Source testSource; @Test - @SuppressWarnings("unchecked") public void testCustomPartitionedProducer() { DirectChannel messageChannel = (DirectChannel) this.testSource.output(); for (ChannelInterceptor channelInterceptor : messageChannel.getChannelInterceptors()) { diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/BinderConfigurationParsingTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/BinderConfigurationParsingTests.java index 65d94eaab..fd02dfff4 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/BinderConfigurationParsingTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/BinderConfigurationParsingTests.java @@ -40,7 +40,6 @@ import static org.hamcrest.Matchers.hasProperty; /** * @author Marius Bogoevici */ -@SuppressWarnings("Duplicates") public class BinderConfigurationParsingTests { private static ClassLoader classLoader = BinderConfigurationParsingTests.class.getClassLoader(); @@ -63,6 +62,7 @@ public class BinderConfigurationParsingTests { hasProperty("configurationClasses", hasItemInArray(StubBinder1Configuration.class))))); } + @SuppressWarnings("unchecked") @Test public void testParseTwoBindersConfigurations() throws Exception { // this is just checking that resources are passed and classes are loaded properly diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/converter/KryoMessageConverterTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/converter/KryoMessageConverterTests.java index 7cb348636..7a40be35d 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/converter/KryoMessageConverterTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/converter/KryoMessageConverterTests.java @@ -37,7 +37,7 @@ public class KryoMessageConverterTests { public void convertStringType() throws Exception { KryoMessageConverter kryoMessageConverter = new KryoMessageConverter(null,true); Message message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE,"application/x-java-object").build(); - Message converted = kryoMessageConverter.toMessage(message.getPayload(),message.getHeaders()); + Message converted = kryoMessageConverter.toMessage(message.getPayload(),message.getHeaders()); Assert.assertNotNull(converted); Assert.assertEquals("application/x-java-object;type=java.lang.String",converted.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString()); } @@ -51,7 +51,7 @@ public class KryoMessageConverterTests { Output output = new Output(baos); kryo.writeObject(output,foo); output.close(); - Message message = MessageBuilder.withPayload(baos.toByteArray()).setHeader(MessageHeaders.CONTENT_TYPE,KryoMessageConverter.KRYO_MIME_TYPE+";type=java.lang.String").build(); + Message message = MessageBuilder.withPayload(baos.toByteArray()).setHeader(MessageHeaders.CONTENT_TYPE,KryoMessageConverter.KRYO_MIME_TYPE+";type=java.lang.String").build(); Object result = kryoMessageConverter.fromMessage(message,String.class); Assert.assertEquals(foo,result); } @@ -65,7 +65,7 @@ public class KryoMessageConverterTests { Output output = new Output(baos); kryo.writeObject(output,foo); output.close(); - Message message = MessageBuilder.withPayload(baos.toByteArray()).build(); + Message message = MessageBuilder.withPayload(baos.toByteArray()).build(); Object result = kryoMessageConverter.fromMessage(message,String.class); Assert.assertNull(result); } @@ -73,14 +73,14 @@ public class KryoMessageConverterTests { @Test(expected = MessageConversionException.class) public void readWithWrongPayloadType() throws Exception{ KryoMessageConverter kryoMessageConverter = new KryoMessageConverter(null,true); - Message message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE,KryoMessageConverter.KRYO_MIME_TYPE+";type=java.lang.String").build(); + Message message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE,KryoMessageConverter.KRYO_MIME_TYPE+";type=java.lang.String").build(); kryoMessageConverter.fromMessage(message,String.class); } @Test(expected = MessageConversionException.class) public void readWithWrongPayloadFormat() throws Exception{ KryoMessageConverter kryoMessageConverter = new KryoMessageConverter(null,true); - Message message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE,KryoMessageConverter.KRYO_MIME_TYPE+";type=java.lang.String").build(); + Message message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE,KryoMessageConverter.KRYO_MIME_TYPE+";type=java.lang.String").build(); kryoMessageConverter.fromMessage(message,String.class); } diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/interceptor/BoundChannelsInterceptedTest.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/interceptor/BoundChannelsInterceptedTest.java index 678b7b5fb..a54fb8a78 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/interceptor/BoundChannelsInterceptedTest.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/interceptor/BoundChannelsInterceptedTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2017 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. @@ -23,7 +23,6 @@ import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.stream.annotation.Bindings; import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.messaging.Sink; import org.springframework.cloud.stream.utils.MockBinderRegistryConfiguration; @@ -46,6 +45,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * Verifies that interceptors used by modules are applied correctly to generated channels. * * @author Marius Bogoevici + * @author Oleg Zhurakousky */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = BoundChannelsInterceptedTest.Foo.class) @@ -54,16 +54,15 @@ public class BoundChannelsInterceptedTest { public static final Message TEST_MESSAGE = MessageBuilder.withPayload("bar").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build(); @Autowired - @Bindings(BoundChannelsInterceptedTest.Foo.class) - public Sink fooSink; + private Sink sink; @Autowired ChannelInterceptor channelInterceptor; @Test public void testBoundChannelsIntercepted() { - this.fooSink.input().send(TEST_MESSAGE); - verify(this.channelInterceptor).preSend(Mockito.any(), Mockito.eq(this.fooSink.input())); + sink.input().send(TEST_MESSAGE); + verify(this.channelInterceptor).preSend(Mockito.any(), Mockito.eq(this.sink.input())); verifyNoMoreInteractions(this.channelInterceptor); } diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/PartitionedConsumerTest.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/PartitionedConsumerTest.java index 4a05b0785..06430bc24 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/PartitionedConsumerTest.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/PartitionedConsumerTest.java @@ -25,7 +25,6 @@ import org.mockito.ArgumentMatcher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.stream.annotation.Bindings; import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.binder.Binder; import org.springframework.cloud.stream.binder.BinderFactory; @@ -57,11 +56,10 @@ public class PartitionedConsumerTest { private BinderFactory binderFactory; @Autowired - @Bindings(TestSink.class) private Sink testSink; @Test - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") public void testBindingPartitionedConsumer() { Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(ConsumerProperties.class); diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/PartitionedProducerTest.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/PartitionedProducerTest.java index c03ef86d5..4e332d99f 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/PartitionedProducerTest.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/PartitionedProducerTest.java @@ -48,7 +48,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; @SpringBootTest(classes = PartitionedProducerTest.TestSource.class) public class PartitionedProducerTest { - @SuppressWarnings("rawtypes") @Autowired private BinderFactory binderFactory; @@ -56,7 +55,7 @@ public class PartitionedProducerTest { private Source testSource; @Test - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public void testBindingPartitionedProducer() { Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(ProducerProperties.class);