Skip to content

Commit

Permalink
chore: Remove unnecessary class loaded check in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aikebah committed Sep 9, 2024
1 parent c1b0e7a commit b676748
Showing 1 changed file with 0 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void setUp() throws Exception {
*/
@Test
public void testZippableExtensions() throws Exception {
assumeFalse(isPreviouslyLoaded("org.owasp.dependencycheck.analyzer.ArchiveAnalyzer"));
ArchiveAnalyzer instance = new ArchiveAnalyzer();
instance.initialize(getSettings());
assertTrue(instance.getFileFilter().accept(new File("c:/test.zip")));
Expand All @@ -61,21 +60,9 @@ public void testZippableExtensions() throws Exception {
*/
@Test
public void testRpmExtension() throws Exception {
assumeFalse(isPreviouslyLoaded("org.owasp.dependencycheck.analyzer.ArchiveAnalyzer"));
ArchiveAnalyzer instance = new ArchiveAnalyzer();
instance.initialize(getSettings());
assertTrue(instance.getFileFilter().accept(new File("/srv/struts-1.2.9-162.35.1.uyuni.noarch.rpm")));
}

private boolean isPreviouslyLoaded(String className) {
try {
Method m = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
m.setAccessible(true);
Object t = m.invoke(Thread.currentThread().getContextClassLoader(), className);
return t != null;
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(ArchiveAnalyzerTest.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
}

0 comments on commit b676748

Please sign in to comment.