LegacyMetaServerProvider implements MetaServerProvider { private String getMetaServerAddress(Properties prop, String sourceName, String propName) { String metaAddress = System.getProperty(sourceName); if (Strings.isNullOrEmpty(metaAddress)) { metaAddress = System.getenv(sourceName.toUpperCase()); } if (Strings.isNullOrEmpty(metaAddress)) { metaAddress = prop.getProperty(propName); } return metaAddress; } LegacyMetaServerProvider(); @Override String getMetaServerAddress(Env targetEnv); @Override int getOrder(); static final int ORDER; }
@Test public void testFromPropertyFile() { LegacyMetaServerProvider legacyMetaServerProvider = new LegacyMetaServerProvider(); assertEquals("http: assertEquals("http: assertEquals(null, legacyMetaServerProvider.getMetaServerAddress(Env.PRO)); }
@Test public void testWithSystemProperty() throws Exception { String someDevMetaAddress = "someMetaAddress"; String someFatMetaAddress = "someFatMetaAddress"; System.setProperty("dev_meta", someDevMetaAddress); System.setProperty("fat_meta", someFatMetaAddress); LegacyMetaServerProvider legacyMetaServerProvider = new LegacyMetaServerProvider(); assertEquals(someDevMetaAddress, legacyMetaServerProvider.getMetaServerAddress(Env.DEV)); assertEquals(someFatMetaAddress, legacyMetaServerProvider.getMetaServerAddress(Env.FAT)); }