use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.
the class RabbitConnectionFactoryCreatorTest method cloudRabbitCreationWithUri.
@Test
public void cloudRabbitCreationWithUri() throws Exception {
String userinfo = String.format("%s:%s", TEST_USERNAME, TEST_PASSWORD);
URI uri = new URI("amqp", userinfo, TEST_HOST, TEST_PORT, "/" + TEST_VH, null, null);
AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", uri.toString());
ConnectionFactory connector = testCreator.create(serviceInfo, null);
assertConnectorPropertiesMatchUri(connector, serviceInfo.getUri());
}
use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.
the class RabbitConnectionFactoryCreatorTest method assertConnectorPropertiesMatchUri.
private void assertConnectorPropertiesMatchUri(ConnectionFactory connector, String uriString) throws Exception {
assertNotNull(connector);
URI uri = new URI(uriString);
assertEquals(uri.getHost(), connector.getHost());
assertEquals(uri.getPort(), connector.getPort());
com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = (com.rabbitmq.client.ConnectionFactory) ReflectionTestUtils.getField(connector, "rabbitConnectionFactory");
String[] userInfo = uri.getRawUserInfo().split(":");
assertEquals(userInfo[0], ReflectionTestUtils.getField(rabbitConnectionFactory, "username"));
assertEquals(userInfo[1], ReflectionTestUtils.getField(rabbitConnectionFactory, "password"));
assertTrue(uri.getPath().endsWith(connector.getVirtualHost()));
}
use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.
the class RabbitConnectionFactoryCreatorTest method cloudRabbitCreationWithUris.
@Test
public void cloudRabbitCreationWithUris() throws Exception {
String userinfo = String.format("%s:%s", TEST_USERNAME, TEST_PASSWORD);
URI uri = new URI("amqp", userinfo, "0.0.0.0", 0, "/" + TEST_VH, null, null);
URI uri1 = new URI("amqp", userinfo, TEST_HOST, TEST_PORT, "/" + TEST_VH, null, null);
URI uri2 = new URI("amqp", userinfo, TEST_HOST2, TEST_PORT2, "/" + TEST_VH, null, null);
List<String> uris = Arrays.asList(uri1.toString(), uri2.toString());
AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", uri.toString(), null, uris, null);
ConnectionFactory connector = testCreator.create(serviceInfo, null);
assertConnectorPropertiesMatchUri(connector, uri1.toString());
assertConnectorPropertiesMatchHosts(connector, uris);
}
use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.
the class RabbitConnectionFactoryConfigWithServiceConfig method cloudRabbitConnectionFactoryWithConfig.
@Test
public void cloudRabbitConnectionFactoryWithConfig() {
ApplicationContext testContext = getTestApplicationContext(RabbitConnectionFactoryConfigWithServiceConfig.class, createService("my-service"));
ConnectionFactory connector = testContext.getBean("connectionFactoryWithConfig", getConnectorType());
RabbitConnectionFactoryCloudConfigTestHelper.assertConfigProperties(connector, 200, -1, -1);
}
use of org.springframework.amqp.rabbit.connection.ConnectionFactory in project spring-cloud-connectors by spring-cloud.
the class RabbitConnectionFactoryXmlConfigTest method cloudRabbitConnectionFactoryWithConfigurationAndProperties.
@Test
public void cloudRabbitConnectionFactoryWithConfigurationAndProperties() {
ApplicationContext testContext = getTestApplicationContext("cloud-rabbit-with-config.xml", createService("my-service"));
ConnectionFactory connector = testContext.getBean("service-channelCacheSize200-properties", getConnectorType());
RabbitConnectionFactoryCloudConfigTestHelper.assertConfigProperties(connector, 200, 5, 10);
}
Aggregations