@Override @Bean public AbstractSubscribableChannel clientInboundChannel() { TestChannel channel = new TestChannel(); channel.setInterceptors(super.clientInboundChannel().getInterceptors()); return channel; }
@Override @Bean public AbstractSubscribableChannel clientOutboundChannel() { TestChannel channel = new TestChannel(); channel.setInterceptors(super.clientOutboundChannel().getInterceptors()); return channel; }
@Override public AbstractSubscribableChannel brokerChannel() { TestChannel channel = new TestChannel(); channel.setInterceptors(super.brokerChannel().getInterceptors()); return channel; } }
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); assertNotNull("No subscription for " + subscriberType, subscriber); assertTrue(channel.hasSubscription(subscriber)); } List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(interceptorCount, interceptors.size()); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); }
@Test public void clientInboundChannelCustomized() { ApplicationContext context = loadConfig(CustomConfig.class); AbstractSubscribableChannel channel = context.getBean( "clientInboundChannel", AbstractSubscribableChannel.class); assertEquals(3, channel.getInterceptors().size()); CustomThreadPoolTaskExecutor taskExecutor = context.getBean( "clientInboundChannelExecutor", CustomThreadPoolTaskExecutor.class); assertEquals(11, taskExecutor.getCorePoolSize()); assertEquals(12, taskExecutor.getMaxPoolSize()); assertEquals(13, taskExecutor.getKeepAliveSeconds()); }
@Test public void brokerChannelCustomized() { ApplicationContext context = loadConfig(CustomConfig.class); AbstractSubscribableChannel channel = context.getBean( "brokerChannel", AbstractSubscribableChannel.class); assertEquals(4, channel.getInterceptors().size()); ThreadPoolTaskExecutor taskExecutor = context.getBean( "brokerChannelExecutor", ThreadPoolTaskExecutor.class); assertEquals(31, taskExecutor.getCorePoolSize()); assertEquals(32, taskExecutor.getMaxPoolSize()); assertEquals(33, taskExecutor.getKeepAliveSeconds()); }
@Test public void clientOutboundChannelCustomized() { ApplicationContext context = loadConfig(CustomConfig.class); AbstractSubscribableChannel channel = context.getBean( "clientOutboundChannel", AbstractSubscribableChannel.class); assertEquals(4, channel.getInterceptors().size()); ThreadPoolTaskExecutor taskExecutor = context.getBean( "clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class); assertEquals(21, taskExecutor.getCorePoolSize()); assertEquals(22, taskExecutor.getMaxPoolSize()); assertEquals(23, taskExecutor.getKeepAliveSeconds()); SimpleBrokerMessageHandler broker = context.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class); assertTrue(broker.isPreservePublishOrder()); }