updated test cases to track down build issue

This commit is contained in:
Jeremy Long
2016-04-30 10:56:50 -04:00
parent abebecac4a
commit 9e46364759
31 changed files with 55 additions and 313 deletions

View File

@@ -31,8 +31,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* An abstract database test case that is used to ensure the H2 DB exists prior to performing tests that utilize the data * An abstract database test case that is used to ensure the H2 DB exists prior
* contained within. * to performing tests that utilize the data contained within.
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
@@ -49,6 +49,11 @@ public abstract class BaseDBTestCase extends BaseTest {
public static void ensureDBExists() throws Exception { public static void ensureDBExists() throws Exception {
File f = new File("./target/data/dc.h2.db");
if (f.exists() && f.isFile() && f.length() < 71680) {
f.delete();
}
java.io.File dataPath = Settings.getDataDirectory(); java.io.File dataPath = Settings.getDataDirectory();
String fileName = Settings.getString(Settings.KEYS.DB_FILE_NAME); String fileName = Settings.getString(Settings.KEYS.DB_FILE_NAME);
LOGGER.trace("DB file name {}", fileName); LOGGER.trace("DB file name {}", fileName);

View File

@@ -39,7 +39,7 @@ public class BaseTest {
if (f.exists() && f.isFile() && f.length() < 71680) { if (f.exists() && f.isFile() && f.length() < 71680) {
System.err.println("------------------------------------------------"); System.err.println("------------------------------------------------");
System.err.println("------------------------------------------------"); System.err.println("------------------------------------------------");
System.err.println("I broke the build"); System.err.println("Test referenced CveDB() and does not extend BaseDbTestCases?");
System.err.println("------------------------------------------------"); System.err.println("------------------------------------------------");
System.err.println("------------------------------------------------"); System.err.println("------------------------------------------------");
} }

View File

@@ -30,16 +30,7 @@ import org.owasp.dependencycheck.utils.Settings;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class EngineIntegrationTest extends BaseTest { public class EngineIntegrationTest extends BaseDBTestCase {
@Before
public void setUp() throws Exception {
org.owasp.dependencycheck.BaseDBTestCase.ensureDBExists();
}
@After
public void tearDown() {
}
/** /**
* Test running the entire engine. * Test running the entire engine.

View File

@@ -20,13 +20,13 @@ package org.owasp.dependencycheck.analyzer;
import java.util.Iterator; import java.util.Iterator;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest; import org.owasp.dependencycheck.BaseDBTestCase;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class AnalyzerServiceTest extends BaseTest { public class AnalyzerServiceTest extends BaseDBTestCase {
/** /**
* Test of getAnalyzers method, of class AnalyzerService. * Test of getAnalyzers method, of class AnalyzerService.

View File

@@ -55,6 +55,7 @@ public class ComposerLockAnalyzerTest extends BaseDBTestCase {
*/ */
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp();
analyzer = new ComposerLockAnalyzer(); analyzer = new ComposerLockAnalyzer();
analyzer.setFilesMatched(true); analyzer.setFilesMatched(true);
analyzer.initialize(); analyzer.initialize();

View File

@@ -18,6 +18,7 @@ package org.owasp.dependencycheck.analyzer;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
import org.owasp.dependencycheck.Engine; import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.dependency.Dependency; import org.owasp.dependencycheck.dependency.Dependency;
@@ -25,7 +26,7 @@ import org.owasp.dependencycheck.dependency.Dependency;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class FalsePositiveAnalyzerTest { public class FalsePositiveAnalyzerTest extends BaseTest {
/** /**
* Test of getName method, of class FalsePositiveAnalyzer. * Test of getName method, of class FalsePositiveAnalyzer.

View File

@@ -28,7 +28,7 @@ import org.owasp.dependencycheck.dependency.Dependency;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class FileNameAnalyzerTest { public class FileNameAnalyzerTest extends BaseTest {
/** /**
* Test of getName method, of class FileNameAnalyzer. * Test of getName method, of class FileNameAnalyzer.

View File

@@ -25,11 +25,12 @@ import java.io.InputStream;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.owasp.dependencycheck.BaseTest;
/** /**
* Created by colezlaw on 9/5/15. * Created by colezlaw on 9/5/15.
*/ */
public class ComposerLockParserTest { public class ComposerLockParserTest extends BaseTest {
private InputStream inputStream; private InputStream inputStream;

View File

@@ -19,12 +19,13 @@ package org.owasp.dependencycheck.data.cpe;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class IndexEntryTest { public class IndexEntryTest extends BaseTest {
/** /**
* Test of setName method, of class IndexEntry. * Test of setName method, of class IndexEntry.

View File

@@ -23,31 +23,13 @@ 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;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class CweDBTest { public class CweDBTest extends BaseTest {
public CweDBTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Method to serialize the CWE HashMap. This is not used in production; this is only used once during dev to create * Method to serialize the CWE HashMap. This is not used in production; this is only used once during dev to create

View File

@@ -43,28 +43,13 @@ import static org.junit.Assert.assertFalse;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class FieldAnalyzerTest { public class FieldAnalyzerTest extends BaseTest {
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
@Test @Test
public void testAnalyzers() throws Exception { public void testAnalyzers() throws Exception {

View File

@@ -23,28 +23,13 @@ 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;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class LuceneUtilsTest { public class LuceneUtilsTest extends BaseTest {
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of appendEscapedLuceneQuery method, of class LuceneUtils. * Test of appendEscapedLuceneQuery method, of class LuceneUtils.

View File

@@ -39,14 +39,6 @@ import org.junit.Test;
*/ */
public class TokenPairConcatenatingFilterTest extends BaseTokenStreamTestCase { public class TokenPairConcatenatingFilterTest extends BaseTokenStreamTestCase {
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Override @Override
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {

View File

@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
import org.owasp.dependencycheck.dependency.Vulnerability; import org.owasp.dependencycheck.dependency.Vulnerability;
import org.owasp.dependencycheck.dependency.VulnerableSoftware; import org.owasp.dependencycheck.dependency.VulnerableSoftware;
import org.owasp.dependencycheck.utils.Settings; import org.owasp.dependencycheck.utils.Settings;
@@ -33,25 +34,7 @@ import org.owasp.dependencycheck.utils.Settings;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class CveDBMySQLTest { public class CveDBMySQLTest extends BaseTest {
@BeforeClass
public static void setUpClass() {
Settings.initialize();
}
@AfterClass
public static void tearDownClass() {
Settings.cleanup();
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
/** /**
* Pretty useless tests of open, commit, and close methods, of class CveDB. * Pretty useless tests of open, commit, and close methods, of class CveDB.

View File

@@ -33,26 +33,7 @@ import org.owasp.dependencycheck.BaseTest;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class DriverLoaderTest { public class DriverLoaderTest extends BaseTest {
public DriverLoaderTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of load method, of class DriverLoader. * Test of load method, of class DriverLoader.
@@ -71,7 +52,8 @@ public class DriverLoaderTest {
} }
/** /**
* Test of load method, of class DriverLoader; expecting an exception due to a bad driver class name. * Test of load method, of class DriverLoader; expecting an exception due to
* a bad driver class name.
*/ */
@Test(expected = DriverLoadException.class) @Test(expected = DriverLoadException.class)
public void testLoad_String_ex() throws Exception { public void testLoad_String_ex() throws Exception {

View File

@@ -36,26 +36,7 @@ import org.owasp.dependencycheck.dependency.VulnerableSoftware;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class NvdCve_1_2_HandlerTest { public class NvdCve_1_2_HandlerTest extends BaseTest {
public NvdCve_1_2_HandlerTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
@Test @Test
public void testParse() throws Exception { public void testParse() throws Exception {

View File

@@ -33,26 +33,7 @@ import org.owasp.dependencycheck.BaseTest;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class NvdCve_2_0_HandlerTest { public class NvdCve_2_0_HandlerTest extends BaseTest {
public NvdCve_2_0_HandlerTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
@Test @Test
public void testParse() { public void testParse() {

View File

@@ -35,26 +35,7 @@ import org.owasp.dependencycheck.data.nexus.MavenArtifact;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class DependencyTest { public class DependencyTest extends BaseTest {
public DependencyTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of getFileName method, of class Dependency. * Test of getFileName method, of class Dependency.

View File

@@ -20,12 +20,13 @@ package org.owasp.dependencycheck.dependency;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class EvidenceTest { public class EvidenceTest extends BaseTest {
/** /**
* Test of equals method, of class Evidence. * Test of equals method, of class Evidence.

View File

@@ -23,31 +23,13 @@ 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;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class VulnerableSoftwareTest { public class VulnerableSoftwareTest extends BaseTest {
public VulnerableSoftwareTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of equals method, of class VulnerableSoftware. * Test of equals method, of class VulnerableSoftware.

View File

@@ -26,6 +26,7 @@ import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator; import javax.xml.validation.Validator;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseDBTestCase;
import org.owasp.dependencycheck.BaseTest; import org.owasp.dependencycheck.BaseTest;
import org.owasp.dependencycheck.Engine; import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.data.nvdcve.CveDB; import org.owasp.dependencycheck.data.nvdcve.CveDB;
@@ -36,12 +37,7 @@ import org.owasp.dependencycheck.utils.Settings;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class ReportGeneratorIntegrationTest extends BaseTest { public class ReportGeneratorIntegrationTest extends BaseDBTestCase {
@Before
public void setUp() throws Exception {
org.owasp.dependencycheck.BaseDBTestCase.ensureDBExists();
}
/** /**
* Test of generateReport method, of class ReportGenerator. * Test of generateReport method, of class ReportGenerator.

View File

@@ -25,31 +25,13 @@ import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class PropertyTypeTest { public class PropertyTypeTest extends BaseTest {
public PropertyTypeTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of set and getValue method, of class PropertyType. * Test of set and getValue method, of class PropertyType.

View File

@@ -39,26 +39,7 @@ import org.xml.sax.XMLReader;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class SuppressionHandlerTest { public class SuppressionHandlerTest extends BaseTest {
public SuppressionHandlerTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of getSuppressionRules method, of class SuppressionHandler. * Test of getSuppressionRules method, of class SuppressionHandler.

View File

@@ -32,26 +32,7 @@ import org.owasp.dependencycheck.BaseTest;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class SuppressionParserTest { public class SuppressionParserTest extends BaseTest {
public SuppressionParserTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of parseSuppressionRules method, of class SuppressionParser. * Test of parseSuppressionRules method, of class SuppressionParser.

View File

@@ -34,7 +34,7 @@ import org.owasp.dependencycheck.dependency.Vulnerability;
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class SuppressionRuleTest { public class SuppressionRuleTest extends BaseTest {
//<editor-fold defaultstate="collapsed" desc="Stupid tests of properties"> //<editor-fold defaultstate="collapsed" desc="Stupid tests of properties">
/** /**

View File

@@ -22,31 +22,13 @@ 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;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class DateUtilTest { public class DateUtilTest extends BaseTest {
public DateUtilTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of withinDateRange method, of class DateUtil. * Test of withinDateRange method, of class DateUtil.

View File

@@ -24,12 +24,13 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class DependencyVersionTest { public class DependencyVersionTest extends BaseTest {
/** /**
* Test of parseVersion method, of class DependencyVersion. * Test of parseVersion method, of class DependencyVersion.

View File

@@ -24,31 +24,13 @@ import static org.junit.Assert.assertNull;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class DependencyVersionUtilTest { public class DependencyVersionUtilTest extends BaseTest {
public DependencyVersionUtilTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/** /**
* Test of parseVersion method, of class DependencyVersionUtil. * Test of parseVersion method, of class DependencyVersionUtil.

View File

@@ -23,12 +23,13 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class FilterTest { public class FilterTest extends BaseTest {
/** /**
* Test of passes method, of class Filter. * Test of passes method, of class Filter.

View File

@@ -23,12 +23,13 @@ import java.util.Properties;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.owasp.dependencycheck.BaseTest;
/** /**
* *
* @author jeremy * @author jeremy
*/ */
public class ModelTest { public class ModelTest extends BaseTest {
/** /**
* Test of getName method, of class Model. * Test of getName method, of class Model.

View File

@@ -27,7 +27,7 @@ import org.owasp.dependencycheck.BaseTest;
* *
* @author jeremy * @author jeremy
*/ */
public class PomUtilsTest { public class PomUtilsTest extends BaseTest {
/** /**
* Test of readPom method, of class PomUtils. * Test of readPom method, of class PomUtils.