Search in sources :

Example 6 with ConnectionFactory

use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class RabbitConnectionFactoryXmlConfigTest method cloudRabbitConnectionFactoryWithProperties.

@Test
public void cloudRabbitConnectionFactoryWithProperties() {
    ApplicationContext testContext = getTestApplicationContext("cloud-rabbit-with-config.xml", createService("my-service"));
    ConnectionFactory connector = testContext.getBean("service-properties", getConnectorType());
    RabbitConnectionFactoryCloudConfigTestHelper.assertConfigProperties(connector, DEFAULT_CHANNEL_CACHE_SIZE, 5, 10);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) Test(org.junit.Test)

Example 7 with ConnectionFactory

use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class RabbitConnectionFactoryXmlConfigTest method cloudRabbitConnectionFactoryWithConfiguration.

@Test
public void cloudRabbitConnectionFactoryWithConfiguration() {
    ApplicationContext testContext = getTestApplicationContext("cloud-rabbit-with-config.xml", createService("my-service"));
    ConnectionFactory connector = testContext.getBean("service-channelCacheSize200", getConnectorType());
    RabbitConnectionFactoryCloudConfigTestHelper.assertConfigProperties(connector, 200, -1, -1);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) Test(org.junit.Test)

Example 8 with ConnectionFactory

use of org.springframework.amqp.rabbit.connection.ConnectionFactory 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);
}
Also used : ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) CachingConnectionFactory(org.springframework.amqp.rabbit.connection.CachingConnectionFactory) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) CachingConnectionFactory(org.springframework.amqp.rabbit.connection.CachingConnectionFactory) Test(org.junit.Test)

Example 9 with ConnectionFactory

use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class RabbitConnectionFactoryConfigWithServiceConfig method cloudRabbitConnectionFactoryWithProperties.

@Test
public void cloudRabbitConnectionFactoryWithProperties() {
    ApplicationContext testContext = getTestApplicationContext(RabbitConnectionFactoryConfigWithServiceConfig.class, createService("my-service"));
    ConnectionFactory connector = testContext.getBean("connectionFactoryWithProperties", getConnectorType());
    RabbitConnectionFactoryCloudConfigTestHelper.assertConfigProperties(connector, DEFAULT_CHANNEL_CACHE_SIZE, 5, 10);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) Test(org.junit.Test)

Example 10 with ConnectionFactory

use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class RabbitConnectionFactoryConfigWithServiceConfig method cloudRabbitConnectionFactoryWithConfigAndProperties.

@Test
public void cloudRabbitConnectionFactoryWithConfigAndProperties() {
    ApplicationContext testContext = getTestApplicationContext(RabbitConnectionFactoryConfigWithServiceConfig.class, createService("my-service"));
    ConnectionFactory connector = testContext.getBean("connectionFactoryWithConfigAndProperties", getConnectorType());
    RabbitConnectionFactoryCloudConfigTestHelper.assertConfigProperties(connector, 300, 15, 20);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) Test(org.junit.Test)

Aggregations

ConnectionFactory (org.springframework.amqp.rabbit.connection.ConnectionFactory)11 Test (org.junit.Test)10 ApplicationContext (org.springframework.context.ApplicationContext)6 URI (java.net.URI)3 AmqpServiceInfo (org.springframework.cloud.service.common.AmqpServiceInfo)3 CachingConnectionFactory (org.springframework.amqp.rabbit.connection.CachingConnectionFactory)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1