Simplify configuration of TestBinder

This commit is contained in:
Oleg Zhurakousky
2019-10-03 14:04:51 -04:00
parent 1fb479ff6d
commit a84cd07dfc
2 changed files with 13 additions and 5 deletions

View File

@@ -171,9 +171,19 @@ public class BinderFactoryAutoConfiguration {
// the above can never be null since it will default to
// ClassUtils.getDefaultClassLoader(..)
try {
Enumeration<URL> resources = classLoader
.getResources("META-INF/spring.binders");
if (!Boolean.valueOf(this.selfContained)
Enumeration<URL> 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."

View File

@@ -1,4 +1,2 @@
integration:\
org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration
mock:\
org.springframework.cloud.stream.utils.MockBinderConfiguration