test: avoid polluting test classpaths with sample dependencies to be scanned#8267
Merged
jeremylong merged 1 commit intodependency-check:mainfrom Feb 2, 2026
Merged
Conversation
…scanned Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
chadlwilson
commented
Jan 31, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses test environment pollution by changing how sample dependencies are made available during testing. Instead of adding test-scoped dependencies to the classpath (which can cause conflicts with JDK ServiceLoader mechanisms), the PR uses Maven's dependency plugin to copy artifacts to a dedicated maven-lib test resource directory.
Changes:
- Refactored Maven build configuration to copy sample artifacts to
target/test-classes/maven-libinstead of adding them as test-scoped dependencies - Updated all test file paths to reference the new
maven-lib/subdirectory - Streamlined integration test error handling with more maintainable assertions
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| core/pom.xml | Replaced test-scoped dependencies and copy-dependencies execution with a targeted copy execution that places artifacts in maven-lib subdirectory |
| core/src/test/java/org/owasp/dependencycheck/BaseTest.java | Removed JCS logging setup and improved resource loading methods to use Objects.requireNonNull instead of JUnit assumptions |
| core/src/test/java/org/owasp/dependencycheck/EngineIT.java | Refactored exception handling in integration test to use streams and assertions, replacing Set-based error filtering |
| core/src/test/java/org/owasp/dependencycheck/xml/suppression/SuppressionRuleTest.java | Updated resource paths to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/xml/suppression/SuppressionParserTest.java | Removed commented-out code |
| core/src/test/java/org/owasp/dependencycheck/reporting/ReportGeneratorIT.java | Updated resource paths to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/dependency/DependencyTest.java | Updated resource paths to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/data/update/NvdApiDataSourceTest.java | Removed unused import and annotation from method signature |
| core/src/test/java/org/owasp/dependencycheck/data/nvdcve/DriverLoaderTest.java | Removed commented-out code |
| core/src/test/java/org/owasp/dependencycheck/analyzer/VulnerabilitySuppressionAnalyzerIT.java | Updated resource path to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/analyzer/JarAnalyzerTest.java | Updated resource paths to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/analyzer/HintAnalyzerTest.java | Updated resource paths to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/analyzer/FileNameAnalyzerTest.java | Updated resource paths to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/analyzer/DependencyMergingAnalyzerTest.java | Updated resource path to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/analyzer/CpeSuppressionAnalyzerIT.java | Updated resource path to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/analyzer/CPEAnalyzerIT.java | Updated resource paths to include maven-lib/ prefix |
| core/src/test/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzerIT.java | Updated resource path to include maven-lib/ prefix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chadlwilson
commented
Jan 31, 2026
This was referenced Feb 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
As mentioned in #8254 (comment) currently the XML testing is a bit unreliable and difficult to debug because xerces and xml-apis dependencies are being pulled down and used during testing due to their inclusion within artifacts that are intended just for use as "sample" artifacts to scan using ODC code.
Other than the risk of classpath clashes, when code uses JDK
ServiceLoadermechanisms (such as the XML APIs), I think this can cause production code to be tested with an environment unrepresentative of a real deployment.We can address this by creating a maven execution that copies dependencies as artifacts to a known test resource location rather than adding to the actual test/integration test classpaths.
Minor tweaks
Related issues
Have test cases been added to cover the new functionality?
yes