Initial implementation of multibinder support
- Addresses #138,#172,#173 with support for multiple binders in an application - Binders can be of multiple types (e.g. Rabbit or Kafka), as well as multiple binders of the same type connecting to different system (e.g. multiple Rabbit binders connecting to different Rabbit clusters) - Binders are now created in a separate context, allowing for multiple configurations - Adds the `spring.cloud.spring.binders` namespace that allows for creating configuration properties for multiple binders - Add support for default binder, modify Kafka tests to use multiple brokers when running embedded
This commit is contained in:
committed by
Mark Fisher
parent
ac395f84e5
commit
96f96f7621
@@ -1,2 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration:\
|
||||
test:\
|
||||
org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.stream.test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -26,12 +26,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.annotation.Bindings;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.binder.BinderFactory;
|
||||
import org.springframework.cloud.stream.messaging.Processor;
|
||||
import org.springframework.cloud.stream.test.binder.MessageCollector;
|
||||
import org.springframework.cloud.stream.test.binder.TestSupportBinder;
|
||||
import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -51,14 +53,14 @@ public class ExampleTest {
|
||||
private Processor processor;
|
||||
|
||||
@Autowired
|
||||
private MessageCollector messageCollector;
|
||||
private BinderFactory<MessageChannel> binderFactory;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testWiring() {
|
||||
Message<String> message = new GenericMessage<>("hello");
|
||||
processor.input().send(message);
|
||||
Message<String> received = (Message<String>) messageCollector.forChannel(processor.output()).poll();
|
||||
Message<String> received = (Message<String>) ((TestSupportBinder) binderFactory.getBinder(null)).messageCollector().forChannel(processor.output()).poll();
|
||||
assertThat(received.getPayload(), equalTo("hello world"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user