Add test to override programmatic definition from system properties.

fixes #45
This commit is contained in:
Christopher Smith
2014-07-11 16:41:18 -05:00
parent 14272c8b10
commit c42a8e3ba7

View File

@@ -0,0 +1,34 @@
package org.springframework.cloud.localconfig;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.ProvideSystemProperty;
import org.springframework.cloud.service.ServiceInfo;
import org.springframework.cloud.service.common.MongoServiceInfo;
public class LocalConfigServiceOverrideTest extends AbstractLocalConfigConnectorTest {
@Rule
public final ProvideSystemProperty OVERRIDE_MYSQL =
new ProvideSystemProperty(
"spring.cloud.candygram",
"mongodb://youruser:yourpass@40.30.20.10:4321/dbname");
@Test
public void serviceOverride() {
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());
}
}