use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudFoundryConnectorPostgresqlServiceTest method postgresqlServiceCreationWithJdbcUrl.
@Test
public void postgresqlServiceCreationWithJdbcUrl() {
String name1 = "database-1";
String name2 = "database-2";
when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getPostgresqlServicePayloadWithJdbcUrl("postgresql-1", hostname, port, username, password, name1), getPostgresqlServicePayloadWithJdbcUrl("postgresql-2", hostname, port, username, password, name2)));
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
ServiceInfo info1 = getServiceInfo(serviceInfos, "postgresql-1");
ServiceInfo info2 = getServiceInfo(serviceInfos, "postgresql-2");
assertServiceFoundOfType(info1, PostgresqlServiceInfo.class);
assertServiceFoundOfType(info2, PostgresqlServiceInfo.class);
assertJdbcUrlEqual(info1, POSTGRES_SCHEME, name1);
assertJdbcUrlEqual(info2, POSTGRES_SCHEME, name2);
assertUriBasedServiceInfoFields(info1, POSTGRES_SCHEME, hostname, port, username, password, name1);
assertUriBasedServiceInfoFields(info2, POSTGRES_SCHEME, hostname, port, username, password, name2);
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudFoundryConnectorSmtpServiceTest method smtpServiceCreation.
@Test
public void smtpServiceCreation() {
when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getSmtpServicePayload("smtp-1", hostname, username, password)));
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
SmtpServiceInfo smtpServiceInfo = (SmtpServiceInfo) getServiceInfo(serviceInfos, "smtp-1");
assertNotNull(smtpServiceInfo);
assertEquals(hostname, smtpServiceInfo.getHost());
assertEquals(587, smtpServiceInfo.getPort());
assertEquals(username, smtpServiceInfo.getUserName());
assertEquals(password, smtpServiceInfo.getPassword());
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudFoundryConnectorSqlServerServiceTest method sqlServerServiceCreationWithJdbcUrl.
@Test
public void sqlServerServiceCreationWithJdbcUrl() {
when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getSqlServerServicePayloadWithJdbcurl(SERVICE_NAME, hostname, port, username, password, INSTANCE_NAME, SQLSERVER_SCHEME + ":")));
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
ServiceInfo info = getServiceInfo(serviceInfos, SERVICE_NAME);
assertServiceFoundOfType(info, SqlServerServiceInfo.class);
assertJdbcUrlEqual(info, SQLSERVER_SCHEME, INSTANCE_NAME);
assertUriBasedServiceInfoFields(info, SQLSERVER_SCHEME, hostname, port, username, password, INSTANCE_NAME);
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class AbstractCloudConnector method getServiceInfo.
private ServiceInfo getServiceInfo(SD serviceData) {
for (ServiceInfoCreator<? extends ServiceInfo, SD> serviceInfoCreator : serviceInfoCreators) {
if (serviceInfoCreator.accept(serviceData)) {
return serviceInfoCreator.createServiceInfo(serviceData);
}
}
// Fallback with a warning
ServiceInfo fallackServiceInfo = getFallbackServiceInfoCreator().createServiceInfo(serviceData);
logger.warning("No suitable service info creator found for service " + fallackServiceInfo.getId() + " Did you forget to add a ServiceInfoCreator?");
return fallackServiceInfo;
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class ServiceConnectorCreatorRegistry method getServiceLabel.
private static String getServiceLabel(ServiceInfo serviceInfo) {
Class<? extends ServiceInfo> serviceInfoClass = serviceInfo.getClass();
ServiceLabel labelAnnotation = serviceInfoClass.getAnnotation(ServiceInfo.ServiceLabel.class);
if (labelAnnotation == null) {
return null;
} else {
return labelAnnotation.value();
}
}
Aggregations