|
|
@ -57,6 +57,7 @@ import static org.mockito.Mockito.mock;
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Aurélien Leboulanger
|
|
|
|
* @author Aurélien Leboulanger
|
|
|
|
* @author Eddú Meléndez
|
|
|
|
* @author Eddú Meléndez
|
|
|
|
|
|
|
|
* @author Vedran Pavic
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class JmsAutoConfigurationTests {
|
|
|
|
class JmsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
@ -143,7 +144,8 @@ class JmsAutoConfigurationTests {
|
|
|
|
void testJmsListenerContainerFactoryWithCustomSettings() {
|
|
|
|
void testJmsListenerContainerFactoryWithCustomSettings() {
|
|
|
|
this.contextRunner.withUserConfiguration(EnableJmsConfiguration.class)
|
|
|
|
this.contextRunner.withUserConfiguration(EnableJmsConfiguration.class)
|
|
|
|
.withPropertyValues("spring.jms.listener.autoStartup=false",
|
|
|
|
.withPropertyValues("spring.jms.listener.autoStartup=false",
|
|
|
|
"spring.jms.listener.session.acknowledgeMode=client", "spring.jms.listener.minConcurrency=2",
|
|
|
|
"spring.jms.listener.session.acknowledgeMode=client",
|
|
|
|
|
|
|
|
"spring.jms.listener.session.transacted=false", "spring.jms.listener.minConcurrency=2",
|
|
|
|
"spring.jms.listener.receiveTimeout=2s", "spring.jms.listener.maxConcurrency=10")
|
|
|
|
"spring.jms.listener.receiveTimeout=2s", "spring.jms.listener.maxConcurrency=10")
|
|
|
|
.run(this::testJmsListenerContainerFactoryWithCustomSettings);
|
|
|
|
.run(this::testJmsListenerContainerFactoryWithCustomSettings);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -152,6 +154,7 @@ class JmsAutoConfigurationTests {
|
|
|
|
DefaultMessageListenerContainer container = getContainer(loaded, "jmsListenerContainerFactory");
|
|
|
|
DefaultMessageListenerContainer container = getContainer(loaded, "jmsListenerContainerFactory");
|
|
|
|
assertThat(container.isAutoStartup()).isFalse();
|
|
|
|
assertThat(container.isAutoStartup()).isFalse();
|
|
|
|
assertThat(container.getSessionAcknowledgeMode()).isEqualTo(Session.CLIENT_ACKNOWLEDGE);
|
|
|
|
assertThat(container.getSessionAcknowledgeMode()).isEqualTo(Session.CLIENT_ACKNOWLEDGE);
|
|
|
|
|
|
|
|
assertThat(container.isSessionTransacted()).isFalse();
|
|
|
|
assertThat(container.getConcurrentConsumers()).isEqualTo(2);
|
|
|
|
assertThat(container.getConcurrentConsumers()).isEqualTo(2);
|
|
|
|
assertThat(container.getMaxConcurrentConsumers()).isEqualTo(10);
|
|
|
|
assertThat(container.getMaxConcurrentConsumers()).isEqualTo(10);
|
|
|
|
assertThat(container).hasFieldOrPropertyWithValue("receiveTimeout", 2000L);
|
|
|
|
assertThat(container).hasFieldOrPropertyWithValue("receiveTimeout", 2000L);
|
|
|
@ -179,6 +182,18 @@ class JmsAutoConfigurationTests {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void testDefaultContainerFactoryWithJtaTransactionManagerAndSessionTransactedEnabled() {
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration7.class, EnableJmsConfiguration.class)
|
|
|
|
|
|
|
|
.withPropertyValues("spring.jms.listener.session.transacted=true")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
DefaultMessageListenerContainer container = getContainer(context, "jmsListenerContainerFactory");
|
|
|
|
|
|
|
|
assertThat(container.isSessionTransacted()).isTrue();
|
|
|
|
|
|
|
|
assertThat(container).hasFieldOrPropertyWithValue("transactionManager",
|
|
|
|
|
|
|
|
context.getBean(JtaTransactionManager.class));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testDefaultContainerFactoryNonJtaTransactionManager() {
|
|
|
|
void testDefaultContainerFactoryNonJtaTransactionManager() {
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration8.class, EnableJmsConfiguration.class)
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration8.class, EnableJmsConfiguration.class)
|
|
|
@ -198,6 +213,17 @@ class JmsAutoConfigurationTests {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void testDefaultContainerFactoryNoTransactionManagerAndSessionTransactedDisabled() {
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(EnableJmsConfiguration.class)
|
|
|
|
|
|
|
|
.withPropertyValues("spring.jms.listener.session.transacted=false")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
DefaultMessageListenerContainer container = getContainer(context, "jmsListenerContainerFactory");
|
|
|
|
|
|
|
|
assertThat(container.isSessionTransacted()).isFalse();
|
|
|
|
|
|
|
|
assertThat(container).hasFieldOrPropertyWithValue("transactionManager", null);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testDefaultContainerFactoryWithMessageConverters() {
|
|
|
|
void testDefaultContainerFactoryWithMessageConverters() {
|
|
|
|
this.contextRunner.withUserConfiguration(MessageConvertersConfiguration.class, EnableJmsConfiguration.class)
|
|
|
|
this.contextRunner.withUserConfiguration(MessageConvertersConfiguration.class, EnableJmsConfiguration.class)
|
|
|
|