Fixed warnings in spring-cloud-stream module

- Removed/modified unnecessary @SupressWarning annotations
 - Removed deprecated configuration for SharedChannelRegistry and fixed associated tests
 - Fixed and documehted other deprecations
This commit is contained in:
Oleg Zhurakousky
2017-11-22 14:22:58 -05:00
parent c94f946c85
commit 5a87211237
38 changed files with 102 additions and 105 deletions

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 Venil Noronha
* @author Janne Valkealahti * @author Janne Valkealahti
* @author Vinicius Carvalho * @author Vinicius Carvalho
* @author Oleg Zhurakousky
*/ */
@EnableBinding @EnableBinding
public class AggregateApplicationBuilder implements AggregateApplication, ApplicationContextAware, public class AggregateApplicationBuilder implements AggregateApplication, ApplicationContextAware,
@@ -189,7 +190,7 @@ public class AggregateApplicationBuilder implements AggregateApplication, Applic
apps.add(sinkConfigurer); apps.add(sinkConfigurer);
} }
LinkedHashMap<Class<?>, String> appsToEmbed = new LinkedHashMap<>(); LinkedHashMap<Class<?>, String> appsToEmbed = new LinkedHashMap<>();
LinkedHashMap<AppConfigurer, String> appConfigurers = new LinkedHashMap<>(); LinkedHashMap<AppConfigurer<?>, String> appConfigurers = new LinkedHashMap<>();
for (int i = 0; i < apps.size(); i++) { for (int i = 0; i < apps.size(); i++) {
AppConfigurer<?> appConfigurer = apps.get(i); AppConfigurer<?> appConfigurer = apps.get(i);
Class<?> appToEmbed = appConfigurer.getApp(); Class<?> appToEmbed = appConfigurer.getApp();
@@ -218,16 +219,14 @@ public class AggregateApplicationBuilder implements AggregateApplication, Applic
SharedBindingTargetRegistry sharedBindingTargetRegistry = new SharedBindingTargetRegistry(); SharedBindingTargetRegistry sharedBindingTargetRegistry = new SharedBindingTargetRegistry();
this.parentContext.getBeanFactory().registerSingleton("sharedBindingTargetRegistry", this.parentContext.getBeanFactory().registerSingleton("sharedBindingTargetRegistry",
sharedBindingTargetRegistry); sharedBindingTargetRegistry);
this.parentContext.getBeanFactory().registerSingleton("sharedChannelRegistry",
new SharedChannelRegistry(sharedBindingTargetRegistry));
} }
} }
SharedBindingTargetRegistry sharedBindingTargetRegistry = this.parentContext SharedBindingTargetRegistry sharedBindingTargetRegistry = this.parentContext
.getBean(SharedBindingTargetRegistry.class); .getBean(SharedBindingTargetRegistry.class);
AggregateApplicationUtils.prepareSharedBindingTargetRegistry(sharedBindingTargetRegistry, appsToEmbed); AggregateApplicationUtils.prepareSharedBindingTargetRegistry(sharedBindingTargetRegistry, appsToEmbed);
for (Map.Entry<AppConfigurer, String> appConfigurerEntry : appConfigurers.entrySet()) { for (Map.Entry<AppConfigurer<?>, String> appConfigurerEntry : appConfigurers.entrySet()) {
AppConfigurer appConfigurer = appConfigurerEntry.getKey(); AppConfigurer<?> appConfigurer = appConfigurerEntry.getKey();
if (appConfigurerEntry.getValue() == null) { if (appConfigurerEntry.getValue() == null) {
continue; continue;
} }
@@ -302,12 +301,6 @@ public class AggregateApplicationBuilder implements AggregateApplication, Applic
public SharedBindingTargetRegistry sharedBindingTargetRegistry() { public SharedBindingTargetRegistry sharedBindingTargetRegistry() {
return new SharedBindingTargetRegistry(); return new SharedBindingTargetRegistry();
} }
@Bean
@ConditionalOnMissingBean(SharedChannelRegistry.class)
public SharedChannelRegistry sharedChannelRegistry(SharedBindingTargetRegistry sharedBindingTargetRegistry) {
return new SharedChannelRegistry(sharedBindingTargetRegistry);
}
} }
public class SourceConfigurer extends AppConfigurer<SourceConfigurer> { public class SourceConfigurer extends AppConfigurer<SourceConfigurer> {

View File

@@ -20,6 +20,7 @@ import java.util.LinkedHashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.springframework.boot.Banner.Mode; import org.springframework.boot.Banner.Mode;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.stream.internal.InternalPropertyNames; import org.springframework.cloud.stream.internal.InternalPropertyNames;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
@@ -44,7 +45,7 @@ abstract class AggregateApplicationUtils {
String[] args, final boolean selfContained, boolean webEnvironment, String[] args, final boolean selfContained, boolean webEnvironment,
boolean headless) { boolean headless) {
SpringApplicationBuilder aggregatorParentConfiguration = new SpringApplicationBuilder(); SpringApplicationBuilder aggregatorParentConfiguration = new SpringApplicationBuilder();
aggregatorParentConfiguration.sources(sources).web(webEnvironment) aggregatorParentConfiguration.sources(sources).web(WebApplicationType.NONE)
.headless(headless) .headless(headless)
.properties("spring.jmx.default-domain=" .properties("spring.jmx.default-domain="
+ AggregateApplicationBuilder.ParentConfiguration.class.getName(), + AggregateApplicationBuilder.ParentConfiguration.class.getName(),
@@ -60,7 +61,7 @@ abstract class AggregateApplicationUtils {
protected static SpringApplicationBuilder embedApp( protected static SpringApplicationBuilder embedApp(
ConfigurableApplicationContext parentContext, String namespace, ConfigurableApplicationContext parentContext, String namespace,
Class<?> app) { 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("spring.jmx.default-domain=" + namespace)
.properties( .properties(
InternalPropertyNames.NAMESPACE_PROPERTY_NAME + "=" + namespace) InternalPropertyNames.NAMESPACE_PROPERTY_NAME + "=" + namespace)

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ public class SharedBindingTargetRegistry {
private Map<String, Object> sharedBindingTargets = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER); private Map<String, Object> sharedBindingTargets = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
@SuppressWarnings("unchecked")
public <T> T get(String id, Class<T> bindingTargetType) { public <T> T get(String id, Class<T> bindingTargetType) {
Object sharedBindingTarget = this.sharedBindingTargets.get(id); Object sharedBindingTarget = this.sharedBindingTargets.get(id);
if (sharedBindingTarget == null) { if (sharedBindingTarget == null) {

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * {@link SharedChannelRegistry} in previous versions and will be removed in the future.
* *
* @author Marius Bogoevici * @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 @Deprecated
public class SharedChannelRegistry { public class SharedChannelRegistry {

View File

@@ -39,6 +39,7 @@ import org.springframework.integration.config.EnableIntegration;
* @author Marius Bogoevici * @author Marius Bogoevici
* @author David Turanski * @author David Turanski
*/ */
@SuppressWarnings("deprecation")
@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE }) @Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented

View File

@@ -82,6 +82,9 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
this.provisioningProvider = provisioningProvider; this.provisioningProvider = provisioningProvider;
} }
/**
* @deprecated As of release 2.0. Please use other constructors.
*/
@Deprecated @Deprecated
protected AbstractMessageChannelBinder(boolean supportsHeadersNatively, String[] headersToEmbed, protected AbstractMessageChannelBinder(boolean supportsHeadersNatively, String[] headersToEmbed,
PP provisioningProvider) { PP provisioningProvider) {
@@ -95,7 +98,7 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
* for handling the middleware specific logic. If the returned producer message * for handling the middleware specific logic. If the returned producer message
* handler is an {@link InitializingBean} then * handler is an {@link InitializingBean} then
* {@link InitializingBean#afterPropertiesSet()} will be called on it. Similarly, if * {@link InitializingBean#afterPropertiesSet()} will be called on it. Similarly, if
* the returned producer message handler e ndpoint is a {@link Lifecycle}, then * the returned producer message handler endpoint is a {@link Lifecycle}, then
* {@link Lifecycle#start()} will be called on it. * {@link Lifecycle#start()} will be called on it.
* *
* @param destination the name of the destination * @param destination the name of the destination

View File

@@ -27,6 +27,7 @@ import java.util.Set;
import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.Banner.Mode; import org.springframework.boot.Banner.Mode;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.stream.reflection.GenericsUtils; import org.springframework.cloud.stream.reflection.GenericsUtils;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@@ -38,6 +39,7 @@ import org.springframework.core.env.StandardEnvironment;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* Default {@link BinderFactory} implementation. * Default {@link BinderFactory} implementation.
* *
@@ -160,6 +162,7 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl
return binderInstance; return binderInstance;
} }
@SuppressWarnings("unchecked")
private <T> Binder<T, ?, ?> getBinderInstance(String configurationName) { private <T> Binder<T, ?, ?> getBinderInstance(String configurationName) {
if (!this.binderInstanceCache.containsKey(configurationName)) { if (!this.binderInstanceCache.containsKey(configurationName)) {
BinderConfiguration binderConfiguration = this.binderConfigurations.get(configurationName); BinderConfiguration binderConfiguration = this.binderConfigurations.get(configurationName);
@@ -193,7 +196,7 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl
.sources(configurationClasses.toArray(new Class<?>[] {})) .sources(configurationClasses.toArray(new Class<?>[] {}))
.bannerMode(Mode.OFF) .bannerMode(Mode.OFF)
.logStartupInfo(false) .logStartupInfo(false)
.web(false); .web(WebApplicationType.NONE);
// If the environment is not customized and a main context is available, we // If the environment is not customized and a main context is available, we
// will set the latter as parent. // will set the latter as parent.
// This ensures that the defaults and user-defined customizations (e.g. custom // 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 ConfigurableApplicationContext binderProducingContext = springApplicationBuilder
.run(args.toArray(new String[args.size()])); .run(args.toArray(new String[args.size()]));
@SuppressWarnings("unchecked")
Binder<T, ?, ?> binder = binderProducingContext.getBean(Binder.class); Binder<T, ?, ?> binder = binderProducingContext.getBean(Binder.class);
if (this.listeners != null) { if (this.listeners != null) {
for (Listener binderFactoryListener : listeners) { for (Listener binderFactoryListener : listeners) {

View File

@@ -109,8 +109,4 @@ public class PartitionHandler {
return this.partitionKeyExtractorStrategy.extractKey(message); return this.partitionKeyExtractorStrategy.extractKey(message);
} }
private int invokePartitionSelector(Object key) {
return this.partitionSelectorStrategy.selectPartition(key, producerProperties.getPartitionCount());
}
} }

View File

@@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
* @author Dave Syer * @author Dave Syer
* @author Artem Bilan * @author Artem Bilan
*/ */
@SuppressWarnings("deprecation")
public abstract class BindingBeanDefinitionRegistryUtils { public abstract class BindingBeanDefinitionRegistryUtils {
public static void registerInputBindingTargetBeanDefinition(String qualifierValue, String name, 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, public static void registerBindingTargetsQualifiedBeanDefinitions(Class<?> parent, Class<?> type,
final BeanDefinitionRegistry registry) { final BeanDefinitionRegistry registry) {

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Map containing dynamic channel names and their bindings.
*/ */
private Map<String, Binding> outputBindings = new HashMap<>(); private Map<String, Binding<?>> outputBindings = new HashMap<>();
public void addOutputBinding(String name, Binding binding) { public void addOutputBinding(String name, Binding<?> binding) {
this.outputBindings.put(name, binding); this.outputBindings.put(name, binding);
} }
@@ -49,7 +49,7 @@ public final class DynamicDestinationsBindable extends BindableAdapter {
@Override @Override
public void unbindOutputs(BindingService adapter) { public void unbindOutputs(BindingService adapter) {
for (Map.Entry<String, Binding> entry : outputBindings.entrySet()) { for (Map.Entry<String, Binding<?>> entry : outputBindings.entrySet()) {
entry.getValue().unbind(); entry.getValue().unbind();
} }
outputBindings.clear(); outputBindings.clear();

View File

@@ -53,7 +53,7 @@ public abstract class StreamAnnotationCommonMethodUtils {
public static int outputAnnotationCount(Method method) { public static int outputAnnotationCount(Method method) {
int outputAnnotationCount = 0; int outputAnnotationCount = 0;
for (int parameterIndex = 0; parameterIndex < method.getParameterTypes().length; parameterIndex++) { 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)) { if (methodParameter.hasParameterAnnotation(Output.class)) {
outputAnnotationCount++; outputAnnotationCount++;
} }

View File

@@ -40,7 +40,7 @@ public class StreamListenerMethodUtils {
protected static int inputAnnotationCount(Method method) { protected static int inputAnnotationCount(Method method) {
int inputAnnotationCount = 0; int inputAnnotationCount = 0;
for (int parameterIndex = 0; parameterIndex < method.getParameterTypes().length; parameterIndex++) { 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)) { if (methodParameter.hasParameterAnnotation(Input.class)) {
inputAnnotationCount++; inputAnnotationCount++;
} }
@@ -51,7 +51,7 @@ public class StreamListenerMethodUtils {
protected static int outputAnnotationCount(Method method) { protected static int outputAnnotationCount(Method method) {
int outputAnnotationCount = 0; int outputAnnotationCount = 0;
for (int parameterIndex = 0; parameterIndex < method.getParameterTypes().length; parameterIndex++) { 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)) { if (methodParameter.hasParameterAnnotation(Output.class)) {
outputAnnotationCount++; outputAnnotationCount++;
} }
@@ -90,7 +90,7 @@ public class StreamListenerMethodUtils {
Assert.isTrue(!StringUtils.hasText(condition), Assert.isTrue(!StringUtils.hasText(condition),
StreamListenerErrorMessages.CONDITION_ON_DECLARATIVE_METHOD); StreamListenerErrorMessages.CONDITION_ON_DECLARATIVE_METHOD);
for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) {
MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(method, parameterIndex); MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex);
if (methodParameter.hasParameterAnnotation(Input.class)) { if (methodParameter.hasParameterAnnotation(Input.class)) {
String inboundName = (String) AnnotationUtils String inboundName = (String) AnnotationUtils
.getValue(methodParameter.getParameterAnnotation(Input.class)); .getValue(methodParameter.getParameterAnnotation(Input.class));
@@ -115,7 +115,7 @@ public class StreamListenerMethodUtils {
int numAnnotatedMethodParameters = 0; int numAnnotatedMethodParameters = 0;
int numPayloadAnnotations = 0; int numPayloadAnnotations = 0;
for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) {
MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(method, parameterIndex); MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex);
if (methodParameter.hasParameterAnnotations()) { if (methodParameter.hasParameterAnnotations()) {
numAnnotatedMethodParameters++; numAnnotatedMethodParameters++;
} }

View File

@@ -17,6 +17,7 @@
package org.springframework.cloud.stream.config; package org.springframework.cloud.stream.config;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; 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.annotation.EnableBinding;
import org.springframework.cloud.stream.binding.BindingBeanDefinitionRegistryUtils; import org.springframework.cloud.stream.binding.BindingBeanDefinitionRegistryUtils;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
@@ -27,11 +28,13 @@ import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
* @deprecated as ov version 2.0 based on deprecation of {@link Bindings} anntoation
*
* @author Marius Bogoevici * @author Marius Bogoevici
* @author Dave Syer * @author Dave Syer
* @author Artem Bilan * @author Artem Bilan
*/ */
@Deprecated
public class BindingBeansRegistrar implements ImportBeanDefinitionRegistrar { public class BindingBeansRegistrar implements ImportBeanDefinitionRegistrar {
@Override @Override

View File

@@ -188,7 +188,12 @@ public class BindingServiceConfiguration {
} }
/**
*
* @deprecated as of version 2.0
*/
@Bean @Bean
@Deprecated
// provided for backwards compatibility scenarios // provided for backwards compatibility scenarios
public ChannelBindingServiceProperties channelBindingServiceProperties( public ChannelBindingServiceProperties channelBindingServiceProperties(
BindingServiceProperties bindingServiceProperties) { BindingServiceProperties bindingServiceProperties) {

View File

@@ -83,7 +83,7 @@ public class EnvironmentEntryInitializingTreeMap<T> extends AbstractMap<String,
@Override @Override
public T get(Object key) { public T get(Object key) {
if (!this.delegate.containsKey(key) && key instanceof String) { if (!this.delegate.containsKey(key) && key instanceof String) {
T entry = BeanUtils.instantiate(entryClass); T entry = BeanUtils.instantiateClass(entryClass);
Binder binder = new Binder(ConfigurationPropertySources.get(environment),new PropertySourcesPlaceholdersResolver(environment),this.conversionService); Binder binder = new Binder(ConfigurationPropertySources.get(environment),new PropertySourcesPlaceholdersResolver(environment),this.conversionService);
binder.bind(defaultsPrefix, Bindable.ofInstance(entry)); binder.bind(defaultsPrefix, Bindable.ofInstance(entry));
this.delegate.put((String) key, entry); this.delegate.put((String) key, entry);

View File

@@ -97,16 +97,13 @@ public class AggregationTest {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void testModuleAggregationUsingSharedChannelRegistry() { public void testModuleAggregationUsingSharedChannelRegistry() {
// test backward compatibility // test backward compatibility
aggregatedApplicationContext = new AggregateApplicationBuilder( aggregatedApplicationContext = new AggregateApplicationBuilder(
MockBinderRegistryConfiguration.class, "--server.port=0") MockBinderRegistryConfiguration.class, "--server.port=0")
.from(TestSource.class).to(TestProcessor.class).run(); .from(TestSource.class).to(TestProcessor.class).run();
org.springframework.cloud.stream.aggregate.SharedChannelRegistry sharedChannelRegistry = SharedBindingTargetRegistry sharedChannelRegistry = aggregatedApplicationContext.getBean(SharedBindingTargetRegistry.class);
aggregatedApplicationContext.getBean(org.springframework.cloud.stream.aggregate.SharedChannelRegistry.class); BindingTargetFactory channelFactory = aggregatedApplicationContext.getBean(BindingTargetFactory.class);
BindingTargetFactory channelFactory = aggregatedApplicationContext
.getBean(BindingTargetFactory.class);
assertThat(channelFactory).isNotNull(); assertThat(channelFactory).isNotNull();
assertThat(sharedChannelRegistry.getAll().keySet()).hasSize(2); assertThat(sharedChannelRegistry.getAll().keySet()).hasSize(2);
aggregatedApplicationContext.close(); aggregatedApplicationContext.close();
@@ -346,22 +343,17 @@ public class AggregationTest {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void testNamespaces() { public void testNamespaces() {
aggregatedApplicationContext = new AggregateApplicationBuilder( aggregatedApplicationContext = new AggregateApplicationBuilder(
MockBinderRegistryConfiguration.class, "--server.port=0") MockBinderRegistryConfiguration.class, "--server.port=0")
.from(TestSource.class).namespace("foo").to(TestProcessor.class) .from(TestSource.class).namespace("foo").to(TestProcessor.class)
.namespace("bar").run(); .namespace("bar").run();
org.springframework.cloud.stream.aggregate.SharedChannelRegistry sharedChannelRegistry = SharedBindingTargetRegistry sharedChannelRegistry = aggregatedApplicationContext.getBean(SharedBindingTargetRegistry.class);
aggregatedApplicationContext.getBean(org.springframework.cloud.stream.aggregate.SharedChannelRegistry.class); BindingTargetFactory channelFactory = aggregatedApplicationContext.getBean(BindingTargetFactory.class);
BindingTargetFactory channelFactory = aggregatedApplicationContext MessageChannel fooOutput = sharedChannelRegistry.get("foo.output", MessageChannel.class);
.getBean(BindingTargetFactory.class);
Object fooOutput = sharedChannelRegistry.get("foo.output");
assertThat(fooOutput).isNotNull(); assertThat(fooOutput).isNotNull();
assertThat(fooOutput).isInstanceOf(MessageChannel.class); Object barInput = sharedChannelRegistry.get("bar.input", MessageChannel.class);
Object barInput = sharedChannelRegistry.get("bar.input");
assertThat(barInput).isNotNull(); assertThat(barInput).isNotNull();
assertThat(barInput).isInstanceOf(MessageChannel.class);
assertThat(channelFactory).isNotNull(); assertThat(channelFactory).isNotNull();
assertThat(sharedChannelRegistry.getAll().keySet()).hasSize(2); assertThat(sharedChannelRegistry.getAll().keySet()).hasSize(2);
aggregatedApplicationContext.close(); aggregatedApplicationContext.close();

View File

@@ -74,7 +74,6 @@ public class AbstractMessageChannelBinderTests {
ErrorInfrastructure errorInfra = binder.errorInfrastructure; ErrorInfrastructure errorInfra = binder.errorInfrastructure;
SubscribableChannel errorChannel = errorInfra.getErrorChannel(); SubscribableChannel errorChannel = errorInfra.getErrorChannel();
assertThat(errorChannel).isNotNull(); assertThat(errorChannel).isNotNull();
@SuppressWarnings("unchecked")
Set<MessageHandler> handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class); Set<MessageHandler> handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class);
assertThat(handlers.size()).isEqualTo(2); assertThat(handlers.size()).isEqualTo(2);
Iterator<MessageHandler> iterator = handlers.iterator(); Iterator<MessageHandler> iterator = handlers.iterator();
@@ -125,7 +124,6 @@ public class AbstractMessageChannelBinderTests {
ErrorInfrastructure errorInfra = binder.errorInfrastructure; ErrorInfrastructure errorInfra = binder.errorInfrastructure;
SubscribableChannel errorChannel = errorInfra.getErrorChannel(); SubscribableChannel errorChannel = errorInfra.getErrorChannel();
assertThat(errorChannel).isNotNull(); assertThat(errorChannel).isNotNull();
@SuppressWarnings("unchecked")
Set<MessageHandler> handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class); Set<MessageHandler> handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class);
assertThat(handlers.size()).isEqualTo(2); assertThat(handlers.size()).isEqualTo(2);
Iterator<MessageHandler> iterator = handlers.iterator(); Iterator<MessageHandler> iterator = handlers.iterator();
@@ -154,9 +152,8 @@ public class AbstractMessageChannelBinderTests {
this(false); this(false);
} }
@SuppressWarnings("unchecked")
StubMessageChannelBinder(boolean hasRecoverer) { StubMessageChannelBinder(boolean hasRecoverer) {
super(true, null, Mockito.mock(ProvisioningProvider.class)); super(null, Mockito.mock(ProvisioningProvider.class));
mockProvisioner(); mockProvisioner();
this.hasRecoverer = hasRecoverer; this.hasRecoverer = hasRecoverer;
} }

View File

@@ -49,7 +49,7 @@ public class ArbitraryInterfaceWithBindingTargetsTests {
@Autowired @Autowired
private BinderFactory binderFactory; private BinderFactory binderFactory;
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
@Test @Test
public void testArbitraryInterfaceChannelsBound() { public void testArbitraryInterfaceChannelsBound() {
Binder binder = binderFactory.getBinder(null, MessageChannel.class); Binder binder = binderFactory.getBinder(null, MessageChannel.class);

View File

@@ -48,7 +48,7 @@ public class ArbitraryInterfaceWithDefaultsTests {
@Autowired @Autowired
private BinderFactory binderFactory; private BinderFactory binderFactory;
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
@Test @Test
public void testArbitraryInterfaceChannelsBound() { public void testArbitraryInterfaceChannelsBound() {
final Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); final Binder binder = this.binderFactory.getBinder(null, MessageChannel.class);

View File

@@ -23,6 +23,7 @@ import java.net.URLClassLoader;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.annotation.EnableBinding;
@@ -66,18 +67,18 @@ public class BinderFactoryConfigurationTests {
return new SpringApplicationBuilder(SimpleApplication.class) return new SpringApplicationBuilder(SimpleApplication.class)
.resourceLoader(new DefaultResourceLoader(classLoader)) .resourceLoader(new DefaultResourceLoader(classLoader))
.properties(properties) .properties(properties)
.web(false) .web(WebApplicationType.NONE)
.run(); .run();
} }
private static ConfigurableApplicationContext createBinderTestContextWithSources(Class[] sources, private static ConfigurableApplicationContext createBinderTestContextWithSources(Class<?>[] sources,
String[] additionalClasspathDirectories, String[] additionalClasspathDirectories,
String... properties) throws IOException { String... properties) throws IOException {
ClassLoader classLoader = createClassLoader(additionalClasspathDirectories, properties); ClassLoader classLoader = createClassLoader(additionalClasspathDirectories, properties);
return new SpringApplicationBuilder(sources) return new SpringApplicationBuilder(sources)
.resourceLoader(new DefaultResourceLoader(classLoader)) .resourceLoader(new DefaultResourceLoader(classLoader))
.properties(properties) .properties(properties)
.web(false) .web(WebApplicationType.NONE)
.run(); .run();
} }
@@ -115,6 +116,7 @@ public class BinderFactoryConfigurationTests {
"spring.cloud.stream.internal.selfContained=true"); "spring.cloud.stream.internal.selfContained=true");
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void loadBinderTypeRegistryWithOneBinder() throws Exception { public void loadBinderTypeRegistryWithOneBinder() throws Exception {
ConfigurableApplicationContext context = createBinderTestContext( ConfigurableApplicationContext context = createBinderTestContext(
@@ -136,6 +138,7 @@ public class BinderFactoryConfigurationTests {
assertThat(defaultBinder).isSameAs(binder1); assertThat(defaultBinder).isSameAs(binder1);
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void loadBinderTypeRegistryWithOneBinderAndSharedEnvironment() throws Exception { public void loadBinderTypeRegistryWithOneBinderAndSharedEnvironment() throws Exception {
ConfigurableApplicationContext context = createBinderTestContext( ConfigurableApplicationContext context = createBinderTestContext(
@@ -147,6 +150,7 @@ public class BinderFactoryConfigurationTests {
assertThat(binder1).hasFieldOrPropertyWithValue("name", "foo"); assertThat(binder1).hasFieldOrPropertyWithValue("name", "foo");
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void loadBinderTypeRegistryWithOneCustomBinderAndSharedEnvironment() throws Exception { public void loadBinderTypeRegistryWithOneCustomBinderAndSharedEnvironment() throws Exception {
ConfigurableApplicationContext context = createBinderTestContext( ConfigurableApplicationContext context = createBinderTestContext(
@@ -162,6 +166,7 @@ public class BinderFactoryConfigurationTests {
assertThat(binderFactory.getBinder(null, MessageChannel.class)).isSameAs(binder1); assertThat(binderFactory.getBinder(null, MessageChannel.class)).isSameAs(binder1);
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void loadBinderTypeRegistryWithTwoBinders() throws Exception { public void loadBinderTypeRegistryWithTwoBinders() throws Exception {
ConfigurableApplicationContext context = createBinderTestContext(new String[] { "binder1", "binder2" }); ConfigurableApplicationContext context = createBinderTestContext(new String[] { "binder1", "binder2" });
@@ -192,6 +197,7 @@ public class BinderFactoryConfigurationTests {
assertThat(binder2).isInstanceOf(StubBinder2.class); assertThat(binder2).isInstanceOf(StubBinder2.class);
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void loadBinderTypeRegistryWithCustomNonDefaultCandidate() throws Exception { public void loadBinderTypeRegistryWithCustomNonDefaultCandidate() throws Exception {
ConfigurableApplicationContext context = createBinderTestContext( ConfigurableApplicationContext context = createBinderTestContext(
@@ -217,6 +223,7 @@ public class BinderFactoryConfigurationTests {
assertThat(binder1).isSameAs(defaultBinder); assertThat(binder1).isSameAs(defaultBinder);
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void loadDefaultBinderWithTwoBinders() throws Exception { public void loadDefaultBinderWithTwoBinders() throws Exception {

View File

@@ -48,37 +48,35 @@ import static org.mockito.Matchers.same;
*/ */
public class ErrorBindingTests { public class ErrorBindingTests {
@SuppressWarnings("rawtypes")
@Test @Test
public void testErrorChannelNotBoundByDefault() { public void testErrorChannelNotBoundByDefault() {
ConfigurableApplicationContext applicationContext = SpringApplication.run(TestProcessor.class, ConfigurableApplicationContext applicationContext = SpringApplication.run(TestProcessor.class,
"--server.port=0"); "--server.port=0");
BinderFactory binderFactory = applicationContext.getBean(BinderFactory.class); BinderFactory binderFactory = applicationContext.getBean(BinderFactory.class);
@SuppressWarnings("unchecked")
Binder binder = binderFactory.getBinder(null, MessageChannel.class); 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)); any(ConsumerProperties.class));
Mockito.verify(binder).bindProducer(eq("output"), any(MessageChannel.class), any(ProducerProperties.class)); Mockito.verify(binder).bindProducer(eq("output"), any(MessageChannel.class), any(ProducerProperties.class));
Mockito.verifyNoMoreInteractions(binder); Mockito.verifyNoMoreInteractions(binder);
applicationContext.close(); applicationContext.close();
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void testErrorChannelBoundIfConfigured() { public void testErrorChannelBoundIfConfigured() {
ConfigurableApplicationContext applicationContext = SpringApplication.run(TestProcessor.class, ConfigurableApplicationContext applicationContext = SpringApplication.run(TestProcessor.class,
"--spring.cloud.stream.bindings.error.destination=foo", "--server.port=0"); "--spring.cloud.stream.bindings.error.destination=foo", "--server.port=0");
BinderFactory binderFactory = applicationContext.getBean(BinderFactory.class, MessageChannel.class); BinderFactory binderFactory = applicationContext.getBean(BinderFactory.class, MessageChannel.class);
@SuppressWarnings("unchecked")
Binder binder = binderFactory.getBinder(null, MessageChannel.class); Binder binder = binderFactory.getBinder(null, MessageChannel.class);
MessageChannel errorChannel = applicationContext.getBean(BindingServiceConfiguration.ERROR_BRIDGE_CHANNEL, MessageChannel errorChannel = applicationContext.getBean(BindingServiceConfiguration.ERROR_BRIDGE_CHANNEL,
MessageChannel.class); 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)); any(ConsumerProperties.class));
Mockito.verify(binder).bindProducer(eq("output"), any(MessageChannel.class), any(ProducerProperties.class)); Mockito.verify(binder).bindProducer(eq("output"), any(MessageChannel.class), any(ProducerProperties.class));
Mockito.verify(binder).bindProducer(eq("foo"), same(errorChannel), 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"))); errorChannel.send(new GenericMessage<>(new Exception("throwing exception")));
assertThat(received.get()).isTrue(); assertThat(received.get()).isTrue();
applicationContext.close(); applicationContext.close();
@@ -157,6 +152,7 @@ public class ErrorBindingTests {
private class Foo { private class Foo {
String foo; String foo;
@SuppressWarnings("unused") // used json ser/deser
public String getFoo() { public String getFoo() {
return foo; return foo;
} }

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.DirectFieldAccessor;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.actuate.health.CompositeHealthIndicator; import org.springframework.boot.actuate.health.CompositeHealthIndicator;
import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.OrderedHealthAggregator; import org.springframework.boot.actuate.health.OrderedHealthAggregator;
@@ -66,9 +67,10 @@ public class HealthIndicatorsConfigurationTests {
BinderFactoryConfigurationTests.class.getClassLoader()); BinderFactoryConfigurationTests.class.getClassLoader());
return new SpringApplicationBuilder(SimpleSource.class) return new SpringApplicationBuilder(SimpleSource.class)
.resourceLoader(new DefaultResourceLoader(classLoader)) .resourceLoader(new DefaultResourceLoader(classLoader))
.properties(properties).web(false).run(); .properties(properties).web(WebApplicationType.NONE).run();
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void healthIndicatorsCheck() throws Exception { public void healthIndicatorsCheck() throws Exception {
ConfigurableApplicationContext context = createBinderTestContext(new String[] { "binder1", "binder2" }, ConfigurableApplicationContext context = createBinderTestContext(new String[] { "binder1", "binder2" },
@@ -93,6 +95,7 @@ public class HealthIndicatorsConfigurationTests {
context.close(); context.close();
} }
@SuppressWarnings("rawtypes")
@Test @Test
public void healthIndicatorsCheckWhenDisabled() throws Exception { public void healthIndicatorsCheckWhenDisabled() throws Exception {
ConfigurableApplicationContext context = createBinderTestContext( ConfigurableApplicationContext context = createBinderTestContext(

View File

@@ -45,7 +45,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
*/ */
public class InputOutputBindingOrderTest { public class InputOutputBindingOrderTest {
@SuppressWarnings("unchecked")
@Test @Test
public void testInputOutputBindingOrder() { public void testInputOutputBindingOrder() {
ConfigurableApplicationContext applicationContext = SpringApplication.run(TestSource.class, "--server.port=-1"); ConfigurableApplicationContext applicationContext = SpringApplication.run(TestSource.class, "--server.port=-1");
@@ -83,7 +82,7 @@ public class InputOutputBindingOrderTest {
private boolean running; private boolean running;
@Override @Override
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
public synchronized void start() { public synchronized void start() {
Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); Binder binder = this.binderFactory.getBinder(null, MessageChannel.class);
verify(binder).bindProducer(eq("output"), eq(this.processor.output()), Mockito.<ProducerProperties>any()); verify(binder).bindProducer(eq("output"), eq(this.processor.output()), Mockito.<ProducerProperties>any());

View File

@@ -49,7 +49,7 @@ public class ProcessorBindingWithBindingTargetsTests {
@Autowired @Autowired
private Processor testProcessor; private Processor testProcessor;
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
@Test @Test
public void testSourceOutputChannelBound() { public void testSourceOutputChannelBound() {
final Binder binder = binderFactory.getBinder(null, MessageChannel.class); final Binder binder = binderFactory.getBinder(null, MessageChannel.class);

View File

@@ -48,7 +48,7 @@ public class ProcessorBindingsWithDefaultsTests {
@Autowired @Autowired
private Processor processor; private Processor processor;
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
@Test @Test
public void testSourceOutputChannelBound() { public void testSourceOutputChannelBound() {
Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); Binder binder = this.binderFactory.getBinder(null, MessageChannel.class);

View File

@@ -51,7 +51,7 @@ public class SinkBindingWithDefaultTargetsTests {
@Autowired @Autowired
private Sink testSink; private Sink testSink;
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
@Test @Test
public void testSourceOutputChannelBound() { public void testSourceOutputChannelBound() {
Binder binder = binderFactory.getBinder(null, MessageChannel.class); Binder binder = binderFactory.getBinder(null, MessageChannel.class);

View File

@@ -49,7 +49,7 @@ public class SinkBindingWithDefaultsTests {
@Autowired @Autowired
private Sink testSink; private Sink testSink;
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
@Test @Test
public void testSourceOutputChannelBound() { public void testSourceOutputChannelBound() {
Binder binder = binderFactory.getBinder(null, MessageChannel.class); Binder binder = binderFactory.getBinder(null, MessageChannel.class);

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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) @SpringBootTest(classes = SourceBindingWithBindingTargetsTests.TestSource.class)
public class SourceBindingWithBindingTargetsTests { public class SourceBindingWithBindingTargetsTests {
@SuppressWarnings("rawtypes")
@Autowired @Autowired
private BinderFactory binderFactory; private BinderFactory binderFactory;
@@ -57,7 +56,7 @@ public class SourceBindingWithBindingTargetsTests {
@Qualifier(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME) @Qualifier(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME)
private PublishSubscribeChannel errorChannel; private PublishSubscribeChannel errorChannel;
@SuppressWarnings("unchecked") @SuppressWarnings("rawtypes")
@Test @Test
public void testSourceOutputChannelBound() { public void testSourceOutputChannelBound() {
Binder binder = binderFactory.getBinder(null, MessageChannel.class); Binder binder = binderFactory.getBinder(null, MessageChannel.class);

View File

@@ -41,14 +41,13 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
@SpringBootTest(classes = SourceBindingWithDefaultsTests.TestSource.class) @SpringBootTest(classes = SourceBindingWithDefaultsTests.TestSource.class)
public class SourceBindingWithDefaultsTests { public class SourceBindingWithDefaultsTests {
@SuppressWarnings("rawtypes")
@Autowired @Autowired
private BinderFactory binderFactory; private BinderFactory binderFactory;
@Autowired @Autowired
private Source testSource; private Source testSource;
@SuppressWarnings("unchecked") @SuppressWarnings("rawtypes")
@Test @Test
public void testSourceOutputChannelBound() { public void testSourceOutputChannelBound() {
Binder binder = binderFactory.getBinder(null, MessageChannel.class); Binder binder = binderFactory.getBinder(null, MessageChannel.class);

View File

@@ -44,7 +44,6 @@ public class SourceBindingWithGlobalPropertiesOnlyTest {
@Autowired @Autowired
private BindingServiceProperties bindingServiceProperties; private BindingServiceProperties bindingServiceProperties;
@SuppressWarnings("unchecked")
@Test @Test
public void testGlobalPropertiesSet() { public void testGlobalPropertiesSet() {
BindingProperties bindingProperties = bindingServiceProperties.getBindingProperties(Source.OUTPUT); BindingProperties bindingProperties = bindingServiceProperties.getBindingProperties(Source.OUTPUT);

View File

@@ -25,7 +25,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.config.BindingProperties; 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.messaging.Source;
import org.springframework.cloud.stream.utils.MockBinderRegistryConfiguration; import org.springframework.cloud.stream.utils.MockBinderRegistryConfiguration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@@ -35,6 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Marius Bogoevici * @author Marius Bogoevici
* @author Ilayaperumal Gopinathan * @author Ilayaperumal Gopinathan
* @author Gary Russell * @author Gary Russell
* @author Oleg Zhurakousky
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = SourceBindingWithGlobalPropertiesTest.TestSource.class, properties = { @SpringBootTest(classes = SourceBindingWithGlobalPropertiesTest.TestSource.class, properties = {
@@ -45,12 +46,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class SourceBindingWithGlobalPropertiesTest { public class SourceBindingWithGlobalPropertiesTest {
@Autowired @Autowired
private ChannelBindingServiceProperties channelBindingServiceProperties; private BindingServiceProperties serviceProperties;
@SuppressWarnings("unchecked")
@Test @Test
public void testGlobalPropertiesSet() { 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.getContentType()).isEqualTo("application/json");
Assertions.assertThat(bindingProperties.getDestination()).isEqualTo("ticktock"); Assertions.assertThat(bindingProperties.getDestination()).isEqualTo("ticktock");
Assertions.assertThat(bindingProperties.getProducer().getRequiredGroups()).containsExactly("someGroup"); Assertions.assertThat(bindingProperties.getProducer().getRequiredGroups()).containsExactly("someGroup");

View File

@@ -393,7 +393,7 @@ public class BindingServiceTests {
assertThat(bindableType).isSameAs(SomeBindableType.class); assertThat(bindableType).isSameAs(SomeBindableType.class);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
@Test @Test
public void testLateBindingConsumer() throws Exception { public void testLateBindingConsumer() throws Exception {
BindingServiceProperties properties = new BindingServiceProperties(); BindingServiceProperties properties = new BindingServiceProperties();
@@ -432,7 +432,7 @@ public class BindingServiceTests {
binderFactory.destroy(); binderFactory.destroy();
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
@Test @Test
public void testLateBindingProducer() throws Exception { public void testLateBindingProducer() throws Exception {
BindingServiceProperties properties = new BindingServiceProperties(); BindingServiceProperties properties = new BindingServiceProperties();

View File

@@ -57,7 +57,6 @@ public class CustomPartitionedProducerTest {
private Source testSource; private Source testSource;
@Test @Test
@SuppressWarnings("unchecked")
public void testCustomPartitionedProducer() { public void testCustomPartitionedProducer() {
DirectChannel messageChannel = (DirectChannel) this.testSource.output(); DirectChannel messageChannel = (DirectChannel) this.testSource.output();
for (ChannelInterceptor channelInterceptor : messageChannel.getChannelInterceptors()) { for (ChannelInterceptor channelInterceptor : messageChannel.getChannelInterceptors()) {

View File

@@ -40,7 +40,6 @@ import static org.hamcrest.Matchers.hasProperty;
/** /**
* @author Marius Bogoevici * @author Marius Bogoevici
*/ */
@SuppressWarnings("Duplicates")
public class BinderConfigurationParsingTests { public class BinderConfigurationParsingTests {
private static ClassLoader classLoader = BinderConfigurationParsingTests.class.getClassLoader(); private static ClassLoader classLoader = BinderConfigurationParsingTests.class.getClassLoader();
@@ -63,6 +62,7 @@ public class BinderConfigurationParsingTests {
hasProperty("configurationClasses", hasItemInArray(StubBinder1Configuration.class))))); hasProperty("configurationClasses", hasItemInArray(StubBinder1Configuration.class)))));
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testParseTwoBindersConfigurations() throws Exception { public void testParseTwoBindersConfigurations() throws Exception {
// this is just checking that resources are passed and classes are loaded properly // this is just checking that resources are passed and classes are loaded properly

View File

@@ -37,7 +37,7 @@ public class KryoMessageConverterTests {
public void convertStringType() throws Exception { public void convertStringType() throws Exception {
KryoMessageConverter kryoMessageConverter = new KryoMessageConverter(null,true); KryoMessageConverter kryoMessageConverter = new KryoMessageConverter(null,true);
Message<?> message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE,"application/x-java-object").build(); 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.assertNotNull(converted);
Assert.assertEquals("application/x-java-object;type=java.lang.String",converted.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString()); 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); Output output = new Output(baos);
kryo.writeObject(output,foo); kryo.writeObject(output,foo);
output.close(); 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); Object result = kryoMessageConverter.fromMessage(message,String.class);
Assert.assertEquals(foo,result); Assert.assertEquals(foo,result);
} }
@@ -65,7 +65,7 @@ public class KryoMessageConverterTests {
Output output = new Output(baos); Output output = new Output(baos);
kryo.writeObject(output,foo); kryo.writeObject(output,foo);
output.close(); output.close();
Message message = MessageBuilder.withPayload(baos.toByteArray()).build(); Message<?> message = MessageBuilder.withPayload(baos.toByteArray()).build();
Object result = kryoMessageConverter.fromMessage(message,String.class); Object result = kryoMessageConverter.fromMessage(message,String.class);
Assert.assertNull(result); Assert.assertNull(result);
} }
@@ -73,14 +73,14 @@ public class KryoMessageConverterTests {
@Test(expected = MessageConversionException.class) @Test(expected = MessageConversionException.class)
public void readWithWrongPayloadType() throws Exception{ public void readWithWrongPayloadType() throws Exception{
KryoMessageConverter kryoMessageConverter = new KryoMessageConverter(null,true); 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); kryoMessageConverter.fromMessage(message,String.class);
} }
@Test(expected = MessageConversionException.class) @Test(expected = MessageConversionException.class)
public void readWithWrongPayloadFormat() throws Exception{ public void readWithWrongPayloadFormat() throws Exception{
KryoMessageConverter kryoMessageConverter = new KryoMessageConverter(null,true); 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); kryoMessageConverter.fromMessage(message,String.class);
} }

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest; 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.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Sink; import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.cloud.stream.utils.MockBinderRegistryConfiguration; 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. * Verifies that interceptors used by modules are applied correctly to generated channels.
* *
* @author Marius Bogoevici * @author Marius Bogoevici
* @author Oleg Zhurakousky
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = BoundChannelsInterceptedTest.Foo.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(); public static final Message<?> TEST_MESSAGE = MessageBuilder.withPayload("bar").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build();
@Autowired @Autowired
@Bindings(BoundChannelsInterceptedTest.Foo.class) private Sink sink;
public Sink fooSink;
@Autowired @Autowired
ChannelInterceptor channelInterceptor; ChannelInterceptor channelInterceptor;
@Test @Test
public void testBoundChannelsIntercepted() { public void testBoundChannelsIntercepted() {
this.fooSink.input().send(TEST_MESSAGE); sink.input().send(TEST_MESSAGE);
verify(this.channelInterceptor).preSend(Mockito.any(), Mockito.eq(this.fooSink.input())); verify(this.channelInterceptor).preSend(Mockito.any(), Mockito.eq(this.sink.input()));
verifyNoMoreInteractions(this.channelInterceptor); verifyNoMoreInteractions(this.channelInterceptor);
} }

View File

@@ -25,7 +25,6 @@ import org.mockito.ArgumentMatcher;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; 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.annotation.EnableBinding;
import org.springframework.cloud.stream.binder.Binder; import org.springframework.cloud.stream.binder.Binder;
import org.springframework.cloud.stream.binder.BinderFactory; import org.springframework.cloud.stream.binder.BinderFactory;
@@ -57,11 +56,10 @@ public class PartitionedConsumerTest {
private BinderFactory binderFactory; private BinderFactory binderFactory;
@Autowired @Autowired
@Bindings(TestSink.class)
private Sink testSink; private Sink testSink;
@Test @Test
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("rawtypes")
public void testBindingPartitionedConsumer() { public void testBindingPartitionedConsumer() {
Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); Binder binder = this.binderFactory.getBinder(null, MessageChannel.class);
ArgumentCaptor<ConsumerProperties> argumentCaptor = ArgumentCaptor.forClass(ConsumerProperties.class); ArgumentCaptor<ConsumerProperties> argumentCaptor = ArgumentCaptor.forClass(ConsumerProperties.class);

View File

@@ -48,7 +48,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
@SpringBootTest(classes = PartitionedProducerTest.TestSource.class) @SpringBootTest(classes = PartitionedProducerTest.TestSource.class)
public class PartitionedProducerTest { public class PartitionedProducerTest {
@SuppressWarnings("rawtypes")
@Autowired @Autowired
private BinderFactory binderFactory; private BinderFactory binderFactory;
@@ -56,7 +55,7 @@ public class PartitionedProducerTest {
private Source testSource; private Source testSource;
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("rawtypes")
public void testBindingPartitionedProducer() { public void testBindingPartitionedProducer() {
Binder binder = this.binderFactory.getBinder(null, MessageChannel.class); Binder binder = this.binderFactory.getBinder(null, MessageChannel.class);
ArgumentCaptor<ProducerProperties> argumentCaptor = ArgumentCaptor.forClass(ProducerProperties.class); ArgumentCaptor<ProducerProperties> argumentCaptor = ArgumentCaptor.forClass(ProducerProperties.class);