Skip to content

Commit

Permalink
Fix Global Embedded Kafka sample for current Spring Boot
Browse files Browse the repository at this point in the history
* We don't need to worry about `spring.embedded.kafka.brokers` since Embedded Kafka
populates `spring.kafka.bootstrap-servers` as well
  • Loading branch information
artembilan committed Jan 29, 2024
1 parent 3cafe48 commit 8a684b3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions samples/sample-05/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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}`.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
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.
Expand Down

0 comments on commit 8a684b3

Please sign in to comment.