Search in sources :

Example 6 with MongoServiceInfo

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

the class CloudTest method servicePropsMongoMultipleHostsUriString.

@Test
public void servicePropsMongoMultipleHostsUriString() {
    String serviceId = "my-mongo-multiple-hosts-uri";
    MongoServiceInfo mongoServiceInfo = createMongoServiceWithMultipleHostsByUri(serviceId);
    CloudConnector stubCloudConnector = getTestCloudConnector(mongoServiceInfo);
    Cloud testCloud = new Cloud(stubCloudConnector, serviceCreators);
    Properties cloudProperties = testCloud.getCloudProperties();
    assertMongoPropsWithMultipleHostsByUri("cloud.services.my-mongo-multiple-hosts-uri", mongoServiceInfo, cloudProperties);
    assertMongoPropsWithMultipleHostsByUri("cloud.services.mongo", mongoServiceInfo, cloudProperties);
}
Also used : CloudTestUtil.getTestCloudConnector(org.springframework.cloud.CloudTestUtil.getTestCloudConnector) Properties(java.util.Properties) MongoServiceInfo(org.springframework.cloud.service.common.MongoServiceInfo) Test(org.junit.Test)

Example 7 with MongoServiceInfo

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

the class LocalConfigServiceOverrideTest method serviceOverride.

@Test
public void serviceOverride() {
    env.setSystemProperty("spring.cloud.candygram", "mongodb://youruser:yourpass@40.30.20.10:4321/dbname");
    List<ServiceInfo> services = connector.getServiceInfos();
    ServiceInfo service = getServiceInfo(services, "candygram");
    assertNotNull(service);
    assertTrue(service instanceof MongoServiceInfo);
    MongoServiceInfo mongo = (MongoServiceInfo) service;
    assertEquals("youruser", mongo.getUserName());
    assertEquals(4321, mongo.getPort());
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) MongoServiceInfo(org.springframework.cloud.service.common.MongoServiceInfo) MongoServiceInfo(org.springframework.cloud.service.common.MongoServiceInfo) Test(org.junit.Test)

Example 8 with MongoServiceInfo

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

the class LocalConfigConnectorMongoServiceTest method serviceCreation.

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

Aggregations

MongoServiceInfo (org.springframework.cloud.service.common.MongoServiceInfo)8 Test (org.junit.Test)7 ServiceInfo (org.springframework.cloud.service.ServiceInfo)4 MongoClient (com.mongodb.MongoClient)2 MongoCredential (com.mongodb.MongoCredential)2 ServerAddress (com.mongodb.ServerAddress)2 Properties (java.util.Properties)2 CloudTestUtil.getTestCloudConnector (org.springframework.cloud.CloudTestUtil.getTestCloudConnector)2 MongoDbFactory (org.springframework.data.mongodb.MongoDbFactory)2 Mongobee (com.github.mongobee.Mongobee)1 HashMap (java.util.HashMap)1 CloudException (org.springframework.cloud.CloudException)1 MysqlServiceInfo (org.springframework.cloud.service.common.MysqlServiceInfo)1 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)1