GH-2266 Add test to ensure GlobalChannelInterceptor is not added multiple times to the MessageChannels
This commit is contained in:
committed by
Oleg Zhurakousky
parent
872edb2f24
commit
d3e5459c2c
@@ -41,6 +41,7 @@ import org.springframework.cloud.stream.binding.NewDestinationBindingCallback;
|
||||
import org.springframework.cloud.stream.config.BindingServiceProperties;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.config.GlobalChannelInterceptor;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
@@ -185,6 +186,27 @@ public class StreamBridgeTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterceptorIsNotAddedMultipleTimesToTheMessageChannel() {
|
||||
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration
|
||||
.getCompleteConfiguration(InterceptorConfiguration.class))
|
||||
.web(WebApplicationType.NONE).run(
|
||||
"--spring.jmx.enabled=false",
|
||||
"--spring.cloud.stream.dynamic-destination-cache-size=1",
|
||||
"--spring.cloud.stream.source=outputA;outputB",
|
||||
"--spring.cloud.stream.bindings.outputA-out-0.destination=outputA",
|
||||
"--spring.cloud.stream.bindings.outputB-out-0.destination=outputB")) {
|
||||
StreamBridge bridge = context.getBean(StreamBridge.class);
|
||||
|
||||
bridge.send("outputA-out-0", "hello foo");
|
||||
bridge.send("outputA-out-0", "hello foo");
|
||||
|
||||
AbstractMessageChannel messageChannel = context.getBean("outputA-out-0", AbstractMessageChannel.class);
|
||||
|
||||
assertThat(messageChannel.getInterceptors()).hasSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithInterceptorsRegisteredOnlyOnOutputChannel() throws InterruptedException {
|
||||
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration
|
||||
|
||||
Reference in New Issue
Block a user