Merge branch 'hansjoachim-upgrades'

Former-commit-id: 6e19e7b75a4481314adb9b74586541a582a98018
This commit is contained in:
Jeremy Long
2015-06-07 06:43:02 -04:00
3 changed files with 31 additions and 16 deletions

View File

@@ -423,12 +423,10 @@ Copyright (c) 2013 - Jeremy Long. All Rights Reserved.
<dependency> <dependency>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId> <artifactId>ant</artifactId>
<version>1.9.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant-testutil</artifactId> <artifactId>ant-testutil</artifactId>
<version>1.9.4</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -18,34 +18,41 @@
package org.owasp.dependencycheck.taskdefs; package org.owasp.dependencycheck.taskdefs;
import java.io.File; import java.io.File;
import org.apache.tools.ant.BuildFileTest;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileRule;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.owasp.dependencycheck.data.nvdcve.BaseDBTestCase; import org.owasp.dependencycheck.data.nvdcve.BaseDBTestCase;
import org.owasp.dependencycheck.utils.Settings; import org.owasp.dependencycheck.utils.Settings;
import static org.junit.Assert.assertTrue;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class DependencyCheckTaskTest extends BuildFileTest { public class DependencyCheckTaskTest {
//TODO: The use of deprecated class BuildFileTestcan possibly
//be replaced with BuildFileRule. However, it currently isn't included in the ant-testutil jar. @Rule
//This should be fixed in ant-testutil 1.9.5, so we can check back once that has been released. public BuildFileRule buildFileRule = new BuildFileRule();
//Reference: http://mail-archives.apache.org/mod_mbox/ant-user/201406.mbox/%3C000001cf87ba$8949b690$9bdd23b0$@de%3E
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Before @Before
@Override
public void setUp() throws Exception { public void setUp() throws Exception {
Settings.initialize(); Settings.initialize();
BaseDBTestCase.ensureDBExists(); BaseDBTestCase.ensureDBExists();
final String buildFile = this.getClass().getClassLoader().getResource("build.xml").getPath(); final String buildFile = this.getClass().getClassLoader().getResource("build.xml").getPath();
configureProject(buildFile); buildFileRule.configureProject(buildFile);
} }
@After @After
@Override
public void tearDown() { public void tearDown() {
//no cleanup... //no cleanup...
//executeTarget("cleanup"); //executeTarget("cleanup");
@@ -63,7 +70,7 @@ public class DependencyCheckTaskTest extends BuildFileTest {
throw new Exception("Unable to delete 'target/DependencyCheck-Report.html' prior to test."); throw new Exception("Unable to delete 'target/DependencyCheck-Report.html' prior to test.");
} }
} }
executeTarget("test.fileset"); buildFileRule.executeTarget("test.fileset");
assertTrue("DependencyCheck report was not generated", report.exists()); assertTrue("DependencyCheck report was not generated", report.exists());
@@ -82,7 +89,7 @@ public class DependencyCheckTaskTest extends BuildFileTest {
throw new Exception("Unable to delete 'target/DependencyCheck-Report.xml' prior to test."); throw new Exception("Unable to delete 'target/DependencyCheck-Report.xml' prior to test.");
} }
} }
executeTarget("test.filelist"); buildFileRule.executeTarget("test.filelist");
assertTrue("DependencyCheck report was not generated", report.exists()); assertTrue("DependencyCheck report was not generated", report.exists());
} }
@@ -100,7 +107,7 @@ public class DependencyCheckTaskTest extends BuildFileTest {
throw new Exception("Unable to delete 'target/DependencyCheck-Vulnerability.html' prior to test."); throw new Exception("Unable to delete 'target/DependencyCheck-Vulnerability.html' prior to test.");
} }
} }
executeTarget("test.dirset"); buildFileRule.executeTarget("test.dirset");
assertTrue("DependencyCheck report was not generated", report.exists()); assertTrue("DependencyCheck report was not generated", report.exists());
} }
@@ -109,7 +116,7 @@ public class DependencyCheckTaskTest extends BuildFileTest {
*/ */
@Test @Test
public void testGetFailBuildOnCVSS() { public void testGetFailBuildOnCVSS() {
expectBuildException("failCVSS", "asdfasdfscore"); expectedException.expect(BuildException.class);
System.out.println(this.getOutput()); buildFileRule.executeTarget("failCVSS");
} }
} }

10
pom.xml
View File

@@ -359,6 +359,16 @@ Copyright (c) 2012 - Jeremy Long
<version>4.12</version> <version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-testutil</artifactId>
<version>1.9.5</version>
</dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId> <artifactId>hamcrest-core</artifactId>