Skip to content

Commit a52f2fe

Browse files
committed
GH-1563: Fix JUnit5 @EmbeddedKafka.partitions()
Resolves #1563 Paritions property ignored in the JUnit5 condition.
1 parent 4262dbe commit a52f2fe

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

spring-kafka-test/src/main/java/org/springframework/kafka/test/condition/EmbeddedKafkaCondition.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ private boolean springTestContext(AnnotatedElement annotatedElement) {
117117
private EmbeddedKafkaBroker createBroker(EmbeddedKafka embedded) {
118118
EmbeddedKafkaBroker broker;
119119
int[] ports = setupPorts(embedded);
120-
broker = new EmbeddedKafkaBroker(embedded.count(), embedded.controlledShutdown(), embedded.topics())
120+
broker = new EmbeddedKafkaBroker(embedded.count(), embedded.controlledShutdown(),
121+
embedded.partitions(), embedded.topics())
121122
.zkPort(embedded.zookeeperPort())
122123
.kafkaPorts(ports)
123124
.zkConnectionTimeout(embedded.zkConnectionTimeout())

spring-kafka-test/src/test/java/org/springframework/kafka/test/condition/EmbeddedKafkaConditionTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
* @since 2.3
3030
*
3131
*/
32-
@EmbeddedKafka(bootstrapServersProperty = "my.bss.property", count = 2)
32+
@EmbeddedKafka(bootstrapServersProperty = "my.bss.property", count = 2, controlledShutdown = true, partitions = 3)
3333
public class EmbeddedKafkaConditionTests {
3434

3535
@Test
3636
public void test(EmbeddedKafkaBroker broker) {
3737
assertThat(broker.getBrokersAsString()).isNotNull();
3838
assertThat(KafkaTestUtils.getPropertyValue(broker, "brokerListProperty")).isEqualTo("my.bss.property");
39+
assertThat(KafkaTestUtils.getPropertyValue(broker, "controlledShutdown")).isEqualTo(Boolean.TRUE);
40+
assertThat(broker.getPartitionsPerTopic()).isEqualTo(3);
3941
}
4042

4143
}

spring-kafka/src/test/java/org/springframework/kafka/core/reactive/ReactiveKafkaProducerTemplateIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 the original author or authors.
2+
* Copyright 2019-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@
7272
*
7373
* @since 2.3.0
7474
*/
75-
@EmbeddedKafka(topics = ReactiveKafkaProducerTemplateIntegrationTests.REACTIVE_INT_KEY_TOPIC, partitions = 1)
75+
@EmbeddedKafka(topics = ReactiveKafkaProducerTemplateIntegrationTests.REACTIVE_INT_KEY_TOPIC, partitions = 2)
7676
public class ReactiveKafkaProducerTemplateIntegrationTests {
7777

7878
private static final int DEFAULT_PARTITIONS_COUNT = 2;

0 commit comments

Comments
 (0)