mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-14 15:53:36 +01:00
codacy recommended updates
This commit is contained in:
@@ -23,8 +23,8 @@ public class SwiftAnalyzersTest extends BaseTest {
|
||||
/**
|
||||
* The analyzer to test.
|
||||
*/
|
||||
CocoaPodsAnalyzer podsAnalyzer;
|
||||
SwiftPackageManagerAnalyzer spmAnalyzer;
|
||||
private CocoaPodsAnalyzer podsAnalyzer;
|
||||
private SwiftPackageManagerAnalyzer spmAnalyzer;
|
||||
|
||||
/**
|
||||
* Correctly setup the analyzer for testing.
|
||||
@@ -36,7 +36,7 @@ public class SwiftAnalyzersTest extends BaseTest {
|
||||
podsAnalyzer = new CocoaPodsAnalyzer();
|
||||
podsAnalyzer.setFilesMatched(true);
|
||||
podsAnalyzer.initialize();
|
||||
|
||||
|
||||
spmAnalyzer = new SwiftPackageManagerAnalyzer();
|
||||
spmAnalyzer.setFilesMatched(true);
|
||||
spmAnalyzer.initialize();
|
||||
@@ -87,7 +87,7 @@ public class SwiftAnalyzersTest extends BaseTest {
|
||||
public void testSPMSupportsFiles() {
|
||||
assertThat(spmAnalyzer.accept(new File("Package.swift")), is(true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test of analyze method, of class CocoaPodsAnalyzer.
|
||||
*
|
||||
@@ -99,7 +99,7 @@ public class SwiftAnalyzersTest extends BaseTest {
|
||||
"swift/cocoapods/EasyPeasy.podspec"));
|
||||
podsAnalyzer.analyze(result, null);
|
||||
final String vendorString = result.getVendorEvidence().toString();
|
||||
|
||||
|
||||
assertThat(vendorString, containsString("Carlos Vidal"));
|
||||
assertThat(vendorString, containsString("https://github.com/nakiostudio/EasyPeasy"));
|
||||
assertThat(vendorString, containsString("MIT"));
|
||||
|
||||
@@ -60,8 +60,12 @@ public class UrlTokenizingFilterTest extends BaseTokenStreamTestCase {
|
||||
* http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestEnglishMinimalStemFilter.java
|
||||
* blast some random strings through the analyzer
|
||||
*/
|
||||
public void testRandomStrings() throws Exception {
|
||||
checkRandomData(random(), analyzer, 1000 * RANDOM_MULTIPLIER);
|
||||
public void testRandomStrings() {
|
||||
try {
|
||||
checkRandomData(random(), analyzer, 1000 * RANDOM_MULTIPLIER);
|
||||
} catch (IOException ex) {
|
||||
fail("Failed test random strings: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,19 +18,19 @@
|
||||
package org.owasp.dependencycheck.data.nvdcve;
|
||||
|
||||
import org.owasp.dependencycheck.BaseDBTestCase;
|
||||
import org.owasp.dependencycheck.dependency.Vulnerability;
|
||||
import org.owasp.dependencycheck.dependency.VulnerableSoftware;
|
||||
import org.owasp.dependencycheck.utils.DependencyVersion;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.dependency.Vulnerability;
|
||||
import org.owasp.dependencycheck.dependency.VulnerableSoftware;
|
||||
import org.owasp.dependencycheck.utils.DependencyVersion;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -150,15 +150,15 @@ public class CveDBIntegrationTest extends BaseDBTestCase {
|
||||
try {
|
||||
instance = new CveDB();
|
||||
Entry<String, Boolean> results = instance.getMatchingSoftware(versions, "openssl", "openssl", identifiedVersion);
|
||||
Assert.assertNull(results);
|
||||
assertNull(results);
|
||||
versions.put("cpe:/a:openssl:openssl:1.0.1p", Boolean.FALSE);
|
||||
results = instance.getMatchingSoftware(versions, "openssl", "openssl", identifiedVersion);
|
||||
Assert.assertNull(results);
|
||||
assertNull(results);
|
||||
|
||||
versions.put("cpe:/a:openssl:openssl:1.0.1q", Boolean.TRUE);
|
||||
results = instance.getMatchingSoftware(versions, "openssl", "openssl", identifiedVersion);
|
||||
Assert.assertNotNull(results);
|
||||
Assert.assertEquals("cpe:/a:openssl:openssl:1.0.1q", results.getKey());
|
||||
assertNotNull(results);
|
||||
assertEquals("cpe:/a:openssl:openssl:1.0.1q", results.getKey());
|
||||
|
||||
versions.clear();
|
||||
|
||||
@@ -173,26 +173,26 @@ public class CveDBIntegrationTest extends BaseDBTestCase {
|
||||
|
||||
identifiedVersion = new DependencyVersion("3.2.2");
|
||||
results = instance.getMatchingSoftware(versions, "springsource", "spring_framework", identifiedVersion);
|
||||
Assert.assertEquals("cpe:/a:springsource:spring_framework:3.2.7", results.getKey());
|
||||
Assert.assertTrue(results.getValue());
|
||||
assertEquals("cpe:/a:springsource:spring_framework:3.2.7", results.getKey());
|
||||
assertTrue(results.getValue());
|
||||
identifiedVersion = new DependencyVersion("3.2.12");
|
||||
results = instance.getMatchingSoftware(versions, "springsource", "spring_framework", identifiedVersion);
|
||||
Assert.assertNull(results);
|
||||
assertNull(results);
|
||||
|
||||
identifiedVersion = new DependencyVersion("4.0.0");
|
||||
results = instance.getMatchingSoftware(versions, "springsource", "spring_framework", identifiedVersion);
|
||||
Assert.assertEquals("cpe:/a:springsource:spring_framework:4.0.1", results.getKey());
|
||||
Assert.assertTrue(results.getValue());
|
||||
assertEquals("cpe:/a:springsource:spring_framework:4.0.1", results.getKey());
|
||||
assertTrue(results.getValue());
|
||||
identifiedVersion = new DependencyVersion("4.1.0");
|
||||
results = instance.getMatchingSoftware(versions, "springsource", "spring_framework", identifiedVersion);
|
||||
Assert.assertNull(results);
|
||||
assertNull(results);
|
||||
|
||||
versions.clear();
|
||||
|
||||
versions.put("cpe:/a:jruby:jruby:-", Boolean.FALSE);
|
||||
identifiedVersion = new DependencyVersion("1.6.3");
|
||||
results = instance.getMatchingSoftware(versions, "springsource", "spring_framework", identifiedVersion);
|
||||
Assert.assertNotNull(results);
|
||||
assertNotNull(results);
|
||||
} finally {
|
||||
if (instance != null) {
|
||||
instance.close();
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.BaseTest;
|
||||
@@ -37,14 +38,14 @@ public class CveDBMySQLTest extends BaseTest {
|
||||
* Pretty useless tests of open, commit, and close methods, of class CveDB.
|
||||
*/
|
||||
@Test
|
||||
public void testOpen() throws DatabaseException {
|
||||
public void testOpen() {
|
||||
try {
|
||||
CveDB instance = new CveDB();
|
||||
instance.open();
|
||||
instance.close();
|
||||
} catch (DatabaseException ex) {
|
||||
System.out.println("Unable to connect to the My SQL database; verify that the db server is running and that the schema has been generated");
|
||||
throw ex;
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,8 @@
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.nvdcve;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.owasp.dependencycheck.BaseDBTestCase;
|
||||
import java.util.Properties;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -20,9 +20,11 @@ package org.owasp.dependencycheck.data.nvdcve;
|
||||
import java.io.File;
|
||||
import java.sql.Driver;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.BaseTest;
|
||||
@@ -35,13 +37,18 @@ public class DriverLoaderTest extends BaseTest {
|
||||
|
||||
/**
|
||||
* Test of load method, of class DriverLoader.
|
||||
*
|
||||
* @throws java.sql.SQLException thrown if there is an error de-registering
|
||||
* the driver
|
||||
*/
|
||||
@Test
|
||||
public void testLoad_String() throws Exception {
|
||||
public void testLoad_String() throws SQLException {
|
||||
String className = "org.h2.Driver";
|
||||
Driver d = null;
|
||||
try {
|
||||
d = DriverLoader.load(className);
|
||||
} catch (DriverLoadException ex) {
|
||||
fail(ex.getMessage());
|
||||
} finally {
|
||||
if (d != null) {
|
||||
DriverManager.deregisterDriver(d);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.owasp.dependencycheck.data.update.exception.UpdateException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -45,6 +46,9 @@ public class BaseUpdaterTest extends BaseDBTestCase {
|
||||
|
||||
/**
|
||||
* Test of getProperties method, of class BaseUpdater.
|
||||
*
|
||||
* @throws org.owasp.dependencycheck.data.update.exception.UpdateException
|
||||
* thrown if there is an error getting the properties
|
||||
*/
|
||||
@Test
|
||||
public void testGetProperties() throws UpdateException {
|
||||
@@ -66,11 +70,13 @@ public class BaseUpdaterTest extends BaseDBTestCase {
|
||||
* Test of closeDataStores method, of class BaseUpdater.
|
||||
*/
|
||||
@Test
|
||||
public void testCloseDataStores() throws UpdateException {
|
||||
public void testCloseDataStores() {
|
||||
BaseUpdater instance = null;
|
||||
try {
|
||||
instance = new BaseUpdaterImpl();
|
||||
instance.openDataStores();
|
||||
} catch (UpdateException ex) {
|
||||
fail(ex.getMessage());
|
||||
} finally {
|
||||
if (instance != null) {
|
||||
instance.closeDataStores();
|
||||
@@ -82,11 +88,13 @@ public class BaseUpdaterTest extends BaseDBTestCase {
|
||||
* Test of openDataStores method, of class BaseUpdater.
|
||||
*/
|
||||
@Test
|
||||
public void testOpenDataStores() throws Exception {
|
||||
public void testOpenDataStores() {
|
||||
BaseUpdater instance = null;
|
||||
try {
|
||||
instance = new BaseUpdaterImpl();
|
||||
instance.openDataStores();
|
||||
} catch (UpdateException ex) {
|
||||
fail(ex.getMessage());
|
||||
} finally {
|
||||
if (instance != null) {
|
||||
instance.closeDataStores();
|
||||
|
||||
@@ -15,14 +15,10 @@
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.update;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Properties;
|
||||
import mockit.Mock;
|
||||
import mockit.MockUp;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.owasp.dependencycheck.utils.DownloadFailedException;
|
||||
*
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class NvdCveUpdaterIntegrationTest extends BaseTest {
|
||||
public class NvdCveUpdaterIntegrationTest extends BaseTest {
|
||||
|
||||
public NvdCveUpdater getUpdater() throws MalformedURLException, DownloadFailedException, UpdateException {
|
||||
NvdCveUpdater instance = new NvdCveUpdater();
|
||||
@@ -40,11 +40,11 @@ public class NvdCveUpdaterIntegrationTest extends BaseTest {
|
||||
// /**
|
||||
// * Test of update method, of class StandardUpdate.
|
||||
// */
|
||||
@Test
|
||||
public void testUpdate() throws Exception {
|
||||
NvdCveUpdater instance = getUpdater();
|
||||
instance.update();
|
||||
}
|
||||
// @Test
|
||||
// public void testUpdate() throws Exception {
|
||||
// NvdCveUpdater instance = getUpdater();
|
||||
// instance.update();
|
||||
// }
|
||||
/**
|
||||
* Test of updatesNeeded method, of class StandardUpdate.
|
||||
*/
|
||||
|
||||
@@ -18,20 +18,27 @@
|
||||
package org.owasp.dependencycheck.reporting;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import javax.xml.validation.Schema;
|
||||
import javax.xml.validation.SchemaFactory;
|
||||
import javax.xml.validation.Validator;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.BaseDBTestCase;
|
||||
import org.owasp.dependencycheck.BaseTest;
|
||||
import org.owasp.dependencycheck.Engine;
|
||||
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
||||
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
|
||||
import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties;
|
||||
import org.owasp.dependencycheck.exception.ExceptionCollection;
|
||||
import org.owasp.dependencycheck.exception.ReportException;
|
||||
import org.owasp.dependencycheck.utils.InvalidSettingException;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -107,48 +114,54 @@ public class ReportGeneratorIntegrationTest extends BaseDBTestCase {
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testGenerateXMLReport() throws Exception {
|
||||
String templateName = "XmlReport";
|
||||
|
||||
File f = new File("target/test-reports");
|
||||
if (!f.exists()) {
|
||||
f.mkdir();
|
||||
public void testGenerateXMLReport() {
|
||||
try {
|
||||
String templateName = "XmlReport";
|
||||
|
||||
File f = new File("target/test-reports");
|
||||
if (!f.exists()) {
|
||||
f.mkdir();
|
||||
}
|
||||
String writeTo = "target/test-reports/Report.xml";
|
||||
|
||||
//File struts = new File(this.getClass().getClassLoader().getResource("struts2-core-2.1.2.jar").getPath());
|
||||
File struts = BaseTest.getResourceAsFile(this, "struts2-core-2.1.2.jar");
|
||||
//File axis = new File(this.getClass().getClassLoader().getResource("axis2-adb-1.4.1.jar").getPath());
|
||||
File axis = BaseTest.getResourceAsFile(this, "axis2-adb-1.4.1.jar");
|
||||
//File jetty = new File(this.getClass().getClassLoader().getResource("org.mortbay.jetty.jar").getPath());
|
||||
File jetty = BaseTest.getResourceAsFile(this, "org.mortbay.jetty.jar");
|
||||
|
||||
boolean autoUpdate = Settings.getBoolean(Settings.KEYS.AUTO_UPDATE);
|
||||
Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, false);
|
||||
Engine engine = new Engine();
|
||||
Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate);
|
||||
|
||||
engine.scan(struts);
|
||||
engine.scan(axis);
|
||||
engine.scan(jetty);
|
||||
engine.analyzeDependencies();
|
||||
|
||||
CveDB cveDB = new CveDB();
|
||||
cveDB.open();
|
||||
DatabaseProperties dbProp = cveDB.getDatabaseProperties();
|
||||
cveDB.close();
|
||||
|
||||
ReportGenerator generator = new ReportGenerator("Test Report", engine.getDependencies(), engine.getAnalyzers(), dbProp);
|
||||
generator.generateReport(templateName, writeTo);
|
||||
|
||||
engine.cleanup();
|
||||
|
||||
InputStream xsdStream = ReportGenerator.class.getClassLoader().getResourceAsStream("schema/dependency-check.1.3.xsd");
|
||||
StreamSource xsdSource = new StreamSource(xsdStream);
|
||||
StreamSource xmlSource = new StreamSource(new File(writeTo));
|
||||
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
Schema schema = sf.newSchema(xsdSource);
|
||||
Validator validator = schema.newValidator();
|
||||
validator.validate(xmlSource);
|
||||
} catch (InvalidSettingException ex) {
|
||||
fail(ex.getMessage());
|
||||
} catch (DatabaseException | ExceptionCollection | ReportException | SAXException | IOException ex) {
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
String writeTo = "target/test-reports/Report.xml";
|
||||
|
||||
//File struts = new File(this.getClass().getClassLoader().getResource("struts2-core-2.1.2.jar").getPath());
|
||||
File struts = BaseTest.getResourceAsFile(this, "struts2-core-2.1.2.jar");
|
||||
//File axis = new File(this.getClass().getClassLoader().getResource("axis2-adb-1.4.1.jar").getPath());
|
||||
File axis = BaseTest.getResourceAsFile(this, "axis2-adb-1.4.1.jar");
|
||||
//File jetty = new File(this.getClass().getClassLoader().getResource("org.mortbay.jetty.jar").getPath());
|
||||
File jetty = BaseTest.getResourceAsFile(this, "org.mortbay.jetty.jar");
|
||||
|
||||
boolean autoUpdate = Settings.getBoolean(Settings.KEYS.AUTO_UPDATE);
|
||||
Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, false);
|
||||
Engine engine = new Engine();
|
||||
Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate);
|
||||
|
||||
engine.scan(struts);
|
||||
engine.scan(axis);
|
||||
engine.scan(jetty);
|
||||
engine.analyzeDependencies();
|
||||
|
||||
CveDB cveDB = new CveDB();
|
||||
cveDB.open();
|
||||
DatabaseProperties dbProp = cveDB.getDatabaseProperties();
|
||||
cveDB.close();
|
||||
|
||||
ReportGenerator generator = new ReportGenerator("Test Report", engine.getDependencies(), engine.getAnalyzers(), dbProp);
|
||||
generator.generateReport(templateName, writeTo);
|
||||
|
||||
engine.cleanup();
|
||||
|
||||
InputStream xsdStream = ReportGenerator.class.getClassLoader().getResourceAsStream("schema/dependency-check.1.3.xsd");
|
||||
StreamSource xsdSource = new StreamSource(xsdStream);
|
||||
StreamSource xmlSource = new StreamSource(new File(writeTo));
|
||||
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
Schema schema = sf.newSchema(xsdSource);
|
||||
Validator validator = schema.newValidator();
|
||||
validator.validate(xmlSource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public class DependencyVersionTest extends BaseTest {
|
||||
expected[4] = new DependencyVersion("2.1.3");
|
||||
expected[5] = new DependencyVersion("2.1.3.r1");
|
||||
expected[6] = new DependencyVersion("2.1.3.r2");
|
||||
java.util.Arrays.sort(dv);
|
||||
Arrays.sort(dv);
|
||||
|
||||
assertArrayEquals(expected, dv);
|
||||
}
|
||||
@@ -209,5 +209,7 @@ public class DependencyVersionTest extends BaseTest {
|
||||
List<String> versionParts = Arrays.asList("1", "1", "1");
|
||||
DependencyVersion instance = new DependencyVersion();
|
||||
instance.setVersionParts(versionParts);
|
||||
List<String> results = instance.getVersionParts();
|
||||
assertEquals(versionParts, results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +92,11 @@ public class ModelTest extends BaseTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetDescription() {
|
||||
String description = "";
|
||||
String description = "description";
|
||||
String expected = "description";
|
||||
Model instance = new Model();
|
||||
instance.setDescription(description);
|
||||
assertEquals(expected, instance.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,9 +116,11 @@ public class ModelTest extends BaseTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetGroupId() {
|
||||
String groupId = "";
|
||||
String groupId = "aaa";
|
||||
String expected = "aaa";
|
||||
Model instance = new Model();
|
||||
instance.setGroupId(groupId);
|
||||
assertEquals(expected, instance.getGroupId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,9 +140,11 @@ public class ModelTest extends BaseTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetArtifactId() {
|
||||
String artifactId = "";
|
||||
String artifactId = "aaa";
|
||||
String expected = "aaa";
|
||||
Model instance = new Model();
|
||||
instance.setArtifactId(artifactId);
|
||||
assertEquals(expected, instance.getArtifactId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.BaseTest;
|
||||
|
||||
@@ -144,6 +144,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testGetFilePath() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,6 +153,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testSetFilePath() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,6 +162,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testGetSha1() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,6 +171,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testSetSha1() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,6 +180,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testGetCpe() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,6 +189,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testSetCpe() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,6 +198,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testAddCpe() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,6 +207,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testHasCpe() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,6 +216,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testSetCvssBelow() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,6 +225,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testAddCvssBelow() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,6 +234,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testHasCvssBelow() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,6 +243,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testGetCwe() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,6 +252,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testSetCwe() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,6 +261,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testAddCwe() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,6 +270,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testHasCwe() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,6 +279,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testGetCve() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,6 +288,7 @@ public class SuppressionRuleTest extends BaseTest {
|
||||
@Test
|
||||
public void testSetCve() {
|
||||
//already tested, this is just left so the IDE doesn't recreate it.
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
@@ -70,6 +71,7 @@ public class ChecksumTest {
|
||||
|
||||
expectedException.expect(IOException.class);
|
||||
Checksum.getChecksum(algorithm, file);
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,11 +20,13 @@ package org.owasp.dependencycheck.utils;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -58,20 +60,31 @@ public class ExpectedOjectInputStreamTest {
|
||||
* Test of resolveClass method, of class ExpectedOjectInputStream.
|
||||
*/
|
||||
@Test
|
||||
public void testResolveClass() throws Exception {
|
||||
List<SimplePojo> data = new ArrayList<SimplePojo>();
|
||||
data.add(new SimplePojo());
|
||||
|
||||
ByteArrayOutputStream mem = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(mem));
|
||||
out.writeObject(data);
|
||||
out.flush();
|
||||
byte[] buf = mem.toByteArray();
|
||||
out.close();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(buf);
|
||||
|
||||
ExpectedOjectInputStream instance = new ExpectedOjectInputStream(in, "java.util.ArrayList", "org.owasp.dependencycheck.utils.SimplePojo", "java.lang.Integer", "java.lang.Number");
|
||||
instance.readObject();
|
||||
public void testResolveClass() {
|
||||
ObjectOutputStream out = null;
|
||||
try {
|
||||
List<SimplePojo> data = new ArrayList<>();
|
||||
data.add(new SimplePojo());
|
||||
ByteArrayOutputStream mem = new ByteArrayOutputStream();
|
||||
out = new ObjectOutputStream(new BufferedOutputStream(mem));
|
||||
out.writeObject(data);
|
||||
out.flush();
|
||||
byte[] buf = mem.toByteArray();
|
||||
out.close();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(buf);
|
||||
ExpectedOjectInputStream instance = new ExpectedOjectInputStream(in, "java.util.ArrayList", "org.owasp.dependencycheck.utils.SimplePojo", "java.lang.Integer", "java.lang.Number");
|
||||
instance.readObject();
|
||||
} catch (IOException | ClassNotFoundException ex) {
|
||||
fail(ex.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user