use of org.springframework.amqp.rabbit.connection.CachingConnectionFactory in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testConnectionFactoryVirtualHostMultiLeadingSlashes.
@Test
public void testConnectionFactoryVirtualHostMultiLeadingSlashes() {
load(TestConfiguration.class, "spring.rabbitmq.virtual_host:///foo");
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
assertThat(connectionFactory.getVirtualHost()).isEqualTo("///foo");
}
use of org.springframework.amqp.rabbit.connection.CachingConnectionFactory in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testConnectionFactoryCacheSettings.
@Test
public void testConnectionFactoryCacheSettings() {
load(TestConfiguration.class, "spring.rabbitmq.cache.channel.size=23", "spring.rabbitmq.cache.channel.checkoutTimeout=1000", "spring.rabbitmq.cache.connection.mode=CONNECTION", "spring.rabbitmq.cache.connection.size=2");
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
assertThat(dfa.getPropertyValue("channelCacheSize")).isEqualTo(23);
assertThat(dfa.getPropertyValue("cacheMode")).isEqualTo(CacheMode.CONNECTION);
assertThat(dfa.getPropertyValue("connectionCacheSize")).isEqualTo(2);
assertThat(dfa.getPropertyValue("channelCheckoutTimeout")).isEqualTo(1000L);
}
use of org.springframework.amqp.rabbit.connection.CachingConnectionFactory in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testConnectionFactoryVirtualHostNoLeadingSlash.
@Test
public void testConnectionFactoryVirtualHostNoLeadingSlash() {
load(TestConfiguration.class, "spring.rabbitmq.virtual_host:foo");
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
assertThat(connectionFactory.getVirtualHost()).isEqualTo("foo");
}
use of org.springframework.amqp.rabbit.connection.CachingConnectionFactory in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testConnectionFactoryBackOff.
@Test
public void testConnectionFactoryBackOff() {
load(TestConfiguration2.class);
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
assertThat(connectionFactory).isEqualTo(rabbitTemplate.getConnectionFactory());
assertThat(connectionFactory.getHost()).isEqualTo("otherserver");
assertThat(connectionFactory.getPort()).isEqualTo(8001);
}
use of org.springframework.amqp.rabbit.connection.CachingConnectionFactory in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testConnectionFactoryWithOverrides.
@Test
public void testConnectionFactoryWithOverrides() {
load(TestConfiguration.class, "spring.rabbitmq.host:remote-server", "spring.rabbitmq.port:9000", "spring.rabbitmq.username:alice", "spring.rabbitmq.password:secret", "spring.rabbitmq.virtual_host:/vhost", "spring.rabbitmq.connection-timeout:123");
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
assertThat(connectionFactory.getHost()).isEqualTo("remote-server");
assertThat(connectionFactory.getPort()).isEqualTo(9000);
assertThat(connectionFactory.getVirtualHost()).isEqualTo("/vhost");
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
com.rabbitmq.client.ConnectionFactory rcf = (com.rabbitmq.client.ConnectionFactory) dfa.getPropertyValue("rabbitConnectionFactory");
assertThat(rcf.getConnectionTimeout()).isEqualTo(123);
assertThat((Address[]) dfa.getPropertyValue("addresses")).hasSize(1);
}
Aggregations