use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudFoundryConnectorAmqpServiceTest method rabbitServiceCreationMultipleUris.
@Test
public void rabbitServiceCreationMultipleUris() {
when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getRabbitServicePayloadMultipleUris("rabbit-1", hostname, hostname2, port, username, password, "q-1", "vhost1"), getRabbitServicePayloadMultipleUris("rabbit-2", hostname, hostname2, port, username, password, "q-2", "vhost2")));
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class);
assertServiceFoundOfType(serviceInfos, "rabbit-2", AmqpServiceInfo.class);
AmqpServiceInfo amqpServiceInfo = (AmqpServiceInfo) serviceInfos.get(0);
assertNotNull(amqpServiceInfo.getUri());
assertTrue(amqpServiceInfo.getUri().contains(hostname));
assertNotNull(amqpServiceInfo.getManagementUri());
assertTrue(amqpServiceInfo.getManagementUri().contains(hostname));
assertNotNull(amqpServiceInfo.getUris());
assertEquals(2, amqpServiceInfo.getUris().size());
assertTrue(amqpServiceInfo.getUris().get(0).contains(hostname));
assertTrue(amqpServiceInfo.getUris().get(1).contains(hostname2));
assertNotNull(amqpServiceInfo.getManagementUris());
assertEquals(2, amqpServiceInfo.getManagementUris().size());
assertTrue(amqpServiceInfo.getManagementUris().get(0).contains(hostname));
assertTrue(amqpServiceInfo.getManagementUris().get(1).contains(hostname2));
}
use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudFoundryConnectorAmqpServiceTest method rabbitServiceCreationWithManagementUri.
@Test
public void rabbitServiceCreationWithManagementUri() {
when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getRabbitServicePayloadWithTags("rabbit-1", hostname, port, username, password, "q-1", "vhost1")));
String expectedManagementUri = "http://" + username + ":" + password + "@" + hostname + "/api";
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class);
AmqpServiceInfo amqpServiceInfo = (AmqpServiceInfo) serviceInfos.get(0);
assertEquals(amqpServiceInfo.getManagementUri(), expectedManagementUri);
}
use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.
the class RabbitConnectionFactoryCreatorTest method cloudRabbitCreationNoUri.
@Test
public void cloudRabbitCreationNoUri() throws Exception {
AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", TEST_HOST, TEST_PORT, TEST_USERNAME, TEST_PASSWORD, TEST_VH);
ConnectionFactory connector = testCreator.create(serviceInfo, null);
assertConnectorPropertiesMatchUri(connector, serviceInfo.getUri());
}
use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.
the class RabbitServiceInfoTest method uriBasedParsingDefaultVhost.
@Test
public void uriBasedParsingDefaultVhost() {
AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", "amqp://myuser:mypass@myhost:12345/");
assertEquals("myhost", serviceInfo.getHost());
assertEquals(12345, serviceInfo.getPort());
assertEquals("myuser", serviceInfo.getUserName());
assertEquals("mypass", serviceInfo.getPassword());
assertNull(serviceInfo.getVirtualHost());
}
use of org.springframework.cloud.service.common.AmqpServiceInfo in project spring-cloud-connectors by spring-cloud.
the class RabbitServiceInfoTest method uriBasedParsing.
@Test
public void uriBasedParsing() {
AmqpServiceInfo serviceInfo = new AmqpServiceInfo("id", "amqp://myuser:mypass@myhost:12345/myvhost");
assertEquals("myhost", serviceInfo.getHost());
assertEquals(12345, serviceInfo.getPort());
assertEquals("myuser", serviceInfo.getUserName());
assertEquals("mypass", serviceInfo.getPassword());
assertEquals("myvhost", serviceInfo.getVirtualHost());
}
Aggregations