WebResourcesRuntimeHintsTests Class — spring-boot Architecture
Architecture documentation for the WebResourcesRuntimeHintsTests class in WebResourcesRuntimeHintsTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHintsTests.java lines 39–89
@WithResource(name = "web/custom-resource.txt")
class WebResourcesRuntimeHintsTests {
@Test
void registerHintsWithAllLocations() {
RuntimeHints hints = register(
new TestClassLoader(List.of("META-INF/resources/", "resources/", "static/", "public/")));
assertThat(hints.resources().resourcePatternHints()).singleElement()
.satisfies(include("META-INF/resources/**", "resources/**", "static/**", "public/**"));
}
@Test
void registerHintsWithOnlyStaticLocations() {
RuntimeHints hints = register(new TestClassLoader(List.of("static/")));
assertThat(hints.resources().resourcePatternHints()).singleElement().satisfies(include("static/**"));
}
@Test
void registerHintsWithNoLocation() {
RuntimeHints hints = register(new TestClassLoader(Collections.emptyList()));
assertThat(hints.resources().resourcePatternHints()).isEmpty();
}
private RuntimeHints register(ClassLoader classLoader) {
RuntimeHints hints = new RuntimeHints();
WebResourcesRuntimeHints registrar = new WebResourcesRuntimeHints();
registrar.registerHints(hints, classLoader);
return hints;
}
private Consumer<ResourcePatternHints> include(String... patterns) {
return (hint) -> assertThat(hint.getIncludes()).map(ResourcePatternHint::getPattern).contains(patterns);
}
private static class TestClassLoader extends ClassLoader {
private final List<String> availableResources;
TestClassLoader(List<String> availableResources) {
super(Thread.currentThread().getContextClassLoader());
this.availableResources = availableResources;
}
@Override
public @Nullable URL getResource(String name) {
return (this.availableResources.contains(name)) ? super.getResource("web/custom-resource.txt") : null;
}
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free