mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-04-10 10:53:58 +02:00
updated test case using an invalid mono path so that it does not run on Windows
Former-commit-id: d6a822f2ce18d9f163839d5d1108cbac06a04516
This commit is contained in:
@@ -17,12 +17,16 @@
|
||||
*/
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.codeaffine.junit.ignore.ConditionalIgnoreRule;
|
||||
import com.codeaffine.junit.ignore.ConditionalIgnoreRule.ConditionalIgnore;
|
||||
import com.codeaffine.junit.ignore.NotRunningOnWindows;
|
||||
import java.io.File;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.dependency.Confidence;
|
||||
import org.owasp.dependencycheck.dependency.Dependency;
|
||||
@@ -31,14 +35,17 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
|
||||
/**
|
||||
* Tests for the AssemblyAnalyzer.
|
||||
*
|
||||
* @author colezlaw
|
||||
*
|
||||
*/
|
||||
public class AssemblyAnalyzerTest {
|
||||
|
||||
AssemblyAnalyzer analyzer;
|
||||
|
||||
/**
|
||||
* Sets up the analyzer.
|
||||
*
|
||||
* @throws Exception if anything goes sideways
|
||||
*/
|
||||
@Before
|
||||
@@ -73,7 +80,7 @@ public class AssemblyAnalyzerTest {
|
||||
assertTrue(d.getProductEvidence().getEvidence().contains(new Evidence("grokassembly", "product", "log4net", Confidence.HIGH)));
|
||||
}
|
||||
|
||||
@Test(expected=AnalysisException.class)
|
||||
@Test(expected = AnalysisException.class)
|
||||
public void testNonexistent() throws Exception {
|
||||
File f = new File(AssemblyAnalyzerTest.class.getClassLoader().getResource("log4net.dll").getPath());
|
||||
File test = new File(f.getParent(), "nonexistent.dll");
|
||||
@@ -81,7 +88,11 @@ public class AssemblyAnalyzerTest {
|
||||
analyzer.analyze(d, null);
|
||||
}
|
||||
|
||||
@Test(expected=AnalysisException.class)
|
||||
@Rule
|
||||
public ConditionalIgnoreRule rule = new ConditionalIgnoreRule();
|
||||
|
||||
@Test()
|
||||
@ConditionalIgnore(condition = NotRunningOnWindows.class)
|
||||
public void testWithSettingMono() throws Exception {
|
||||
String oldValue = Settings.getString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH);
|
||||
// if oldValue is null, that means that neither the system property nor the setting has
|
||||
@@ -94,10 +105,14 @@ public class AssemblyAnalyzerTest {
|
||||
Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, "/yooser/bine/mono");
|
||||
}
|
||||
|
||||
//** @Test(expected = AnalysisException) doesn't seem to work with the conditional test **//
|
||||
AnalysisException aex = null;
|
||||
try {
|
||||
// Have to make a NEW analyzer because during setUp, it would have gotten the correct one
|
||||
AssemblyAnalyzer aanalyzer = new AssemblyAnalyzer();
|
||||
aanalyzer.initialize();
|
||||
} catch (AnalysisException ex) {
|
||||
aex = ex;
|
||||
} finally {
|
||||
// Now recover the way we came in. If we had to set a System property, delete it. Otherwise,
|
||||
// reset the old value
|
||||
@@ -107,6 +122,7 @@ public class AssemblyAnalyzerTest {
|
||||
Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, oldValue);
|
||||
}
|
||||
}
|
||||
assertNull("Excpted exception: org.owasp.dependencycheck.analyzer.AnalysisException", aex);
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
Reference in New Issue
Block a user