mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +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
|
||||
void whenHasUseDefinedProducerInterceptorInjectsBean() {
|
||||
<T> void whenHasUseDefinedProducerInterceptorInjectsBean() {
|
||||
ProducerInterceptor interceptor = mock(ProducerInterceptor.class);
|
||||
this.contextRunner.withBean("customProducerInterceptor", ProducerInterceptor.class, () -> interceptor)
|
||||
.run((context) -> assertThat(context).getBean(PulsarTemplate.class)
|
||||
.extracting("interceptors")
|
||||
.asList()
|
||||
.contains(interceptor));
|
||||
.run((context) -> {
|
||||
PulsarTemplate<?> pulsarTemplate = context.getBean(PulsarTemplate.class);
|
||||
Customizers<ProducerBuilderCustomizer<T>, ProducerBuilder<T>> customizers = Customizers
|
||||
.of(ProducerBuilder.class, ProducerBuilderCustomizer::customize);
|
||||
assertThat(customizers.fromField(pulsarTemplate, "interceptorsCustomizers"))
|
||||
.callsInOrder(ProducerBuilder::intercept, interceptor);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenHasUseDefinedProducerInterceptorsInjectsBeansInCorrectOrder() {
|
||||
this.contextRunner.withUserConfiguration(InterceptorTestConfiguration.class)
|
||||
.run((context) -> assertThat(context).getBean(PulsarTemplate.class)
|
||||
.extracting("interceptors")
|
||||
.asList()
|
||||
.containsExactly(context.getBean("interceptorBar"), context.getBean("interceptorFoo")));
|
||||
<T> void whenHasUseDefinedProducerInterceptorsInjectsBeansInCorrectOrder() {
|
||||
this.contextRunner.withUserConfiguration(InterceptorTestConfiguration.class).run((context) -> {
|
||||
ProducerInterceptor interceptorFoo = context.getBean("interceptorFoo", ProducerInterceptor.class);
|
||||
ProducerInterceptor interceptorBar = context.getBean("interceptorBar", ProducerInterceptor.class);
|
||||
PulsarTemplate<?> pulsarTemplate = context.getBean(PulsarTemplate.class);
|
||||
Customizers<ProducerBuilderCustomizer<T>, ProducerBuilder<T>> customizers = Customizers
|
||||
.of(ProducerBuilder.class, ProducerBuilderCustomizer::customize);
|
||||
assertThat(customizers.fromField(pulsarTemplate, "interceptorsCustomizers"))
|
||||
.callsInOrder(ProducerBuilder::intercept, interceptorBar, interceptorFoo);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user