Accept only ClassPathResource in ResourceHints#registerResource()
This commit throws an exception in registerResource() if the supplied resource is not a ClassPathResource. See gh-29083
This commit is contained in:
@@ -117,8 +117,9 @@ class ResourceHintsTests {
|
||||
@Test
|
||||
void registerResourceWithUnsupportedResourceType() {
|
||||
DescriptiveResource resource = new DescriptiveResource("bogus");
|
||||
this.resourceHints.registerResource(resource);
|
||||
assertThat(this.resourceHints.resourcePatterns()).isEmpty();
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.resourceHints.registerResource(resource))
|
||||
.withMessage("Resource must be a ClassPathResource that exists: %s", resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,7 +127,7 @@ class ResourceHintsTests {
|
||||
ClassPathResource resource = new ClassPathResource("bogus", getClass());
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.resourceHints.registerResource(resource))
|
||||
.withMessage("Resource does not exist: %s", resource);
|
||||
.withMessage("Resource must be a ClassPathResource that exists: %s", resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user