use of org.springframework.cloud.stream.config.BinderFactoryConfiguration in project spring-cloud-stream by spring-cloud.
the class BindingServiceTests method testUnrecognizedBinderAllowedIfNotUsed.
@Test
public void testUnrecognizedBinderAllowedIfNotUsed() {
HashMap<String, String> properties = new HashMap<>();
properties.put("spring.cloud.stream.bindings.input.destination", "fooInput");
properties.put("spring.cloud.stream.bindings.output.destination", "fooOutput");
properties.put("spring.cloud.stream.defaultBinder", "mock1");
properties.put("spring.cloud.stream.binders.mock1.type", "mock");
properties.put("spring.cloud.stream.binders.kafka1.type", "kafka");
BindingServiceProperties bindingServiceProperties = createBindingServiceProperties(properties);
DefaultBinderFactory binderFactory = new BinderFactoryConfiguration().binderFactory(createMockBinderTypeRegistry(), bindingServiceProperties);
BindingService bindingService = new BindingService(bindingServiceProperties, binderFactory);
bindingService.bindConsumer(new DirectChannel(), "input");
bindingService.bindProducer(new DirectChannel(), "output");
}
use of org.springframework.cloud.stream.config.BinderFactoryConfiguration in project spring-cloud-stream by spring-cloud.
the class BindingServiceTests method testUnrecognizedBinderDisallowedIfUsed.
@Test
public void testUnrecognizedBinderDisallowedIfUsed() {
HashMap<String, String> properties = new HashMap<>();
properties.put("spring.cloud.stream.bindings.input.destination", "fooInput");
properties.put("spring.cloud.stream.bindings.input.binder", "mock1");
properties.put("spring.cloud.stream.bindings.output.destination", "fooOutput");
properties.put("spring.cloud.stream.bindings.output.type", "kafka1");
properties.put("spring.cloud.stream.binders.mock1.type", "mock");
properties.put("spring.cloud.stream.binders.kafka1.type", "kafka");
BindingServiceProperties bindingServiceProperties = createBindingServiceProperties(properties);
DefaultBinderFactory binderFactory = new BinderFactoryConfiguration().binderFactory(createMockBinderTypeRegistry(), bindingServiceProperties);
BindingService bindingService = new BindingService(bindingServiceProperties, binderFactory);
bindingService.bindConsumer(new DirectChannel(), "input");
try {
bindingService.bindProducer(new DirectChannel(), "output");
fail("Expected 'Unknown binder configuration'");
} catch (IllegalArgumentException e) {
assertThat(e).hasMessageContaining("Binder type kafka is not defined");
}
}
Aggregations