Skip to content

Commit df8db51

Browse files
committed
Adjust test for topic builder having prototype scope
1 parent f40986b commit df8db51

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarAutoConfigurationTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import org.springframework.pulsar.core.PulsarProducerFactory;
6868
import org.springframework.pulsar.core.PulsarReaderFactory;
6969
import org.springframework.pulsar.core.PulsarTemplate;
70-
import org.springframework.pulsar.core.PulsarTopicBuilder;
7170
import org.springframework.pulsar.core.ReaderBuilderCustomizer;
7271
import org.springframework.pulsar.core.SchemaResolver;
7372
import org.springframework.pulsar.core.TopicResolver;
@@ -221,7 +220,8 @@ void injectsExpectedBeans() {
221220
.run((context) -> assertThat(context).getBean(DefaultPulsarProducerFactory.class)
222221
.hasFieldOrPropertyWithValue("pulsarClient", context.getBean(PulsarClient.class))
223222
.hasFieldOrPropertyWithValue("topicResolver", context.getBean(TopicResolver.class))
224-
.hasFieldOrPropertyWithValue("topicBuilder", context.getBean(PulsarTopicBuilder.class)));
223+
.extracting("topicBuilder")
224+
.isNotNull()); // prototype so only check not-null
225225
}
226226

227227
@ParameterizedTest
@@ -378,7 +378,8 @@ void whenHasUserDefinedBeanDoesNotAutoConfigureBean() {
378378
void injectsExpectedBeans() {
379379
this.contextRunner.run((context) -> assertThat(context).getBean(DefaultPulsarConsumerFactory.class)
380380
.hasFieldOrPropertyWithValue("pulsarClient", context.getBean(PulsarClient.class))
381-
.hasFieldOrPropertyWithValue("topicBuilder", context.getBean(PulsarTopicBuilder.class)));
381+
.extracting("topicBuilder")
382+
.isNotNull()); // prototype so only check not-null
382383
}
383384

384385
@Test
@@ -578,7 +579,8 @@ void whenHasUserDefinedBeanDoesNotAutoConfigureBean() {
578579
void injectsExpectedBeans() {
579580
this.contextRunner.run((context) -> assertThat(context).getBean(DefaultPulsarReaderFactory.class)
580581
.hasFieldOrPropertyWithValue("pulsarClient", context.getBean(PulsarClient.class))
581-
.hasFieldOrPropertyWithValue("topicBuilder", context.getBean(PulsarTopicBuilder.class)));
582+
.extracting("topicBuilder")
583+
.isNotNull()); // prototype so only check not-null
582584
}
583585

584586
@Test

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfigurationTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,12 @@ void whenHasDefaultsTenantAndNamespaceAppliedToTopicBuilder() {
353353
}));
354354
}
355355

356+
@Test
357+
void beanHasScopePrototype() {
358+
this.contextRunner.run((context) -> assertThat(context.getBean(PulsarTopicBuilder.class))
359+
.isNotSameAs(context.getBean(PulsarTopicBuilder.class)));
360+
}
361+
356362
}
357363

358364
@Nested

0 commit comments

Comments
 (0)