@Test public void testFromSystem() { env.setSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY, PROPERTIES_FILE_NAME); assertEquals(PROPERTIES_FILE_NAME, resolver.findCloudPropertiesFile().getPath()); }
@Test public void testSystemProperty() { env.setSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY, PROPERTIES_FILE_NAME); assertEquals(PROPERTIES_FILE_NAME, resolver.findCloudPropertiesFileFromSystem().getPath()); }
@Before public void useTestUris() { InputStream testUrisProperties = getClass().getClassLoader().getResourceAsStream(PROPERTY_FILE_WITH_URIS); env.setSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY, PROPERTY_FILE_WITH_URIS); connector.setFileProvider(StubbedOpenFileLocalConfigConnector.fileContentsFromStream(PROPERTY_FILE_WITH_URIS, testUrisProperties)); assertTrue(connector.isInMatchingCloud()); } }
@Test public void testPrecedence() { env.setSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY, PROPERTIES_FILE_NAME); resolver = new PropertiesFileResolver(env, "spring-cloud-literal.properties"); assertEquals(PROPERTIES_FILE_NAME, resolver.findCloudPropertiesFile().getPath()); } }
@Test public void testTemplate() { resolver = new PropertiesFileResolver(env, "spring-cloud-template.properties"); env.setSystemProperty("user.home", "/foo"); assertEquals(PROPERTIES_FILE_NAME, resolver.findCloudPropertiesFileFromClasspath().getPath()); }
@Test public void testFromClasspath() { resolver = new PropertiesFileResolver(env, "spring-cloud-template.properties"); env.setSystemProperty("user.home", "/foo"); assertEquals(PROPERTIES_FILE_NAME, resolver.findCloudPropertiesFile().getPath()); }
@Before public void init() throws IOException { env = new PassthroughEnvironmentAccessor(); env.setSystemProperty("spring.cloud.baz", "inline!"); connector.setEnvironmentAccessor(env); }
@Test public void testAppIdInFileAndSystem() throws IOException { env.setSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY, PROPERTY_FILE_NAME); env.setSystemProperty(LocalConfigConnector.APP_ID_PROPERTY, APP_ID); connector.setFileProvider(StubbedOpenFileLocalConfigConnector.fileContentsFromString(PROPERTY_FILE_NAME, APP_ID_PROPERTY)); assertTrue(connector.isInMatchingCloud()); assertEquals(APP_ID, connector.getApplicationInstanceInfo().getAppId()); } }
@Test public void testAppIdInConfigFile() throws IOException { env.setSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY, PROPERTY_FILE_NAME); connector.setFileProvider(StubbedOpenFileLocalConfigConnector.fileContentsFromString(PROPERTY_FILE_NAME, APP_ID_PROPERTY)); assertTrue(connector.isInMatchingCloud()); assertEquals(APP_ID, connector.getApplicationInstanceInfo().getAppId()); }
@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()); } }