mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-21 08:39:24 +01:00
added tests for new methods
Former-commit-id: e571160a322b68d4dfb18ecc2dc4c774b8403665
This commit is contained in:
@@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.owasp.dependencycheck.data.nvdcve;
|
package org.owasp.dependencycheck.data.nvdcve;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -29,10 +29,7 @@ import org.owasp.dependencycheck.data.update.NvdCveInfo;
|
|||||||
*
|
*
|
||||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||||
*/
|
*/
|
||||||
public class DatabasePropertiesTest {
|
public class DatabasePropertiesTest extends BaseDBTestCase {
|
||||||
|
|
||||||
public DatabasePropertiesTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass() {
|
public static void setUpClass() {
|
||||||
@@ -43,11 +40,15 @@ public class DatabasePropertiesTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
@Override
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
@Override
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,7 +86,7 @@ public class DatabasePropertiesTest {
|
|||||||
cveDB.open();
|
cveDB.open();
|
||||||
instance = cveDB.getDatabaseProperties();
|
instance = cveDB.getDatabaseProperties();
|
||||||
cveDB.close();
|
cveDB.close();
|
||||||
long results = Long.parseLong(instance.getProperty("lastupdated." + key));
|
long results = Long.parseLong(instance.getProperty("NVD CVE " + key));
|
||||||
assertEquals(expected, results);
|
assertEquals(expected, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,4 +105,33 @@ public class DatabasePropertiesTest {
|
|||||||
String result = instance.getProperty(key, defaultValue);
|
String result = instance.getProperty(key, defaultValue);
|
||||||
assertEquals(expResult, result);
|
assertEquals(expResult, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getProperty method, of class DatabaseProperties.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetProperty_String() throws DatabaseException {
|
||||||
|
String key = "version";
|
||||||
|
CveDB cveDB = new CveDB();
|
||||||
|
cveDB.open();
|
||||||
|
DatabaseProperties instance = cveDB.getDatabaseProperties();
|
||||||
|
cveDB.close();
|
||||||
|
String result = instance.getProperty(key);
|
||||||
|
double version = Double.parseDouble(result);
|
||||||
|
assertTrue(version >= 2.8);
|
||||||
|
assertTrue(version <= 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getProperties method, of class DatabaseProperties.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetProperties() throws DatabaseException {
|
||||||
|
CveDB cveDB = new CveDB();
|
||||||
|
cveDB.open();
|
||||||
|
DatabaseProperties instance = cveDB.getDatabaseProperties();
|
||||||
|
cveDB.close();
|
||||||
|
Properties result = instance.getProperties();
|
||||||
|
assertTrue(result.size() > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user