use of jakarta.jms.ConnectionFactory in project spring-boot by spring-projects.
the class ArtemisAutoConfigurationTests method nativeConnectionFactoryCredentials.
@Test
void nativeConnectionFactoryCredentials() {
this.contextRunner.withUserConfiguration(EmptyConfiguration.class).withPropertyValues("spring.artemis.mode:native", "spring.artemis.user:user", "spring.artemis.password:secret").run((context) -> {
JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);
ConnectionFactory connectionFactory = getConnectionFactory(context);
assertThat(connectionFactory).isEqualTo(jmsTemplate.getConnectionFactory());
ActiveMQConnectionFactory activeMQConnectionFactory = getActiveMQConnectionFactory(connectionFactory);
assertNettyConnectionFactory(activeMQConnectionFactory, "localhost", 61616);
assertThat(activeMQConnectionFactory.getUser()).isEqualTo("user");
assertThat(activeMQConnectionFactory.getPassword()).isEqualTo("secret");
});
}
use of jakarta.jms.ConnectionFactory in project spring-boot by spring-projects.
the class ArtemisAutoConfigurationTests method connectionFactoryCachingCanBeDisabled.
@Test
void connectionFactoryCachingCanBeDisabled() {
this.contextRunner.withUserConfiguration(EmptyConfiguration.class).withPropertyValues("spring.jms.cache.enabled=false").run((context) -> {
assertThat(context).doesNotHaveBean(CachingConnectionFactory.class);
ConnectionFactory connectionFactory = getConnectionFactory(context);
assertThat(connectionFactory).isInstanceOf(ActiveMQConnectionFactory.class);
});
}
use of jakarta.jms.ConnectionFactory in project spring-boot by spring-projects.
the class JndiConnectionFactoryAutoConfigurationTests method detectWithXAConnectionFactory.
@Test
void detectWithXAConnectionFactory() {
ConnectionFactory connectionFactory = configureConnectionFactory("java:/XAConnectionFactory");
this.contextRunner.run(assertConnectionFactory(connectionFactory));
}
use of jakarta.jms.ConnectionFactory in project spring-boot by spring-projects.
the class JndiConnectionFactoryAutoConfigurationTests method jndiNamePropertySet.
@Test
void jndiNamePropertySet() {
ConnectionFactory connectionFactory = configureConnectionFactory("java:comp/env/myCF");
this.contextRunner.withPropertyValues("spring.jms.jndi-name=java:comp/env/myCF").run(assertConnectionFactory(connectionFactory));
}
use of jakarta.jms.ConnectionFactory in project spring-framework by spring-projects.
the class JmsTransactionManagerTests method testTransactionRollback.
@Test
public void testTransactionRollback() throws JMSException {
ConnectionFactory cf = mock(ConnectionFactory.class);
Connection con = mock(Connection.class);
final Session session = mock(Session.class);
given(cf.createConnection()).willReturn(con);
given(con.createSession(true, Session.AUTO_ACKNOWLEDGE)).willReturn(session);
JmsTransactionManager tm = new JmsTransactionManager(cf);
TransactionStatus ts = tm.getTransaction(new DefaultTransactionDefinition());
JmsTemplate jt = new JmsTemplate(cf);
jt.execute((SessionCallback<Void>) sess -> {
assertThat(session).isSameAs(sess);
return null;
});
tm.rollback(ts);
verify(session).rollback();
verify(session).close();
verify(con).close();
}
Aggregations