Search in sources :

Example 26 with ServiceInfo

use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.

the class HerokuConnectorPostgresqlServiceTest method assertPostgresServiceCreated.

private void assertPostgresServiceCreated(String envVarName, String serviceInstanceName) {
    Map<String, String> env = new HashMap<String, String>();
    String postgresUrl = getRelationalServiceUrl("db");
    env.put(envVarName, postgresUrl);
    when(mockEnvironment.getEnv()).thenReturn(env);
    List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
    ServiceInfo serviceInfo = getServiceInfo(serviceInfos, serviceInstanceName);
    assertNotNull(serviceInfo);
    assertTrue(serviceInfo instanceof PostgresqlServiceInfo);
    assertReleationServiceInfo((PostgresqlServiceInfo) serviceInfo, "db");
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) PostgresqlServiceInfo(org.springframework.cloud.service.common.PostgresqlServiceInfo) HashMap(java.util.HashMap) PostgresqlServiceInfo(org.springframework.cloud.service.common.PostgresqlServiceInfo)

Example 27 with ServiceInfo

use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.

the class LocalConfigConnectorAmqpServiceTest method serviceCreation.

@Test
public void serviceCreation() {
    List<ServiceInfo> services = connector.getServiceInfos();
    ServiceInfo service = getServiceInfo(services, "rabbit");
    assertNotNull(service);
    assertTrue(service instanceof AmqpServiceInfo);
    assertUriParameters((AmqpServiceInfo) service);
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) AmqpServiceInfo(org.springframework.cloud.service.common.AmqpServiceInfo) Test(org.junit.Test)

Example 28 with ServiceInfo

use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CloudFoundryConnectorPostgresqlServiceTest method postgresqlServiceCreation.

@Test
public void postgresqlServiceCreation() {
    String name1 = "database-1";
    String name2 = "database-2";
    when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getPostgresqlServicePayload("postgresql-1", hostname, port, username, password, name1), getPostgresqlServicePayload("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 29 with ServiceInfo

use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CloudFoundryConnectorSmtpServiceTest method smtpServiceCreationWithUri.

@Test
public void smtpServiceCreationWithUri() {
    when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getSmtpServicePayloadWithUri("smtp-1", hostname, port, username, password)));
    List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
    SmtpServiceInfo smtpServiceInfo = (SmtpServiceInfo) getServiceInfo(serviceInfos, "smtp-1");
    assertNotNull(smtpServiceInfo);
    assertEquals(hostname, smtpServiceInfo.getHost());
    assertEquals(port, smtpServiceInfo.getPort());
    assertEquals(username, smtpServiceInfo.getUserName());
    assertEquals(password, smtpServiceInfo.getPassword());
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) SmtpServiceInfo(org.springframework.cloud.service.common.SmtpServiceInfo) SmtpServiceInfo(org.springframework.cloud.service.common.SmtpServiceInfo) Test(org.junit.Test)

Example 30 with ServiceInfo

use of org.springframework.cloud.service.ServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CloudFoundryConnectorSqlServerServiceTest method sqlServerServiceCreationWithNoUri.

@Test
public void sqlServerServiceCreationWithNoUri() {
    when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn(getServicesPayload(getUserProvidedServicePayloadWithNoUri(SERVICE_NAME, hostname, port, username, password, INSTANCE_NAME)));
    List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
    ServiceInfo info = getServiceInfo(serviceInfos, SERVICE_NAME);
    assertNotNull(info);
    // service was not detected as SQL-Server
    assertFalse(SqlServerServiceInfo.class.isAssignableFrom(info.getClass()));
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) SqlServerServiceInfo(org.springframework.cloud.service.common.SqlServerServiceInfo) SqlServerServiceInfo(org.springframework.cloud.service.common.SqlServerServiceInfo) 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