Skip to content

Commit

Permalink
Temp: log bad resource loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Oct 16, 2023
1 parent 20cb05c commit 3385c9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
name: JBoss Modules CI

on:
push:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

Expand Down
14 changes: 10 additions & 4 deletions src/test/java/org/jboss/modules/ResourceRootPathsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.BasicFileAttributes;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -92,10 +95,10 @@ public void setupModuleLoader() throws Exception {
@Test
public void testPaths() throws Exception {
ConcreteModuleSpec moduleSpec = (ConcreteModuleSpec) moduleLoader.findModule("test.test");
ResourceLoaderSpec[] resourceLoaders = moduleSpec.getResourceLoaders();
ResourceLoaderSpec[] resourceLoaderSpecs = moduleSpec.getResourceLoaders();
List<ResourceLoader> resourceLoaders = Stream.of(resourceLoaderSpecs).map(ResourceLoaderSpec::getResourceLoader).collect(Collectors.toList());
int checkCount = 0;
for (ResourceLoaderSpec r : resourceLoaders) {
ResourceLoader resourceLoader = r.getResourceLoader();
for (ResourceLoader resourceLoader : resourceLoaders) {
if (resourceLoader instanceof JarFileResourceLoader) {
final File jar = getFileFromJarUri(resourceLoader.getLocation());

Expand All @@ -110,6 +113,8 @@ public void testPaths() throws Exception {
checkCount++;
continue;
}

System.err.printf("JAR was neither %s nor %s, but %s%n", testModuleRoot, repoRoot, jar.getParentFile());
} else if (resourceLoader instanceof PathResourceLoader) {
final File dir = new File(resourceLoader.getLocation());

Expand All @@ -124,9 +129,10 @@ public void testPaths() throws Exception {
checkCount++;
continue;
}
System.err.printf("Directory was neither %s nor %s, but %s%n", testModuleRoot, repoRoot, dir.getParentFile());
}
}
Assert.assertEquals("Test should have checked 4 ResourceLoaders", 4, checkCount);
Assert.assertEquals("Test should have checked 4 ResourceLoaders: " + List.of(resourceLoaders), 4, checkCount);
}

private File getFileFromJarUri(URI uri) throws Exception {
Expand Down

0 comments on commit 3385c9e

Please sign in to comment.