Search in sources :

Example 11 with ServiceInfo

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

Example 12 with ServiceInfo

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

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

Example 14 with ServiceInfo

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());
}
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 15 with ServiceInfo

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));
}
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)

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