Search in sources :

Example 1 with AbstractSubscribableChannel

use of org.springframework.messaging.support.AbstractSubscribableChannel in project spring-framework by spring-projects.

the class TestValidator method testChannel.

private void testChannel(String channelName, List<Class<? extends MessageHandler>> subscriberTypes, int interceptorCount) {
    AbstractSubscribableChannel channel = this.appContext.getBean(channelName, AbstractSubscribableChannel.class);
    for (Class<? extends MessageHandler> subscriberType : subscriberTypes) {
        MessageHandler subscriber = this.appContext.getBean(subscriberType);
        assertThat(subscriber).as("No subscription for " + subscriberType).isNotNull();
        assertThat(channel.hasSubscription(subscriber)).isTrue();
    }
    List<ChannelInterceptor> interceptors = channel.getInterceptors();
    assertThat(interceptors.size()).isEqualTo(interceptorCount);
    assertThat(interceptors.get(interceptors.size() - 1).getClass()).isEqualTo(ImmutableMessageChannelInterceptor.class);
}
Also used : AbstractSubscribableChannel(org.springframework.messaging.support.AbstractSubscribableChannel) StompBrokerRelayMessageHandler(org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler) MessageHandler(org.springframework.messaging.MessageHandler) SimpleBrokerMessageHandler(org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler) UserRegistryMessageHandler(org.springframework.messaging.simp.user.UserRegistryMessageHandler) UserDestinationMessageHandler(org.springframework.messaging.simp.user.UserDestinationMessageHandler) SimpAnnotationMethodMessageHandler(org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler) ChannelInterceptor(org.springframework.messaging.support.ChannelInterceptor) ImmutableMessageChannelInterceptor(org.springframework.messaging.support.ImmutableMessageChannelInterceptor)

Example 2 with AbstractSubscribableChannel

use of org.springframework.messaging.support.AbstractSubscribableChannel in project spring-framework by spring-projects.

the class MessageBrokerConfigurationTests method clientInboundChannelCustomized.

@Test
public void clientInboundChannelCustomized() {
    ApplicationContext context = loadConfig(CustomConfig.class);
    AbstractSubscribableChannel channel = context.getBean("clientInboundChannel", AbstractSubscribableChannel.class);
    assertThat(channel.getInterceptors().size()).isEqualTo(3);
    CustomThreadPoolTaskExecutor taskExecutor = context.getBean("clientInboundChannelExecutor", CustomThreadPoolTaskExecutor.class);
    assertThat(taskExecutor.getCorePoolSize()).isEqualTo(11);
    assertThat(taskExecutor.getMaxPoolSize()).isEqualTo(12);
    assertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(13);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) AbstractSubscribableChannel(org.springframework.messaging.support.AbstractSubscribableChannel) Test(org.junit.jupiter.api.Test)

Example 3 with AbstractSubscribableChannel

use of org.springframework.messaging.support.AbstractSubscribableChannel in project spring-framework by spring-projects.

the class MessageBrokerConfigurationTests method clientOutboundChannelCustomized.

@Test
public void clientOutboundChannelCustomized() {
    ApplicationContext context = loadConfig(CustomConfig.class);
    AbstractSubscribableChannel channel = context.getBean("clientOutboundChannel", AbstractSubscribableChannel.class);
    assertThat(channel.getInterceptors().size()).isEqualTo(4);
    ThreadPoolTaskExecutor taskExecutor = context.getBean("clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class);
    assertThat(taskExecutor.getCorePoolSize()).isEqualTo(21);
    assertThat(taskExecutor.getMaxPoolSize()).isEqualTo(22);
    assertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(23);
    SimpleBrokerMessageHandler broker = context.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class);
    assertThat(broker.isPreservePublishOrder()).isTrue();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) AbstractSubscribableChannel(org.springframework.messaging.support.AbstractSubscribableChannel) SimpleBrokerMessageHandler(org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Test(org.junit.jupiter.api.Test)

Example 4 with AbstractSubscribableChannel

use of org.springframework.messaging.support.AbstractSubscribableChannel in project spring-framework by spring-projects.

the class MessageBrokerConfigurationTests method brokerChannelCustomized.

@Test
public void brokerChannelCustomized() {
    ApplicationContext context = loadConfig(CustomConfig.class);
    AbstractSubscribableChannel channel = context.getBean("brokerChannel", AbstractSubscribableChannel.class);
    assertThat(channel.getInterceptors().size()).isEqualTo(4);
    ThreadPoolTaskExecutor taskExecutor = context.getBean("brokerChannelExecutor", ThreadPoolTaskExecutor.class);
    assertThat(taskExecutor.getCorePoolSize()).isEqualTo(31);
    assertThat(taskExecutor.getMaxPoolSize()).isEqualTo(32);
    assertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(33);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) AbstractSubscribableChannel(org.springframework.messaging.support.AbstractSubscribableChannel) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractSubscribableChannel (org.springframework.messaging.support.AbstractSubscribableChannel)4 Test (org.junit.jupiter.api.Test)3 ApplicationContext (org.springframework.context.ApplicationContext)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)3 SimpleBrokerMessageHandler (org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler)2 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)2 MessageHandler (org.springframework.messaging.MessageHandler)1 SimpAnnotationMethodMessageHandler (org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler)1 StompBrokerRelayMessageHandler (org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler)1 UserDestinationMessageHandler (org.springframework.messaging.simp.user.UserDestinationMessageHandler)1 UserRegistryMessageHandler (org.springframework.messaging.simp.user.UserRegistryMessageHandler)1 ChannelInterceptor (org.springframework.messaging.support.ChannelInterceptor)1 ImmutableMessageChannelInterceptor (org.springframework.messaging.support.ImmutableMessageChannelInterceptor)1