@Test public void testCustomContainerFactoryWithConfigurer() { this.context = doLoad( new Class<?>[] {TestConfiguration9.class, EnableJmsConfiguration.class}, "spring.jms.listener.autoStartup=false"); assertThat(this.context.containsBean("jmsListenerContainerFactory")).isTrue(); JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean("customListenerContainerFactory", JmsListenerContainerFactory.class); assertThat(jmsListenerContainerFactory).isInstanceOf(DefaultJmsListenerContainerFactory.class); DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory) .createListenerContainer(mock(JmsListenerEndpoint.class)); assertThat(listenerContainer.getCacheLevel()) .isEqualTo(DefaultMessageListenerContainer.CACHE_CONSUMER); assertThat(listenerContainer.isAutoStartup()).isFalse(); }
@Test public void testJmsListenerContainerFactoryWithCustomSettings() { load( EnableJmsConfiguration.class, "spring.jms.listener.autoStartup=false", "spring.jms.listener.acknowledgeMode=client", "spring.jms.listener.concurrency=2", "spring.jms.listener.maxConcurrency=10"); JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean("jmsListenerContainerFactory", JmsListenerContainerFactory.class); assertThat(jmsListenerContainerFactory.getClass()) .isEqualTo(DefaultJmsListenerContainerFactory.class); DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory) .createListenerContainer(mock(JmsListenerEndpoint.class)); assertThat(listenerContainer.isAutoStartup()).isFalse(); assertThat(listenerContainer.getSessionAcknowledgeMode()).isEqualTo(Session.CLIENT_ACKNOWLEDGE); assertThat(listenerContainer.getConcurrentConsumers()).isEqualTo(2); assertThat(listenerContainer.getMaxConcurrentConsumers()).isEqualTo(10); }