From 087771762b46c82033953fd19d2aa935145bfd13 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Fri, 14 Jan 2022 17:12:57 -0500 Subject: [PATCH] Restore RetryTemplateTests. --- .../stream/config}/RetryTemplateTests.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) rename spring-cloud-stream/{deleted-tests => src/test/java/org/springframework/cloud/stream/config}/RetryTemplateTests.java (90%) diff --git a/spring-cloud-stream/deleted-tests/RetryTemplateTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/RetryTemplateTests.java similarity index 90% rename from spring-cloud-stream/deleted-tests/RetryTemplateTests.java rename to spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/RetryTemplateTests.java index 0cba76f24..faea2f40b 100644 --- a/spring-cloud-stream/deleted-tests/RetryTemplateTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/RetryTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2022 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. @@ -19,18 +19,17 @@ package org.springframework.cloud.stream.config; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Map; +import java.util.function.Function; import org.junit.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.annotation.StreamRetryTemplate; import org.springframework.cloud.stream.binder.AbstractBinder; import org.springframework.cloud.stream.binder.ConsumerProperties; import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; -import org.springframework.cloud.stream.messaging.Processor; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; @@ -40,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Oleg Zhurakousky - * + * @author Soby Chacko */ public class RetryTemplateTests { @@ -65,14 +64,14 @@ public class RetryTemplateTests { ApplicationContext context = new SpringApplicationBuilder( SpecificCustomRetryTemplateConfiguration.class) .web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", - "--spring.cloud.stream.bindings.input.consumer.retry-template-name=retryTemplateTwo"); + "--spring.cloud.stream.bindings.processor-in-0.consumer.retry-template-name=retryTemplateTwo"); RetryTemplate retryTemplateTwo = context.getBean("retryTemplateTwo", RetryTemplate.class); BindingServiceProperties bindingServiceProperties = context .getBean(BindingServiceProperties.class); ConsumerProperties consumerProperties = bindingServiceProperties - .getConsumerProperties("input"); + .getConsumerProperties("processor-in-0"); AbstractBinder binder = context.getBean(AbstractBinder.class); Method m = AbstractBinder.class.getDeclaredMethod("buildRetryTemplate", @@ -83,7 +82,6 @@ public class RetryTemplateTests { assertThat(retryTemplate).isEqualTo(retryTemplateTwo); } - @EnableBinding(Processor.class) @Import(TestChannelBinderConfiguration.class) @EnableAutoConfiguration public static class SpecificCustomRetryTemplateConfiguration { @@ -103,9 +101,12 @@ public class RetryTemplateTests { return new RetryTemplate(); } + @Bean + public Function processor() { + return s -> s; + } } - @EnableBinding(Processor.class) @Import(TestChannelBinderConfiguration.class) @EnableAutoConfiguration public static class SingleCustomRetryTemplateConfiguration { @@ -120,6 +121,9 @@ public class RetryTemplateTests { return new RetryTemplate(); } + @Bean + public Function processor() { + return s -> s; + } } - }