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/antora/modules/ROOT/pages/testing.adoc
+23-45Lines changed: 23 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -56,8 +56,11 @@ If this is not possible for some reason, note that the `consumeFromEmbeddedTopic
56
56
Since it does not have access to the consumer properties, you must use the overloaded method that takes a `seekToEnd` boolean parameter to seek to the end instead of the beginning.
57
57
====
58
58
59
-
NOTE: The `EmbeddedKafkaRule` JUnit 4 rule has been removed in version 4.0.
60
-
For JUnit 4, you should use the `EmbeddedKafkaKraftBroker` directly or migrate to JUnit 5 with the `@EmbeddedKafka` annotation.
59
+
[NOTE]
60
+
====
61
+
Spring for Apache Kafka no longer supports JUnit 4.
62
+
Migration to JUnit Jupiter is recommended.
63
+
====
61
64
62
65
The `EmbeddedKafkaBroker` class has a utility method that lets you consume for all the topics it created.
63
66
The following example shows how to use it:
@@ -121,15 +124,19 @@ The following example configuration creates topics called `cat` and `hat` with f
.addTopics(new NewTopic("thing1", 10, (short) 1), new NewTopic("thing2", 15, (short) 1));
139
+
broker.addTopics(new NewTopic("thing1", 10, (short) 1), new NewTopic("thing2", 15, (short) 1));
133
140
...
134
141
}
135
142
@@ -206,7 +213,7 @@ In addition, these properties can be provided:
206
213
207
214
Essentially these properties mimic some of the `@EmbeddedKafka` attributes.
208
215
209
-
See more information about configuration properties and how to provide them in the https://junit.org/junit5/docs/current/user-guide/#running-tests-config-params[JUnit 5 User Guide].
216
+
See more information about configuration properties and how to provide them in the https://junit.org/junit5/docs/current/user-guide/#running-tests-config-params[JUnit Jupiter User Guide].
210
217
For example, a `spring.embedded.kafka.brokers.property=my.bootstrap-servers` entry can be added into a `junit-platform.properties` file in the testing classpath.
211
218
Starting with version 3.0.10, the broker automatically sets this to `spring.kafka.bootstrap-servers`, by default, for testing with Spring Boot applications.
212
219
@@ -225,7 +232,7 @@ The following example shows how to use it:
225
232
226
233
[source, java]
227
234
----
228
-
@RunWith(SpringRunner.class)
235
+
@SpringJUnitConfig
229
236
@DirtiesContext
230
237
@EmbeddedKafka(partitions = 1,
231
238
topics = {
@@ -237,7 +244,7 @@ public class KafkaStreamsTests {
0 commit comments