mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-06-02 23:51:02 +00:00
Revert previous changes to HIRS_Util classes related to VERSION file
This commit is contained in:
parent
404f2ab5dd
commit
96e41156c7
@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user