mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Re-enable Spring Pulsar interceptor tests
The PulsarTemplate recently replaced its list of ProducerInterceptors
with a list of ProducerBuilderCustomizers that customize the builder by
adding each interceptor to the builder. The PulsarAutoConfigurationTests
previosuly relied on the previous field. This commit adjusts the tests
to instead use the Customizers testing utility to verify the
interceptors.
(cherry picked from commit 9c054a021f
)
See gh-39946
This commit is contained in:
parent
f324994065
commit
ac0d1e0ec6
@ -283,22 +283,29 @@ class PulsarAutoConfigurationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenHasUseDefinedProducerInterceptorInjectsBean() {
|
<T> void whenHasUseDefinedProducerInterceptorInjectsBean() {
|
||||||
ProducerInterceptor interceptor = mock(ProducerInterceptor.class);
|
ProducerInterceptor interceptor = mock(ProducerInterceptor.class);
|
||||||
this.contextRunner.withBean("customProducerInterceptor", ProducerInterceptor.class, () -> interceptor)
|
this.contextRunner.withBean("customProducerInterceptor", ProducerInterceptor.class, () -> interceptor)
|
||||||
.run((context) -> assertThat(context).getBean(PulsarTemplate.class)
|
.run((context) -> {
|
||||||
.extracting("interceptors")
|
PulsarTemplate<?> pulsarTemplate = context.getBean(PulsarTemplate.class);
|
||||||
.asList()
|
Customizers<ProducerBuilderCustomizer<T>, ProducerBuilder<T>> customizers = Customizers
|
||||||
.contains(interceptor));
|
.of(ProducerBuilder.class, ProducerBuilderCustomizer::customize);
|
||||||
|
assertThat(customizers.fromField(pulsarTemplate, "interceptorsCustomizers"))
|
||||||
|
.callsInOrder(ProducerBuilder::intercept, interceptor);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenHasUseDefinedProducerInterceptorsInjectsBeansInCorrectOrder() {
|
<T> void whenHasUseDefinedProducerInterceptorsInjectsBeansInCorrectOrder() {
|
||||||
this.contextRunner.withUserConfiguration(InterceptorTestConfiguration.class)
|
this.contextRunner.withUserConfiguration(InterceptorTestConfiguration.class).run((context) -> {
|
||||||
.run((context) -> assertThat(context).getBean(PulsarTemplate.class)
|
ProducerInterceptor interceptorFoo = context.getBean("interceptorFoo", ProducerInterceptor.class);
|
||||||
.extracting("interceptors")
|
ProducerInterceptor interceptorBar = context.getBean("interceptorBar", ProducerInterceptor.class);
|
||||||
.asList()
|
PulsarTemplate<?> pulsarTemplate = context.getBean(PulsarTemplate.class);
|
||||||
.containsExactly(context.getBean("interceptorBar"), context.getBean("interceptorFoo")));
|
Customizers<ProducerBuilderCustomizer<T>, ProducerBuilder<T>> customizers = Customizers
|
||||||
|
.of(ProducerBuilder.class, ProducerBuilderCustomizer::customize);
|
||||||
|
assertThat(customizers.fromField(pulsarTemplate, "interceptorsCustomizers"))
|
||||||
|
.callsInOrder(ProducerBuilder::intercept, interceptorBar, interceptorFoo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user