Search in sources :

Example 6 with DefaultJmsListenerContainerFactory

use of org.springframework.jms.config.DefaultJmsListenerContainerFactory in project spring-boot by spring-projects.

the class JmsAutoConfigurationTests method testDefaultContainerFactoryWithJtaTransactionManager.

@Test
public void testDefaultContainerFactoryWithJtaTransactionManager() {
    this.context = createContext(TestConfiguration7.class, EnableJmsConfiguration.class);
    JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean("jmsListenerContainerFactory", JmsListenerContainerFactory.class);
    assertThat(jmsListenerContainerFactory.getClass()).isEqualTo(DefaultJmsListenerContainerFactory.class);
    DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory).createListenerContainer(mock(JmsListenerEndpoint.class));
    assertThat(listenerContainer.isSessionTransacted()).isFalse();
    assertThat(new DirectFieldAccessor(listenerContainer).getPropertyValue("transactionManager")).isSameAs(this.context.getBean(JtaTransactionManager.class));
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) JtaTransactionManager(org.springframework.transaction.jta.JtaTransactionManager) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 7 with DefaultJmsListenerContainerFactory

use of org.springframework.jms.config.DefaultJmsListenerContainerFactory in project spring-boot by spring-projects.

the class JmsAutoConfigurationTests method testDefaultContainerFactoryNoTransactionManager.

@Test
public void testDefaultContainerFactoryNoTransactionManager() {
    this.context = createContext(EnableJmsConfiguration.class);
    JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean("jmsListenerContainerFactory", JmsListenerContainerFactory.class);
    assertThat(jmsListenerContainerFactory.getClass()).isEqualTo(DefaultJmsListenerContainerFactory.class);
    DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory).createListenerContainer(mock(JmsListenerEndpoint.class));
    assertThat(listenerContainer.isSessionTransacted()).isTrue();
    assertThat(new DirectFieldAccessor(listenerContainer).getPropertyValue("transactionManager")).isNull();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Aggregations

DefaultJmsListenerContainerFactory (org.springframework.jms.config.DefaultJmsListenerContainerFactory)7 Test (org.junit.Test)6 JmsListenerEndpoint (org.springframework.jms.config.JmsListenerEndpoint)6 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)6 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)3 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 JtaTransactionManager (org.springframework.transaction.jta.JtaTransactionManager)1