From 05ee48c1f3503a16b1130ebe649fdcee83af8e54 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Mon, 30 Sep 2019 15:34:08 -0400 Subject: [PATCH] @EmbeddedKafka javadoc polishing - place holders are not resolved when Spring is not being used --- .../kafka/test/EmbeddedKafkaBroker.java | 2 +- .../kafka/test/context/EmbeddedKafka.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/spring-kafka-test/src/main/java/org/springframework/kafka/test/EmbeddedKafkaBroker.java b/spring-kafka-test/src/main/java/org/springframework/kafka/test/EmbeddedKafkaBroker.java index f8a760d4..ad53c32a 100644 --- a/spring-kafka-test/src/main/java/org/springframework/kafka/test/EmbeddedKafkaBroker.java +++ b/spring-kafka-test/src/main/java/org/springframework/kafka/test/EmbeddedKafkaBroker.java @@ -610,7 +610,7 @@ public class EmbeddedKafkaBroker implements InitializingBean, DisposableBean { int n = 0; while (n++ < 100) { try { - ZkFourLetterWords.sendStat("127.0.0.1", port, 3000); + ZkFourLetterWords.sendStat("127.0.0.1", this.port, 3000); Thread.sleep(100); } catch (@SuppressWarnings("unused") Exception e) { diff --git a/spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafka.java b/spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafka.java index 8d5830eb..5d007bb6 100644 --- a/spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafka.java +++ b/spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafka.java @@ -108,11 +108,13 @@ public @interface EmbeddedKafka { int partitions() default 2; /** - * Topics that should be created Topics may contain property placeholders, e.g. + * Topics that should be created Topics may contain property place holders, e.g. * {@code topics = "${kafka.topic.one:topicOne}"} The topics will be created with * {@link #partitions()} partitions; to provision other topics with other partition * counts call the {@code addTopics(NewTopic... topics)} method on the autowired * broker. + * Place holders will only be resolved when there is a Spring test application + * context present (such as when using {@code @SpringJunitConfig or @SpringRunner}. * @return the topics to create */ String[] topics() default { }; @@ -120,7 +122,9 @@ public @interface EmbeddedKafka { /** * Properties in form {@literal key=value} that should be added to the broker config * before runs. When used in a Spring test context, properties may contain property - * placeholders, e.g. {@code delete.topic.enable=${topic.delete:true}}. + * place holders, e.g. {@code delete.topic.enable=${topic.delete:true}}. + * Place holders will only be resolved when there is a Spring test application + * context present (such as when using {@code @SpringJunitConfig or @SpringRunner}. * @return the properties to add * @see #brokerPropertiesLocation() * @see org.springframework.kafka.test.EmbeddedKafkaBroker#brokerProperties(java.util.Map) @@ -131,9 +135,11 @@ public @interface EmbeddedKafka { * Spring {@code Resource} url specifying the location of properties that should be * added to the broker config. When used in a Spring test context, the * {@code brokerPropertiesLocation} url and the properties themselves may contain - * placeholders that are resolved during initialization. Properties specified by + * place holders that are resolved during initialization. Properties specified by * {@link #brokerProperties()} will override properties found in * {@code brokerPropertiesLocation}. + * Place holders will only be resolved when there is a Spring test application + * context present (such as when using {@code @SpringJunitConfig or @SpringRunner}. * @return a {@code Resource} url specifying the location of properties to add * @see #brokerProperties() * @see org.springframework.kafka.test.EmbeddedKafkaBroker#brokerProperties(java.util.Map)