You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/asciidoc/testing.adoc
+17-12
Original file line number
Diff line number
Diff line change
@@ -151,7 +151,7 @@ public class MyTests {
151
151
By default, `addTopics` will throw an exception when problems arise (such as adding a topic that already exists).
152
152
Version 2.6 added a new version of that method that returns a `Map<String, Exception>`; the key is the topic name and the value is `null` for success, or an `Exception` for a failure.
153
153
154
-
==== Using the Same Brokers for Multiple Test Classes
154
+
==== Using the Same Broker(s) for Multiple Test Classes
155
155
156
156
There is no built-in support for doing so, but you can use the same broker for multiple test classes with something similar to the following:
157
157
@@ -160,17 +160,18 @@ There is no built-in support for doing so, but you can use the same broker for m
160
160
----
161
161
public final class EmbeddedKafkaHolder {
162
162
163
-
private static EmbeddedKafkaRule embeddedKafka = new EmbeddedKafkaRule(1, false);
163
+
private static EmbeddedKafkaBroker embeddedKafka = new EmbeddedKafkaBroker(1, false)
private static final EmbeddedKafkaBroker broker = EmbeddedKafkaHolder.getEmbeddedKafka();
198
201
----
199
202
====
200
203
201
-
IMPORTANT: The preceding example provides no mechanism for shutting down the brokers when all tests are complete.
204
+
If you are not using Spring Boot, you can obtain the bootstrap servers using `broker.getBrokersAsString()`.
205
+
206
+
IMPORTANT: The preceding example provides no mechanism for shutting down the broker(s) when all tests are complete.
202
207
This could be a problem if, say, you run your tests in a Gradle daemon.
203
208
You should not use this technique in such a situation, or you should use something to call `destroy()` on the `EmbeddedKafkaBroker` when your tests are complete.
204
209
@@ -293,11 +298,11 @@ When *not* using the spring test context, the `EmbdeddedKafkaCondition` creates
0 commit comments