@Override protected List<UriBasedServiceData> getServicesData() { if (fileProperties == null) throw new IllegalStateException("isInMatchingCloud() must be called first to initialize connector"); LinkedHashMap<String, Properties> propertySources = new LinkedHashMap<String, Properties>(); propertySources.put("properties from file", fileProperties); try { propertySources.put("system properties", env.getSystemProperties()); } catch (SecurityException e) { logger.log(Level.WARNING, "couldn't read system properties; no service definitions from system properties will be applied", e); } return LocalConfigUtil.readServicesData(propertySources); }
@Override protected List<UriBasedServiceData> getServicesData() { if (fileProperties == null) throw new IllegalStateException("isInMatchingCloud() must be called first to initialize connector"); LinkedHashMap<String, Properties> propertySources = new LinkedHashMap<String, Properties>(); propertySources.put("properties from file", fileProperties); try { propertySources.put("system properties", env.getSystemProperties()); } catch (SecurityException e) { logger.log(Level.WARNING, "couldn't read system properties; no service definitions from system properties will be applied", e); } return LocalConfigUtil.readServicesData(propertySources); }
@Test public void testOverride() { first.setProperty("spring.cloud.duplicate", "firstUri"); second.setProperty("spring.cloud.duplicate", "secondUri"); List<UriBasedServiceData> serviceData = LocalConfigUtil.readServicesData(propertySources); assertEquals(1, serviceData.size()); UriBasedServiceData kvp = serviceData.get(0); assertEquals("duplicate", kvp.getKey()); assertEquals("secondUri", kvp.getUri()); } }
@Test public void testCollation() { first.setProperty("spring.cloud.first", "firstUri"); second.setProperty("spring.cloud.second", "secondUri"); List<UriBasedServiceData> serviceData = LocalConfigUtil.readServicesData(propertySources); assertEquals(2, serviceData.size()); boolean foundFirst = false; for (UriBasedServiceData kvp : serviceData) { if (kvp.getKey().equals("first")) { assertEquals("firstUri", kvp.getUri()); foundFirst = true; } } assertTrue(foundFirst); }