Revert previous changes to HIRS_Util classes related to VERSION file

This commit is contained in:
Tsai 2019-12-11 15:57:09 -05:00
parent 404f2ab5dd
commit 96e41156c7
2 changed files with 7 additions and 17 deletions

View File

@ -1,13 +1,12 @@
package hirs.utils; package hirs.utils;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
/** /**
* Utility class to get the current version from the VERSION file. * Utility class to get the current version from the VERSION file.
@ -59,16 +58,7 @@ public final class VersionHelper {
* @throws IOException * @throws IOException
*/ */
private static String getFileContents(final String filename) throws IOException { private static String getFileContents(final String filename) throws IOException {
URL url = Resources.getResource(filename);
File versionFileLink = new File(VersionHelper.class.getClassLoader() return Resources.toString(url, Charsets.UTF_8).trim();
.getResource(filename).getFile());
String versionFilePath = versionFileLink.getCanonicalPath();
BufferedReader reader = new BufferedReader(
new InputStreamReader(
new FileInputStream(versionFilePath), "UTF-8"));
String version = reader.readLine();
reader.close();
return version;
} }
} }

View File

@ -14,8 +14,8 @@ public class VersionHelperTest {
@Test @Test
public void testGetVersionFail() { public void testGetVersionFail() {
String version = VersionHelper.getVersion("somefile"); String actual = VersionHelper.getVersion("somefile");
Assert.assertEquals(version, ""); Assert.assertTrue(actual.startsWith(""));
} }
/** /**