From 65784d6dc41c366c9203131c8c222ff6accbb663 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sat, 3 May 2014 11:01:31 -0400 Subject: [PATCH] updated to use local copy of data files to speedup the test case Former-commit-id: 5bb1d67156500ba74124ced18bcae599e4c5dc7a --- .../update/NvdCveUpdaterIntegrationTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/dependency-check-core/src/test/java/org/owasp/dependencycheck/data/update/NvdCveUpdaterIntegrationTest.java b/dependency-check-core/src/test/java/org/owasp/dependencycheck/data/update/NvdCveUpdaterIntegrationTest.java index c9d1463a5..24863e04b 100644 --- a/dependency-check-core/src/test/java/org/owasp/dependencycheck/data/update/NvdCveUpdaterIntegrationTest.java +++ b/dependency-check-core/src/test/java/org/owasp/dependencycheck/data/update/NvdCveUpdaterIntegrationTest.java @@ -17,8 +17,12 @@ */ package org.owasp.dependencycheck.data.update; +import java.io.File; +import java.util.Calendar; +import org.junit.Before; import org.junit.Test; import org.owasp.dependencycheck.BaseTest; +import org.owasp.dependencycheck.utils.Settings; /** * @@ -26,6 +30,32 @@ import org.owasp.dependencycheck.BaseTest; */ public class NvdCveUpdaterIntegrationTest extends BaseTest { + @Before + public void setUp() throws Exception { + int year = Calendar.getInstance().get(Calendar.YEAR); + if (year <= 2014) { + File f = new File(NvdCveUpdaterIntegrationTest.class.getClassLoader().getResource("nvdcve-2.0-2014.xml").getPath()); + String baseURL = f.toURI().toURL().toString(); + String modified12 = baseURL.replace("nvdcve-2.0-2014.xml", "nvdcve-modified.xml"); + String modified20 = baseURL.replace("nvdcve-2.0-2014.xml", "nvdcve-2.0-modified.xml"); + String full12 = baseURL.replace("nvdcve-2.0-2014.xml", "nvdcve-%d.xml"); + String full20 = baseURL.replace("nvdcve-2.0-2014.xml", "nvdcve-2.0-%d.xml"); +// cve.url-1.2.modified=http://nvd.nist.gov/download/nvdcve-modified.xml +// cve.url-2.0.modified=http://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-modified.xml +// cve.startyear=2014 +// cve.url-2.0.base=http://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-%d.xml +// cve.url-1.2.base=http://nvd.nist.gov/download/nvdcve-%d.xml + + Settings.setString(Settings.KEYS.CVE_MODIFIED_12_URL, modified12); + Settings.setString(Settings.KEYS.CVE_MODIFIED_20_URL, modified20); + Settings.setString(Settings.KEYS.CVE_SCHEMA_1_2, full12); + Settings.setString(Settings.KEYS.CVE_SCHEMA_2_0, full20); + Settings.setString(Settings.KEYS.CVE_START_YEAR, "2014"); + } else { + System.err.println("Consider updating the local data files to make the NvdCveUpdaterIntegrationTest perform faster"); + } + } + /** * Test of update method, of class NvdCveUpdater. */