From a84cd07dfc0e7475ac5f5d9174efbf97cdefc6ed Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Thu, 3 Oct 2019 14:04:51 -0400 Subject: [PATCH] Simplify configuration of TestBinder --- .../config/BinderFactoryAutoConfiguration.java | 16 +++++++++++++--- .../src/test/resources/META-INF/spring.binders | 2 -- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BinderFactoryAutoConfiguration.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BinderFactoryAutoConfiguration.java index 8e4ea78a4..cf890e15e 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BinderFactoryAutoConfiguration.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BinderFactoryAutoConfiguration.java @@ -171,9 +171,19 @@ public class BinderFactoryAutoConfiguration { // the above can never be null since it will default to // ClassUtils.getDefaultClassLoader(..) try { - Enumeration resources = classLoader - .getResources("META-INF/spring.binders"); - if (!Boolean.valueOf(this.selfContained) + Enumeration resources = classLoader.getResources("META-INF/spring.binders"); + + // see if test binder is available on the classpath and if so add it t o the binderTypes + try { + BinderType bt = new BinderType("integration", new Class[] { + classLoader.loadClass("org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration")}); + binderTypes.put("integration", bt); + } + catch (Exception e) { + // ignore. means test binder is not available + } + + if (binderTypes.isEmpty() && !Boolean.valueOf(this.selfContained) && (resources == null || !resources.hasMoreElements())) { this.logger.debug( "Failed to locate 'META-INF/spring.binders' resources on the classpath." diff --git a/spring-cloud-stream/src/test/resources/META-INF/spring.binders b/spring-cloud-stream/src/test/resources/META-INF/spring.binders index 84dc342e2..b6e4a6729 100644 --- a/spring-cloud-stream/src/test/resources/META-INF/spring.binders +++ b/spring-cloud-stream/src/test/resources/META-INF/spring.binders @@ -1,4 +1,2 @@ -integration:\ -org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration mock:\ org.springframework.cloud.stream.utils.MockBinderConfiguration