From 6d7c810e086acb21d73ed7502fc5f2b568a5bf95 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 26 Jan 2018 14:22:09 -0500 Subject: [PATCH] Make AC access from the `createBindableChannel()` To let test to interact with conventional beans override `createBindableChannel()` in the `KinesisBinderTests` to obtain `MessageConverterConfigurer` from the provided `ApplicationContext` --- .../binder/kinesis/KinesisBinderTests.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/spring-cloud-stream-binder-kinesis/src/test/java/org/springframework/cloud/stream/binder/kinesis/KinesisBinderTests.java b/spring-cloud-stream-binder-kinesis/src/test/java/org/springframework/cloud/stream/binder/kinesis/KinesisBinderTests.java index 2d19bb9..20272e2 100644 --- a/spring-cloud-stream-binder-kinesis/src/test/java/org/springframework/cloud/stream/binder/kinesis/KinesisBinderTests.java +++ b/spring-cloud-stream-binder-kinesis/src/test/java/org/springframework/cloud/stream/binder/kinesis/KinesisBinderTests.java @@ -55,6 +55,7 @@ import org.springframework.cloud.stream.binder.TestUtils; import org.springframework.cloud.stream.binder.kinesis.properties.KinesisBinderConfigurationProperties; import org.springframework.cloud.stream.binder.kinesis.properties.KinesisConsumerProperties; import org.springframework.cloud.stream.binder.kinesis.properties.KinesisProducerProperties; +import org.springframework.cloud.stream.binding.MessageConverterConfigurer; import org.springframework.cloud.stream.config.BindingProperties; import org.springframework.context.ApplicationContext; import org.springframework.expression.common.LiteralExpression; @@ -203,7 +204,6 @@ public class KinesisBinderTests @Test @Override - @SuppressWarnings("deprecation") public void testPartitionedModuleJava() throws Exception { KinesisTestBinder binder = getBinder(); @@ -245,9 +245,8 @@ public class KinesisBinderTests ExtendedProducerProperties producerProperties = createProducerProperties(); - // TODO must be fixed via application context - producerProperties.setPartitionKeyExtractorClass(PartitionTestSupport.class); - producerProperties.setPartitionSelectorClass(PartitionTestSupport.class); + producerProperties.setPartitionKeyExtractorName("partitionSupport"); + producerProperties.setPartitionSelectorName("partitionSupport"); producerProperties.setPartitionCount(3); DirectChannel output = createBindableChannel("test.output", @@ -526,6 +525,24 @@ public class KinesisBinderTests return producerProperties; } + protected DirectChannel createBindableChannel(String channelName, + BindingProperties bindingProperties, boolean inputChannel) { + + MessageConverterConfigurer messageConverterConfigurer = getBinder() + .getApplicationContext() + .getBean(MessageConverterConfigurer.class); + + DirectChannel channel = new DirectChannel(); + channel.setBeanName(channelName); + if (inputChannel) { + messageConverterConfigurer.configureInputChannel(channel, channelName); + } + else { + messageConverterConfigurer.configureOutputChannel(channel, channelName); + } + return channel; + } + @Override public Spy spyOn(String name) { throw new UnsupportedOperationException("'spyOn' is not used by Kinesis tests");