Skip to content

Commit 7bf7ded

Browse files
committed
KafkaTestUtils consumer properties API unification
Signed-off-by: mipo256 <[email protected]>
1 parent 85a2097 commit 7bf7ded

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

spring-kafka-test/src/main/java/org/springframework/kafka/test/utils/KafkaTestUtils.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
* @author Hugo Wood
6060
* @author Artem Bilan
6161
* @author Sanghyeok An
62+
* @author Mikhail Polivakha
6263
*/
6364
public final class KafkaTestUtils {
6465

@@ -81,13 +82,30 @@ private KafkaTestUtils() {
8182
* @param autoCommit the auto commit.
8283
* @param embeddedKafka a {@link EmbeddedKafkaBroker} instance.
8384
* @return the properties.
85+
* @deprecated please, use {@link #consumerProps(EmbeddedKafkaBroker, String, boolean)} instead
8486
*/
87+
@Deprecated(forRemoval = true, since = "4.0.0")
8588
public static Map<String, Object> consumerProps(String group, String autoCommit,
8689
EmbeddedKafkaBroker embeddedKafka) {
8790

8891
return consumerProps(embeddedKafka.getBrokersAsString(), group, autoCommit);
8992
}
9093

94+
/**
95+
* Set up test properties for an {@code <Integer, String>} consumer.
96+
*
97+
* @param group the group id.
98+
* @param autoCommit the auto commit.
99+
* @param embeddedKafka a {@link EmbeddedKafkaBroker} instance.
100+
* @since 4.0
101+
* @return the properties.
102+
*/
103+
public static Map<String, Object> consumerProps(EmbeddedKafkaBroker embeddedKafka, String group,
104+
boolean autoCommit) {
105+
106+
return consumerProps(embeddedKafka.getBrokersAsString(), group, autoCommit);
107+
}
108+
91109
/**
92110
* Set up test properties for an {@code <Integer, String>} consumer.
93111
* @param brokers the bootstrapServers property.
@@ -114,8 +132,22 @@ public static Map<String, Object> producerProps(EmbeddedKafkaBroker embeddedKafk
114132
* @param group the group id.
115133
* @param autoCommit the auto commit.
116134
* @return the properties.
117-
*/
135+
* @deprecated Please, use {@link #consumerProps(String, String, boolean)} instead.
136+
*/
137+
@Deprecated(forRemoval = true, since = "4.0.0")
118138
public static Map<String, Object> consumerProps(String brokers, String group, String autoCommit) {
139+
return consumerProps(brokers, group, Boolean.parseBoolean(autoCommit));
140+
}
141+
142+
/**
143+
* Set up test properties for an {@code <Integer, String>} consumer.
144+
* @param brokers the bootstrapServers property.
145+
* @param group the group id.
146+
* @param autoCommit the auto commit.
147+
* @since 4.0
148+
* @return the properties.
149+
*/
150+
public static Map<String, Object> consumerProps(String brokers, String group, boolean autoCommit) {
119151
Map<String, Object> props = new HashMap<>();
120152
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, brokers);
121153
props.put(ConsumerConfig.GROUP_ID_CONFIG, group);

0 commit comments

Comments
 (0)