mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-04-30 04:04:30 +02:00
corrected minor issue with path to zipped test data
Former-commit-id: 862ea03dc2738dc315a82c03d514f3ce8b6f410e
This commit is contained in:
@@ -61,16 +61,18 @@ public abstract class BaseIndexTestCase {
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
protected static File getDataDirectory() throws IOException {
|
||||
final String fileName = Settings.getString(Settings.KEYS.CPE_DATA_DIRECTORY);
|
||||
final String dataDirectory = Settings.getString(Settings.KEYS.DATA_DIRECTORY);
|
||||
return new File(dataDirectory, fileName);
|
||||
//return FileUtils.getDataDirectory(fileName, Index.class);
|
||||
protected static File getDataDirectory(Class clazz) throws IOException {
|
||||
final File dataDirectory = Settings.getFile(Settings.KEYS.CPE_DATA_DIRECTORY, clazz);
|
||||
return dataDirectory;
|
||||
}
|
||||
|
||||
public static void ensureIndexExists() throws Exception {
|
||||
ensureIndexExists(BaseIndexTestCase.class);
|
||||
}
|
||||
|
||||
public static void ensureIndexExists(Class clazz) throws Exception {
|
||||
//String indexPath = Settings.getString(Settings.KEYS.CPE_DATA_DIRECTORY);
|
||||
String indexPath = getDataDirectory().getCanonicalPath();
|
||||
String indexPath = getDataDirectory(clazz).getAbsolutePath();
|
||||
java.io.File f = new File(indexPath);
|
||||
|
||||
if (!f.exists() || (f.isDirectory() && f.listFiles().length == 0)) {
|
||||
|
||||
@@ -46,21 +46,24 @@ public abstract class BaseDBTestCase extends TestCase {
|
||||
ensureDBExists();
|
||||
}
|
||||
|
||||
protected static File getDataDirectory() throws IOException {
|
||||
final String fileName = Settings.getString(Settings.KEYS.CVE_DATA_DIRECTORY);
|
||||
final String dataDirectory = Settings.getString(Settings.KEYS.DATA_DIRECTORY);
|
||||
return new File(dataDirectory, fileName);
|
||||
protected static File getDataDirectory(Class clazz) throws IOException {
|
||||
final File dataDirectory = Settings.getFile(Settings.KEYS.CVE_DATA_DIRECTORY, clazz);
|
||||
return dataDirectory;
|
||||
}
|
||||
|
||||
public static void ensureDBExists() throws Exception {
|
||||
String indexPath = getDataDirectory().getCanonicalPath();
|
||||
ensureDBExists(BaseDBTestCase.class);
|
||||
}
|
||||
|
||||
public static void ensureDBExists(Class clazz) throws Exception {
|
||||
String indexPath = getDataDirectory(clazz).getAbsolutePath();
|
||||
java.io.File f = new File(indexPath);
|
||||
if (!f.exists() || (f.isDirectory() && f.listFiles().length == 0)) {
|
||||
f.mkdirs();
|
||||
FileInputStream fis = null;
|
||||
ZipInputStream zin = null;
|
||||
try {
|
||||
File path = new File(BaseDBTestCase.class.getClassLoader().getResource("db.cve.zip").getPath());
|
||||
File path = new File(clazz.getClassLoader().getResource("db.cve.zip").getPath());
|
||||
fis = new FileInputStream(path);
|
||||
zin = new ZipInputStream(new BufferedInputStream(fis));
|
||||
ZipEntry entry;
|
||||
|
||||
Reference in New Issue
Block a user