Poprawki
This commit is contained in:
1 parent
b9f39bd708
commit
0ea913646a
3 files changed
+9
-6
No files matched your search
Binary file not shown.
@@ -14,7 +14,11 @@ public class Sender {
|
||||
private KafkaTemplate<String,String> kafkaTemplate;
|
||||
|
||||
public void send(String topic, String payload){
|
||||
log.info("sending payload='{}' to topic ='{}'",payload,topic);
|
||||
kafkaTemplate.send(topic,payload);
|
||||
int i=10;
|
||||
while(i>0) {
|
||||
log.info("sending payload='{}' to topic ='{}'", payload, topic);
|
||||
kafkaTemplate.send(topic, payload);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import kafka.server.KafkaServer;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -12,7 +11,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.kafka.test.context.EmbeddedKafka;
|
||||
import org.springframework.kafka.test.rule.KafkaEmbedded;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
@@ -21,6 +19,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@SpringBootTest
|
||||
@DirtiesContext
|
||||
public class SpringKafkaApplicationTest {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SpringKafkaApplicationTest.class);
|
||||
private static String BOOT_TOPIC = "boot.t";
|
||||
|
||||
@@ -31,8 +30,8 @@ public class SpringKafkaApplicationTest {
|
||||
private Consumer receiver;
|
||||
|
||||
@ClassRule
|
||||
public static KafkaEmbedded embeddedKafka =
|
||||
new KafkaEmbedded(1, true, BOOT_TOPIC);
|
||||
public static KafkaEmbedded embeddedKafka = new KafkaEmbedded(1, true, BOOT_TOPIC);
|
||||
|
||||
@Test
|
||||
public void testReceive() throws Exception {
|
||||
sender.send(BOOT_TOPIC, "Hello Boot!");
|
||||
|
||||
Reference in new issue
Block a user