use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class HerokuConnectorMongoServiceTest method mongoServiceCreation.
@Test
public void mongoServiceCreation() {
for (String mongoEnv : new String[] { "MONGOLAB_URI", "MONGOHQ_URL", "MONGOSOUP_URL" }) {
Map<String, String> env = new HashMap<String, String>();
String mongoUrl = getMongoServiceUrl("db");
env.put(mongoEnv, mongoUrl);
when(mockEnvironment.getEnv()).thenReturn(env);
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
ServiceInfo serviceInfo = getServiceInfo(serviceInfos, mongoEnv.substring(0, mongoEnv.length() - 4));
assertNotNull(serviceInfo);
assertTrue(serviceInfo instanceof MongoServiceInfo);
assertMongoServiceInfo((MongoServiceInfo) serviceInfo, "db");
}
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class HerokuConnectorRedisServiceTest method redisServiceCreation.
@Test
public void redisServiceCreation() {
for (String redisEnv : new String[] { "REDISTOGO_URL", "REDISCLOUD_URL", "OPENREDIS_URL", "REDISGREEN_URL", "REDIS_URL" }) {
Map<String, String> env = new HashMap<String, String>();
String redisUrl = getRedisServiceUrl();
env.put(redisEnv, redisUrl);
when(mockEnvironment.getEnv()).thenReturn(env);
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
ServiceInfo serviceInfo = getServiceInfo(serviceInfos, redisEnv.substring(0, redisEnv.length() - 4));
assertNotNull(serviceInfo);
assertTrue(serviceInfo instanceof RedisServiceInfo);
assertRedisServiceInfo((RedisServiceInfo) serviceInfo);
}
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class HerokuConnectorAmqpServiceTest method amqpServiceCreation.
@Test
public void amqpServiceCreation() {
Map<String, String> env = new HashMap<String, String>();
String amqpUrl = getAmqpServiceUrl("db");
env.put("CLOUDAMQP_URL", amqpUrl);
when(mockEnvironment.getEnv()).thenReturn(env);
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
ServiceInfo serviceInfo = getServiceInfo(serviceInfos, "CLOUDAMQP");
assertNotNull(serviceInfo);
assertTrue(serviceInfo instanceof AmqpServiceInfo);
assertAmqpServiceInfo((AmqpServiceInfo) serviceInfo, "db");
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudFoundryConnectorAmqpServiceTest method rabbitServiceCreationWithoutManagementUri.
@Test
public void rabbitServiceCreationWithoutManagementUri() {
when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getRabbitServicePayloadNoLabelNoTags("rabbit-1", hostname, port, username, password, "q-1", "vhost1")));
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
assertServiceFoundOfType(serviceInfos, "rabbit-1", AmqpServiceInfo.class);
AmqpServiceInfo amqpServiceInfo = (AmqpServiceInfo) serviceInfos.get(0);
assertNull(amqpServiceInfo.getManagementUri());
}
use of org.springframework.cloud.service.ServiceInfo 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));
}
Aggregations