Search in sources :

Example 21 with ServiceInfo

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);
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) PostgresqlServiceInfo(org.springframework.cloud.service.common.PostgresqlServiceInfo) Test(org.junit.Test)

Example 22 with ServiceInfo

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);
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) UriBasedServiceInfo(org.springframework.cloud.service.UriBasedServiceInfo)

Example 23 with ServiceInfo

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());
}
Also used : RelationalServiceInfo(org.springframework.cloud.service.common.RelationalServiceInfo) ServiceInfo(org.springframework.cloud.service.ServiceInfo) MongoServiceInfo(org.springframework.cloud.service.common.MongoServiceInfo) MysqlServiceInfo(org.springframework.cloud.service.common.MysqlServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) UriBasedServiceInfo(org.springframework.cloud.service.UriBasedServiceInfo) RedisServiceInfo(org.springframework.cloud.service.common.RedisServiceInfo) CloudTestUtil.getTestCloudConnector(org.springframework.cloud.CloudTestUtil.getTestCloudConnector) Test(org.junit.Test)

Example 24 with ServiceInfo

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());
}
Also used : RelationalServiceInfo(org.springframework.cloud.service.common.RelationalServiceInfo) ServiceInfo(org.springframework.cloud.service.ServiceInfo) MongoServiceInfo(org.springframework.cloud.service.common.MongoServiceInfo) MysqlServiceInfo(org.springframework.cloud.service.common.MysqlServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) UriBasedServiceInfo(org.springframework.cloud.service.UriBasedServiceInfo) RedisServiceInfo(org.springframework.cloud.service.common.RedisServiceInfo) MysqlDataSourceCreator(org.springframework.cloud.service.relational.MysqlDataSourceCreator) ServiceConnectorCreator(org.springframework.cloud.service.ServiceConnectorCreator) Before(org.junit.Before)

Example 25 with ServiceInfo

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");
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) MysqlServiceInfo(org.springframework.cloud.service.common.MysqlServiceInfo) MysqlServiceInfo(org.springframework.cloud.service.common.MysqlServiceInfo) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

ServiceInfo (org.springframework.cloud.service.ServiceInfo)47 Test (org.junit.Test)37 MysqlServiceInfo (org.springframework.cloud.service.common.MysqlServiceInfo)16 AmqpServiceInfo (org.springframework.cloud.service.common.AmqpServiceInfo)8 HashMap (java.util.HashMap)6 CompositeServiceInfo (org.springframework.cloud.service.CompositeServiceInfo)5 MongoServiceInfo (org.springframework.cloud.service.common.MongoServiceInfo)5 PostgresqlServiceInfo (org.springframework.cloud.service.common.PostgresqlServiceInfo)5 RedisServiceInfo (org.springframework.cloud.service.common.RedisServiceInfo)4 ArrayList (java.util.ArrayList)3 UriBasedServiceInfo (org.springframework.cloud.service.UriBasedServiceInfo)3 DB2ServiceInfo (org.springframework.cloud.service.common.DB2ServiceInfo)3 OracleServiceInfo (org.springframework.cloud.service.common.OracleServiceInfo)3 SqlServerServiceInfo (org.springframework.cloud.service.common.SqlServerServiceInfo)3 StubCloudConnector (org.springframework.cloud.CloudTestUtil.StubCloudConnector)2 StubCompositeServiceInfo (org.springframework.cloud.CloudTestUtil.StubCompositeServiceInfo)2 StubServiceInfo (org.springframework.cloud.CloudTestUtil.StubServiceInfo)2 BaseServiceInfo (org.springframework.cloud.service.BaseServiceInfo)2 RelationalServiceInfo (org.springframework.cloud.service.common.RelationalServiceInfo)2 SmtpServiceInfo (org.springframework.cloud.service.common.SmtpServiceInfo)2