@Test public void testMissingFile() throws Throwable { try { final Version version = new Version(); version.MODULE_PROPERTIES = "foo.bar"; final String result = version.getVersion(); fail("did not get exception, got " + result); } catch (RuntimeException e) { try { throw(e.getCause()); } catch (FileNotFoundException e2) { } } }
public String getVersion() { return Util.execute(new ExceptionAction<String>() { @Override public String doAction() throws IOException { final URL resource = Version.class.getClassLoader().getResource(MODULE_PROPERTIES); if (resource == null) { throw new FileNotFoundException("Could not find internal resource " + MODULE_PROPERTIES); } final Reader reader = new InputStreamReader( resource.openStream(), "UTF-8"); try { final Properties properties = new Properties(); properties.load(reader); final String property = properties.getProperty(MODULE_VERSION); return property == null ? "unknown version, could not find property " + MODULE_VERSION + " in " + MODULE_PROPERTIES : property; } finally { reader.close(); } } }); }
Version { public String getVersion() { return Util.execute(new ExceptionAction<String>() { @Override public String doAction() throws IOException { final URL resource = Version.class.getClassLoader().getResource(MODULE_PROPERTIES); if (resource == null) { throw new FileNotFoundException("Could not find internal resource " + MODULE_PROPERTIES); } final Reader reader = new InputStreamReader( resource.openStream(), "UTF-8"); try { final Properties properties = new Properties(); properties.load(reader); final String property = properties.getProperty(MODULE_VERSION); return property == null ? "unknown version, could not find property " + MODULE_VERSION + " in " + MODULE_PROPERTIES : property; } finally { reader.close(); } } }); } }
Version { public String getVersion() { return Util.execute(new ExceptionAction<String>() { @Override public String doAction() throws IOException { final URL resource = Version.class.getClassLoader().getResource(MODULE_PROPERTIES); if (resource == null) { throw new FileNotFoundException("Could not find internal resource " + MODULE_PROPERTIES); } final Reader reader = new InputStreamReader( resource.openStream(), "UTF-8"); try { final Properties properties = new Properties(); properties.load(reader); final String property = properties.getProperty(MODULE_VERSION); return property == null ? "unknown version, could not find property " + MODULE_VERSION + " in " + MODULE_PROPERTIES : property; } finally { reader.close(); } } }); }  }
Version { public String getVersion() { return Util.execute(new ExceptionAction<String>() { @Override public String doAction() throws IOException { final URL resource = Version.class.getClassLoader().getResource(MODULE_PROPERTIES); if (resource == null) { throw new FileNotFoundException("Could not find internal resource " + MODULE_PROPERTIES); } final Reader reader = new InputStreamReader( resource.openStream(), "UTF-8"); try { final Properties properties = new Properties(); properties.load(reader); final String property = properties.getProperty(MODULE_VERSION); return property == null ? "unknown version, could not find property " + MODULE_VERSION + " in " + MODULE_PROPERTIES : property; } finally { reader.close(); } } }); }  String getVersion(); }
Version { public String getVersion() { return Util.execute(new ExceptionAction<String>() { @Override public String doAction() throws IOException { final URL resource = Version.class.getClassLoader().getResource(MODULE_PROPERTIES); if (resource == null) { throw new FileNotFoundException("Could not find internal resource " + MODULE_PROPERTIES); } final Reader reader = new InputStreamReader( resource.openStream(), "UTF-8"); try { final Properties properties = new Properties(); properties.load(reader); final String property = properties.getProperty(MODULE_VERSION); return property == null ? "unknown version, could not find property " + MODULE_VERSION + " in " + MODULE_PROPERTIES : property; } finally { reader.close(); } } }); }  String getVersion();  }