broker is not started
This commit is contained in:
1 parent
a03cee513a
commit
3d45446ebd
4 files changed
+90
-2
No files matched your search
@@ -0,0 +1,37 @@
|
||||
package edu.my.example.kafka;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.kafka.test.rule.KafkaEmbedded;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SpringKafkaApplicationTest {
|
||||
|
||||
private static String BOOT_TOPIC = "boot.t";
|
||||
|
||||
@Autowired
|
||||
private Sender sender;
|
||||
|
||||
@Autowired
|
||||
private Consumer receiver;
|
||||
|
||||
@ClassRule
|
||||
public static KafkaEmbedded embeddedKafka = new KafkaEmbedded(1, true, BOOT_TOPIC);
|
||||
|
||||
@Test
|
||||
public void testReceive() throws Exception {
|
||||
sender.send(BOOT_TOPIC, "Hello Boot!");
|
||||
|
||||
receiver.getLatch().await(10000, TimeUnit.MILLISECONDS);
|
||||
assertThat(receiver.getLatch().getCount()).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user