@Test public void shouldReadFromFile() throws Exception { final ClassPathManifestInfoProvider provider = new ClassPathManifestInfoProvider("/git.properties", "source1"); final ManifestInfo manifestInfo = provider.getManifestInfo(); assertEquals("1.0.0", manifestInfo.getVersionId()); assertEquals("abcd1234", manifestInfo.getBuildId()); }
@Override public ManifestInfo getManifestInfo() { final Properties properties = new Properties(); final InputStream gitProperties = ClassPathManifestInfoProvider.class.getResourceAsStream(resource); if (gitProperties != null) { try { properties.load(gitProperties); } catch (IOException e) { LOGGER.debug("Unable to read from resource '{}'.", resource, e); } } else { LOGGER.debug("Resource '{}' does not exist.", resource); } final String versionId = Optional.ofNullable(properties.getProperty("git.build.version")).orElse("N/A"); final String buildId = Optional.ofNullable(properties.getProperty("git.commit.id.abbrev")).orElse("N/A"); return new ManifestInfo(versionId, buildId); }
ClassPathManifestInfoProvider implements ManifestInfoProvider { @Override public ManifestInfo getManifestInfo() { final Properties properties = new Properties(); final InputStream gitProperties = ClassPathManifestInfoProvider.class.getResourceAsStream(resource); if (gitProperties != null) { try { properties.load(gitProperties); } catch (IOException e) { LOGGER.debug("Unable to read from resource '{}'.", resource, e); } } else { LOGGER.debug("Resource '{}' does not exist.", resource); } final String versionId = Optional.ofNullable(properties.getProperty("git.build.version")).orElse("N/A"); final String buildId = Optional.ofNullable(properties.getProperty("git.commit.id.abbrev")).orElse("N/A"); return new ManifestInfo(versionId, buildId); } }
ClassPathManifestInfoProvider implements ManifestInfoProvider { @Override public ManifestInfo getManifestInfo() { final Properties properties = new Properties(); final InputStream gitProperties = ClassPathManifestInfoProvider.class.getResourceAsStream(resource); if (gitProperties != null) { try { properties.load(gitProperties); } catch (IOException e) { LOGGER.debug("Unable to read from resource '{}'.", resource, e); } } else { LOGGER.debug("Resource '{}' does not exist.", resource); } final String versionId = Optional.ofNullable(properties.getProperty("git.build.version")).orElse("N/A"); final String buildId = Optional.ofNullable(properties.getProperty("git.commit.id.abbrev")).orElse("N/A"); return new ManifestInfo(versionId, buildId); } ClassPathManifestInfoProvider(String resource, String name); }
ClassPathManifestInfoProvider implements ManifestInfoProvider { @Override public ManifestInfo getManifestInfo() { final Properties properties = new Properties(); final InputStream gitProperties = ClassPathManifestInfoProvider.class.getResourceAsStream(resource); if (gitProperties != null) { try { properties.load(gitProperties); } catch (IOException e) { LOGGER.debug("Unable to read from resource '{}'.", resource, e); } } else { LOGGER.debug("Resource '{}' does not exist.", resource); } final String versionId = Optional.ofNullable(properties.getProperty("git.build.version")).orElse("N/A"); final String buildId = Optional.ofNullable(properties.getProperty("git.commit.id.abbrev")).orElse("N/A"); return new ManifestInfo(versionId, buildId); } ClassPathManifestInfoProvider(String resource, String name); @Override String getName(); @Override ManifestInfo getManifestInfo(); }
ClassPathManifestInfoProvider implements ManifestInfoProvider { @Override public ManifestInfo getManifestInfo() { final Properties properties = new Properties(); final InputStream gitProperties = ClassPathManifestInfoProvider.class.getResourceAsStream(resource); if (gitProperties != null) { try { properties.load(gitProperties); } catch (IOException e) { LOGGER.debug("Unable to read from resource '{}'.", resource, e); } } else { LOGGER.debug("Resource '{}' does not exist.", resource); } final String versionId = Optional.ofNullable(properties.getProperty("git.build.version")).orElse("N/A"); final String buildId = Optional.ofNullable(properties.getProperty("git.commit.id.abbrev")).orElse("N/A"); return new ManifestInfo(versionId, buildId); } ClassPathManifestInfoProvider(String resource, String name); @Override String getName(); @Override ManifestInfo getManifestInfo();  }