Fix Global Embedded Kafka sample for current Spring Boot
* We don't need to worry about `spring.embedded.kafka.brokers` since Embedded Kafka populates `spring.kafka.bootstrap-servers` as well
This commit is contained in:
@@ -7,11 +7,13 @@ Additional properties for the underlying `GlobalEmbeddedKafkaTestExecutionListen
|
||||
|
||||
Run only `./mvnw test` command for this sample.
|
||||
The Maven will report to the output similar two log messages:
|
||||
```
|
||||
|
||||
[source,text]
|
||||
----
|
||||
11:03:44.383 [main] INFO o.s.k.t.j.GlobalEmbeddedKafkaTestExecutionListener - Started global Embedded Kafka on: 127.0.0.1:53671
|
||||
...
|
||||
11:03:48.439 [main] INFO o.s.k.t.j.GlobalEmbeddedKafkaTestExecutionListener - Stopped global Embedded Kafka.
|
||||
```
|
||||
----
|
||||
One in the beginning of the test plan - and another in the end before reporting failures.
|
||||
|
||||
The application by itself is going to fail because it has a configuration like `spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}`.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}
|
||||
spring.kafka.producer.properties[max.block.ms]=1000
|
||||
spring.kafka.consumer.auto-offset-reset=earliest
|
||||
logging.level.root=error
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
/**
|
||||
* This test is going to fail from IDE since there is no exposed {@code spring.embedded.kafka.brokers} system property.
|
||||
* This test is going to fail from IDE since there is no exposed {@code spring.kafka.bootstrap-servers} system property.
|
||||
* Use Maven to run tests which enables global embedded Kafka broker via properties provided to Surefire plugin.
|
||||
*/
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
/**
|
||||
* This test is going to fail from IDE since there is no exposed {@code spring.embedded.kafka.brokers} system property.
|
||||
* This test is going to fail from IDE since there is no exposed {@code spring.kafka.bootstrap-servers} system property.
|
||||
* This test demonstrates that global embedded Kafka broker config for {@code auto.create.topics.enable=false}
|
||||
* is in an effect - the topic {@code nonExistingTopic} does not exist on the broker.
|
||||
* See {@code /resources/kafka-broker.properties} and Maven Surefire plugin configuration.
|
||||
|
||||
Reference in New Issue
Block a user