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:
@@ -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<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++) {
|
||||
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<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) {
|
||||
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<SourceConfigurer> {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<String, Object> sharedBindingTargets = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(String id, Class<T> bindingTargetType) {
|
||||
Object sharedBindingTarget = this.sharedBindingTargets.get(id);
|
||||
if (sharedBindingTarget == null) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -82,6 +82,9 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
|
||||
this.provisioningProvider = provisioningProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated As of release 2.0. Please use other constructors.
|
||||
*/
|
||||
@Deprecated
|
||||
protected AbstractMessageChannelBinder(boolean supportsHeadersNatively, String[] headersToEmbed,
|
||||
PP provisioningProvider) {
|
||||
@@ -95,7 +98,7 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
|
||||
* for handling the middleware specific logic. If the returned producer message
|
||||
* handler is an {@link InitializingBean} then
|
||||
* {@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.
|
||||
*
|
||||
* @param destination the name of the destination
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.boot.Banner.Mode;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.stream.reflection.GenericsUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Default {@link BinderFactory} implementation.
|
||||
*
|
||||
@@ -160,6 +162,7 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl
|
||||
return binderInstance;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> Binder<T, ?, ?> 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<T, ?, ?> binder = binderProducingContext.getBean(Binder.class);
|
||||
if (this.listeners != null) {
|
||||
for (Listener binderFactoryListener : listeners) {
|
||||
|
||||
@@ -109,8 +109,4 @@ public class PartitionHandler {
|
||||
return this.partitionKeyExtractorStrategy.extractKey(message);
|
||||
}
|
||||
|
||||
private int invokePartitionSelector(Object key) {
|
||||
return this.partitionSelectorStrategy.selectPartition(key, producerProperties.getPartitionCount());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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<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);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class DynamicDestinationsBindable extends BindableAdapter {
|
||||
|
||||
@Override
|
||||
public void unbindOutputs(BindingService adapter) {
|
||||
for (Map.Entry<String, Binding> entry : outputBindings.entrySet()) {
|
||||
for (Map.Entry<String, Binding<?>> entry : outputBindings.entrySet()) {
|
||||
entry.getValue().unbind();
|
||||
}
|
||||
outputBindings.clear();
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -83,7 +83,7 @@ public class EnvironmentEntryInitializingTreeMap<T> extends AbstractMap<String,
|
||||
@Override
|
||||
public T get(Object key) {
|
||||
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.bind(defaultsPrefix, Bindable.ofInstance(entry));
|
||||
this.delegate.put((String) key, entry);
|
||||
|
||||
@@ -97,16 +97,13 @@ public class AggregationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testModuleAggregationUsingSharedChannelRegistry() {
|
||||
// test backward compatibility
|
||||
aggregatedApplicationContext = new AggregateApplicationBuilder(
|
||||
MockBinderRegistryConfiguration.class, "--server.port=0")
|
||||
.from(TestSource.class).to(TestProcessor.class).run();
|
||||
org.springframework.cloud.stream.aggregate.SharedChannelRegistry sharedChannelRegistry =
|
||||
aggregatedApplicationContext.getBean(org.springframework.cloud.stream.aggregate.SharedChannelRegistry.class);
|
||||
BindingTargetFactory channelFactory = aggregatedApplicationContext
|
||||
.getBean(BindingTargetFactory.class);
|
||||
SharedBindingTargetRegistry sharedChannelRegistry = aggregatedApplicationContext.getBean(SharedBindingTargetRegistry.class);
|
||||
BindingTargetFactory channelFactory = aggregatedApplicationContext.getBean(BindingTargetFactory.class);
|
||||
assertThat(channelFactory).isNotNull();
|
||||
assertThat(sharedChannelRegistry.getAll().keySet()).hasSize(2);
|
||||
aggregatedApplicationContext.close();
|
||||
@@ -346,22 +343,17 @@ public class AggregationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testNamespaces() {
|
||||
aggregatedApplicationContext = new AggregateApplicationBuilder(
|
||||
MockBinderRegistryConfiguration.class, "--server.port=0")
|
||||
.from(TestSource.class).namespace("foo").to(TestProcessor.class)
|
||||
.namespace("bar").run();
|
||||
org.springframework.cloud.stream.aggregate.SharedChannelRegistry sharedChannelRegistry =
|
||||
aggregatedApplicationContext.getBean(org.springframework.cloud.stream.aggregate.SharedChannelRegistry.class);
|
||||
BindingTargetFactory channelFactory = aggregatedApplicationContext
|
||||
.getBean(BindingTargetFactory.class);
|
||||
Object fooOutput = sharedChannelRegistry.get("foo.output");
|
||||
SharedBindingTargetRegistry sharedChannelRegistry = aggregatedApplicationContext.getBean(SharedBindingTargetRegistry.class);
|
||||
BindingTargetFactory channelFactory = aggregatedApplicationContext.getBean(BindingTargetFactory.class);
|
||||
MessageChannel fooOutput = sharedChannelRegistry.get("foo.output", MessageChannel.class);
|
||||
assertThat(fooOutput).isNotNull();
|
||||
assertThat(fooOutput).isInstanceOf(MessageChannel.class);
|
||||
Object barInput = sharedChannelRegistry.get("bar.input");
|
||||
Object barInput = sharedChannelRegistry.get("bar.input", MessageChannel.class);
|
||||
assertThat(barInput).isNotNull();
|
||||
assertThat(barInput).isInstanceOf(MessageChannel.class);
|
||||
assertThat(channelFactory).isNotNull();
|
||||
assertThat(sharedChannelRegistry.getAll().keySet()).hasSize(2);
|
||||
aggregatedApplicationContext.close();
|
||||
|
||||
@@ -74,7 +74,6 @@ public class AbstractMessageChannelBinderTests {
|
||||
ErrorInfrastructure errorInfra = binder.errorInfrastructure;
|
||||
SubscribableChannel errorChannel = errorInfra.getErrorChannel();
|
||||
assertThat(errorChannel).isNotNull();
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<MessageHandler> handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class);
|
||||
assertThat(handlers.size()).isEqualTo(2);
|
||||
Iterator<MessageHandler> iterator = handlers.iterator();
|
||||
@@ -125,7 +124,6 @@ public class AbstractMessageChannelBinderTests {
|
||||
ErrorInfrastructure errorInfra = binder.errorInfrastructure;
|
||||
SubscribableChannel errorChannel = errorInfra.getErrorChannel();
|
||||
assertThat(errorChannel).isNotNull();
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<MessageHandler> handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class);
|
||||
assertThat(handlers.size()).isEqualTo(2);
|
||||
Iterator<MessageHandler> 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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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.<ProducerProperties>any());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -44,7 +44,6 @@ public class SourceBindingWithGlobalPropertiesOnlyTest {
|
||||
@Autowired
|
||||
private BindingServiceProperties bindingServiceProperties;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testGlobalPropertiesSet() {
|
||||
BindingProperties bindingProperties = bindingServiceProperties.getBindingProperties(Source.OUTPUT);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ConsumerProperties> argumentCaptor = ArgumentCaptor.forClass(ConsumerProperties.class);
|
||||
|
||||
@@ -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<ProducerProperties> argumentCaptor = ArgumentCaptor.forClass(ProducerProperties.class);
|
||||
|
||||
Reference in New Issue
Block a user