use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudFoundryConnectorPostgresqlServiceTest method postgresqlServiceCreationNoLabelNoTags.
@Test
public void postgresqlServiceCreationNoLabelNoTags() {
String name1 = "database-1";
String name2 = "database-2";
when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getPostgresqlServicePayloadNoLabelNoTags("postgresql-1", hostname, port, username, password, name1), getPostgresqlServicePayloadNoLabelNoTags("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 AbstractCloudFoundryConnectorTest method assertServiceFoundOfType.
protected static void assertServiceFoundOfType(List<ServiceInfo> serviceInfos, String serviceId, Class<? extends ServiceInfo> type) {
ServiceInfo serviceInfo = getServiceInfo(serviceInfos, serviceId);
assertServiceFoundOfType(serviceInfo, type);
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudTest method serviceInfosForConnectorType.
@Test
public void serviceInfosForConnectorType() {
String serviceId = "mysql-db";
CloudConnector stubCloudConnector = getTestCloudConnector(createMysqlService(serviceId));
Cloud testCloud = new Cloud(stubCloudConnector, serviceCreators);
List<ServiceInfo> serviceInfos = testCloud.getServiceInfos(DataSource.class);
assertEquals(1, serviceInfos.size());
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class CloudTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
serviceCreators = new ArrayList<ServiceConnectorCreator<?, ? extends ServiceInfo>>();
serviceCreators.add(new MysqlDataSourceCreator());
}
use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.
the class HerokuConnectorMysqlServiceTest method mysqlServiceCreation.
@Test
public void mysqlServiceCreation() {
Map<String, String> env = new HashMap<String, String>();
String mysqlUrl = getRelationalServiceUrl("db");
env.put("CLEARDB_DATABASE_URL", mysqlUrl);
when(mockEnvironment.getEnv()).thenReturn(env);
List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
ServiceInfo serviceInfo = getServiceInfo(serviceInfos, "CLEARDB_DATABASE");
assertNotNull(serviceInfo);
assertTrue(serviceInfo instanceof MysqlServiceInfo);
assertReleationServiceInfo((MysqlServiceInfo) serviceInfo, "db");
}
Aggregations