fixed unit test on non-windows

This commit is contained in:
Jeremy Long
2016-09-01 06:12:35 -04:00
parent 9fcf23c802
commit 6a68abbd67
2 changed files with 6 additions and 4 deletions

View File

@@ -86,7 +86,7 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
* *
* @return the list of arguments to begin populating the ProcessBuilder * @return the list of arguments to begin populating the ProcessBuilder
*/ */
private List<String> buildArgumentList() { protected List<String> buildArgumentList() {
// Use file.separator as a wild guess as to whether this is Windows // Use file.separator as a wild guess as to whether this is Windows
final List<String> args = new ArrayList<String>(); final List<String> args = new ArrayList<String>();
if (!SystemUtils.IS_OS_WINDOWS) { if (!SystemUtils.IS_OS_WINDOWS) {

View File

@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import org.junit.Assume; import org.junit.Assume;
import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.BaseTest; import org.owasp.dependencycheck.BaseTest;
@@ -81,7 +82,7 @@ public class AssemblyAnalyzerTest extends BaseTest {
@Test @Test
public void testAnalysis() throws Exception { public void testAnalysis() throws Exception {
//File f = new File(AssemblyAnalyzerTest.class.getClassLoader().getResource("GrokAssembly.exe").getPath()); assumeNotNull(analyzer.buildArgumentList());
File f = BaseTest.getResourceAsFile(this, "GrokAssembly.exe"); File f = BaseTest.getResourceAsFile(this, "GrokAssembly.exe");
Dependency d = new Dependency(f); Dependency d = new Dependency(f);
analyzer.analyze(d, null); analyzer.analyze(d, null);
@@ -104,7 +105,7 @@ public class AssemblyAnalyzerTest extends BaseTest {
@Test @Test
public void testLog4Net() throws Exception { public void testLog4Net() throws Exception {
//File f = new File(AssemblyAnalyzerTest.class.getClassLoader().getResource("log4net.dll").getPath()); assumeNotNull(analyzer.buildArgumentList());
File f = BaseTest.getResourceAsFile(this, "log4net.dll"); File f = BaseTest.getResourceAsFile(this, "log4net.dll");
Dependency d = new Dependency(f); Dependency d = new Dependency(f);
@@ -116,9 +117,10 @@ public class AssemblyAnalyzerTest extends BaseTest {
@Test @Test
public void testNonexistent() { public void testNonexistent() {
assumeNotNull(analyzer.buildArgumentList());
// Tweak the log level so the warning doesn't show in the console // Tweak the log level so the warning doesn't show in the console
String oldProp = System.getProperty(LOG_KEY, "info"); String oldProp = System.getProperty(LOG_KEY, "info");
//File f = new File(AssemblyAnalyzerTest.class.getClassLoader().getResource("log4net.dll").getPath());
File f = BaseTest.getResourceAsFile(this, "log4net.dll"); File f = BaseTest.getResourceAsFile(this, "log4net.dll");
File test = new File(f.getParent(), "nonexistent.dll"); File test = new File(f.getParent(), "nonexistent.dll");
Dependency d = new Dependency(test); Dependency d = new Dependency(test);