1 package de.example.spring.kafka;
3 import static org.hamcrest.CoreMatchers.is;
4 import static org.junit.Assert.assertThat;
6 import javax.inject.Inject;
9 import org.junit.runner.RunWith;
10 import org.springframework.boot.test.context.SpringBootTest;
11 import org.springframework.cloud.stream.messaging.Source;
12 import org.springframework.cloud.stream.test.binder.MessageCollector;
13 import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
14 import org.springframework.messaging.Message;
15 import org.springframework.test.annotation.DirtiesContext;
16 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
18 @RunWith(SpringJUnit4ClassRunner.class)
19 @SpringBootTest(classes = { Sender.class, TestSupportBinderAutoConfiguration.class })
21 public class SenderIntegrationTest {
30 private MessageCollector messageCollector;
33 public void sendSomeProduct() {
34 Product product = new Product("hello", "this is some description");
36 sender.sendMessage("hello");
38 Message<Product> received = (Message<Product>) messageCollector.forChannel(source.output()).poll();
40 assertThat(received.getPayload().getDescription(), is(product.getDescription()));