Search in sources :

Example 11 with DefaultBinderFactory

use of org.springframework.cloud.stream.binder.DefaultBinderFactory 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");
    }
}
Also used : HashMap(java.util.HashMap) DirectChannel(org.springframework.integration.channel.DirectChannel) BinderFactoryConfiguration(org.springframework.cloud.stream.config.BinderFactoryConfiguration) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BindingServiceProperties(org.springframework.cloud.stream.config.BindingServiceProperties) DefaultBinderFactory(org.springframework.cloud.stream.binder.DefaultBinderFactory) Test(org.junit.Test)

Aggregations

DefaultBinderFactory (org.springframework.cloud.stream.binder.DefaultBinderFactory)11 Test (org.junit.Test)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 BindingServiceProperties (org.springframework.cloud.stream.config.BindingServiceProperties)10 DirectChannel (org.springframework.integration.channel.DirectChannel)10 HashMap (java.util.HashMap)9 BindingProperties (org.springframework.cloud.stream.config.BindingProperties)8 MessageChannel (org.springframework.messaging.MessageChannel)8 ConsumerProperties (org.springframework.cloud.stream.binder.ConsumerProperties)6 ExtendedPropertiesBinder (org.springframework.cloud.stream.binder.ExtendedPropertiesBinder)6 Binder (org.springframework.cloud.stream.binder.Binder)5 Binding (org.springframework.cloud.stream.binder.Binding)5 ExtendedProducerProperties (org.springframework.cloud.stream.binder.ExtendedProducerProperties)3 ProducerProperties (org.springframework.cloud.stream.binder.ProducerProperties)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 BinderFactoryConfiguration (org.springframework.cloud.stream.config.BinderFactoryConfiguration)2 ThreadPoolTaskScheduler (org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)2 Properties (java.util.Properties)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1