@Test public void testLoadNotExists() { ClasspathOverrideSource overrideSource = OverrideSources.classpath("application.unknown") .build(); assertThat(overrideSource.load(), is(Optional.empty())); }
@Override public Optional<OverrideContent> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } OverrideData data = OverrideData.create(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); return Optional.of(OverrideContent.builder() .data(data) .build()); }
ClasspathOverrideSource extends AbstractSource implements OverrideSource { @Override public Optional<OverrideContent> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } OverrideData data = OverrideData.create(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); return Optional.of(OverrideContent.builder() .data(data) .build()); } }
ClasspathOverrideSource extends AbstractSource implements OverrideSource { @Override public Optional<OverrideContent> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } OverrideData data = OverrideData.create(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); return Optional.of(OverrideContent.builder() .data(data) .build()); } ClasspathOverrideSource(Builder builder); }
ClasspathOverrideSource extends AbstractSource implements OverrideSource { @Override public Optional<OverrideContent> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } OverrideData data = OverrideData.create(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); return Optional.of(OverrideContent.builder() .data(data) .build()); } ClasspathOverrideSource(Builder builder); @Override Optional<OverrideContent> load(); static ClasspathOverrideSource create(Config config); static Builder builder(); }
ClasspathOverrideSource extends AbstractSource implements OverrideSource { @Override public Optional<OverrideContent> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } OverrideData data = OverrideData.create(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); return Optional.of(OverrideContent.builder() .data(data) .build()); } ClasspathOverrideSource(Builder builder); @Override Optional<OverrideContent> load(); static ClasspathOverrideSource create(Config config); static Builder builder();  }