1
|
-package com.yoho.ops.kafka;
|
|
|
2
|
-
|
|
|
3
|
-import static org.assertj.core.api.Assertions.assertThat;
|
|
|
4
|
-
|
|
|
5
|
-import java.util.concurrent.TimeUnit;
|
|
|
6
|
-
|
|
|
7
|
-import org.junit.Test;
|
|
|
8
|
-import org.junit.runner.RunWith;
|
|
|
9
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
10
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
11
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
12
|
-
|
|
|
13
|
-@RunWith(SpringRunner.class)
|
|
|
14
|
-@SpringBootTest
|
|
|
15
|
-public class SpringKafkaApplicationTests {
|
|
|
16
|
-
|
|
|
17
|
- @Autowired
|
|
|
18
|
- private Sender sender;
|
|
|
19
|
-
|
|
|
20
|
- @Autowired
|
|
|
21
|
- private Receiver receiver;
|
|
|
22
|
-
|
|
|
23
|
- @Test
|
|
|
24
|
- public void testReceive() throws Exception {
|
|
|
25
|
- sender.send("helloworld.t", "Hello Spring Kafka!");
|
|
|
26
|
-
|
|
|
27
|
- Thread.sleep(100000);
|
|
|
28
|
- }
|
|
|
29
|
-} |
|
|