Skip to content

Commit 1797755

Browse files
committed
KafkaTestUtils consumer properties API unification
1 parent 168aca9 commit 1797755

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,28 @@ private KafkaTestUtils() {
8181
* @param autoCommit the auto commit.
8282
* @param embeddedKafka a {@link EmbeddedKafkaBroker} instance.
8383
* @return the properties.
84+
* @deprecated please, use {@link #consumerProps(EmbeddedKafkaBroker, String, boolean)} instead
8485
*/
86+
@Deprecated(forRemoval = true, since = "4.0.0")
8587
public static Map<String, Object> consumerProps(String group, String autoCommit,
8688
EmbeddedKafkaBroker embeddedKafka) {
8789

8890
return consumerProps(embeddedKafka.getBrokersAsString(), group, autoCommit);
8991
}
9092

93+
/**
94+
* Set up test properties for an {@code <Integer, String>} consumer.
95+
* @param group the group id.
96+
* @param autoCommit the auto commit.
97+
* @param embeddedKafka a {@link EmbeddedKafkaBroker} instance.
98+
* @return the properties.
99+
*/
100+
public static Map<String, Object> consumerProps(EmbeddedKafkaBroker embeddedKafka, String group,
101+
boolean autoCommit) {
102+
103+
return consumerProps(embeddedKafka.getBrokersAsString(), group, autoCommit);
104+
}
105+
91106
/**
92107
* Set up test properties for an {@code <Integer, String>} consumer.
93108
* @param brokers the bootstrapServers property.
@@ -114,8 +129,21 @@ public static Map<String, Object> producerProps(EmbeddedKafkaBroker embeddedKafk
114129
* @param group the group id.
115130
* @param autoCommit the auto commit.
116131
* @return the properties.
117-
*/
132+
* @deprecated Please, use {@link #consumerProps(String, String, boolean)} instead.
133+
*/
134+
@Deprecated(forRemoval = true, since = "4.0.0")
118135
public static Map<String, Object> consumerProps(String brokers, String group, String autoCommit) {
136+
return consumerProps(brokers, group, Boolean.parseBoolean(autoCommit));
137+
}
138+
139+
/**
140+
* Set up test properties for an {@code <Integer, String>} consumer.
141+
* @param brokers the bootstrapServers property.
142+
* @param group the group id.
143+
* @param autoCommit the auto commit.
144+
* @return the properties.
145+
*/
146+
public static Map<String, Object> consumerProps(String brokers, String group, boolean autoCommit) {
119147
Map<String, Object> props = new HashMap<>();
120148
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, brokers);
121149
props.put(ConsumerConfig.GROUP_ID_CONFIG, group);

0 commit comments

Comments
 (0)