@Test @SuppressWarnings("unchecked") public void testCreateCombinedConfiguration_optionalUrlNotFound() throws Exception { test1Properties.forEach(System::setProperty); System.setProperty("testProperty", "testValue"); Configuration configuration = configurationHelper.createCombinedConfiguration(null, Lists.<ConfigurationInfo<URL>>newArrayList(new ConfigurationInfo<URL>( new URL("file: assertEquals("efgh", configuration.getString("a.b.c")); assertEquals("1234", configuration.getString("a.b.d")); assertEquals("testValue", configuration.getString("testProperty")); }
public CombinedConfiguration createCombinedConfiguration( @Nullable List<ConfigurationInfo<String>> paths, @Nullable List<ConfigurationInfo<URL>> urls) throws ConfigurationLoadException { CombinedConfiguration combinedConfiguration = setupConfiguration(new CombinedConfiguration(new OverrideCombiner())); addConfiguration(combinedConfiguration, fromSystem()); if (paths != null) { for (ConfigurationInfo<String> path : paths) { if (path != null && path.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(path.getLocation())); } catch (ConfigurationLoadException e) { if (!path.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Could not load optional configuration: " + path); } } } } } if (urls != null) { for (ConfigurationInfo<URL> url : urls) { if (url != null && url.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(url.getLocation())); } catch (ConfigurationLoadException e) { if (!url.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Did not load optional configuration" + url.getLocation() + ":", e); } } } } } return combinedConfiguration; }
ConfigurationHelper { public CombinedConfiguration createCombinedConfiguration( @Nullable List<ConfigurationInfo<String>> paths, @Nullable List<ConfigurationInfo<URL>> urls) throws ConfigurationLoadException { CombinedConfiguration combinedConfiguration = setupConfiguration(new CombinedConfiguration(new OverrideCombiner())); addConfiguration(combinedConfiguration, fromSystem()); if (paths != null) { for (ConfigurationInfo<String> path : paths) { if (path != null && path.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(path.getLocation())); } catch (ConfigurationLoadException e) { if (!path.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Could not load optional configuration: " + path); } } } } } if (urls != null) { for (ConfigurationInfo<URL> url : urls) { if (url != null && url.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(url.getLocation())); } catch (ConfigurationLoadException e) { if (!url.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Did not load optional configuration" + url.getLocation() + ":", e); } } } } } return combinedConfiguration; } }
ConfigurationHelper { public CombinedConfiguration createCombinedConfiguration( @Nullable List<ConfigurationInfo<String>> paths, @Nullable List<ConfigurationInfo<URL>> urls) throws ConfigurationLoadException { CombinedConfiguration combinedConfiguration = setupConfiguration(new CombinedConfiguration(new OverrideCombiner())); addConfiguration(combinedConfiguration, fromSystem()); if (paths != null) { for (ConfigurationInfo<String> path : paths) { if (path != null && path.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(path.getLocation())); } catch (ConfigurationLoadException e) { if (!path.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Could not load optional configuration: " + path); } } } } } if (urls != null) { for (ConfigurationInfo<URL> url : urls) { if (url != null && url.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(url.getLocation())); } catch (ConfigurationLoadException e) { if (!url.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Did not load optional configuration" + url.getLocation() + ":", e); } } } } } return combinedConfiguration; }  }
ConfigurationHelper { public CombinedConfiguration createCombinedConfiguration( @Nullable List<ConfigurationInfo<String>> paths, @Nullable List<ConfigurationInfo<URL>> urls) throws ConfigurationLoadException { CombinedConfiguration combinedConfiguration = setupConfiguration(new CombinedConfiguration(new OverrideCombiner())); addConfiguration(combinedConfiguration, fromSystem()); if (paths != null) { for (ConfigurationInfo<String> path : paths) { if (path != null && path.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(path.getLocation())); } catch (ConfigurationLoadException e) { if (!path.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Could not load optional configuration: " + path); } } } } } if (urls != null) { for (ConfigurationInfo<URL> url : urls) { if (url != null && url.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(url.getLocation())); } catch (ConfigurationLoadException e) { if (!url.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Did not load optional configuration" + url.getLocation() + ":", e); } } } } } return combinedConfiguration; }  Configuration fromFile(String path); Configuration fromFile(File path); Configuration fromFile(URL path); Configuration fromSystem(); CombinedConfiguration createCombinedConfiguration(
      @Nullable List<ConfigurationInfo<String>> paths,
      @Nullable List<ConfigurationInfo<URL>> urls); static List<ConfigurationInfo<T>> newList(@Nullable List<T> locations,
      final boolean isOptional); static List<ConfigurationInfo<T>> newList(boolean isOptional, T location); }
ConfigurationHelper { public CombinedConfiguration createCombinedConfiguration( @Nullable List<ConfigurationInfo<String>> paths, @Nullable List<ConfigurationInfo<URL>> urls) throws ConfigurationLoadException { CombinedConfiguration combinedConfiguration = setupConfiguration(new CombinedConfiguration(new OverrideCombiner())); addConfiguration(combinedConfiguration, fromSystem()); if (paths != null) { for (ConfigurationInfo<String> path : paths) { if (path != null && path.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(path.getLocation())); } catch (ConfigurationLoadException e) { if (!path.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Could not load optional configuration: " + path); } } } } } if (urls != null) { for (ConfigurationInfo<URL> url : urls) { if (url != null && url.getLocation() != null) { try { addConfiguration(combinedConfiguration, fromFile(url.getLocation())); } catch (ConfigurationLoadException e) { if (!url.isOptional) { throw e; } else { AdsServiceLoggers.ADS_API_LIB_LOG.debug( "Did not load optional configuration" + url.getLocation() + ":", e); } } } } } return combinedConfiguration; }  Configuration fromFile(String path); Configuration fromFile(File path); Configuration fromFile(URL path); Configuration fromSystem(); CombinedConfiguration createCombinedConfiguration(
      @Nullable List<ConfigurationInfo<String>> paths,
      @Nullable List<ConfigurationInfo<URL>> urls); static List<ConfigurationInfo<T>> newList(@Nullable List<T> locations,
      final boolean isOptional); static List<ConfigurationInfo<T>> newList(boolean isOptional, T location);  }