|
|
|
@ -45,21 +45,21 @@ class ResourceHintsTests {
@@ -45,21 +45,21 @@ class ResourceHintsTests {
|
|
|
|
|
@Test |
|
|
|
|
void registerType() { |
|
|
|
|
this.resourceHints.registerType(String.class); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies( |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies( |
|
|
|
|
patternOf("java/lang/String.class")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void registerTypeWithNestedType() { |
|
|
|
|
this.resourceHints.registerType(TypeReference.of(Nested.class)); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies( |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies( |
|
|
|
|
patternOf("org/springframework/aot/hint/ResourceHintsTests$Nested.class")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void registerTypeWithInnerNestedType() { |
|
|
|
|
this.resourceHints.registerType(TypeReference.of(Inner.class)); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies( |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies( |
|
|
|
|
patternOf("org/springframework/aot/hint/ResourceHintsTests$Nested$Inner.class")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -67,7 +67,7 @@ class ResourceHintsTests {
@@ -67,7 +67,7 @@ class ResourceHintsTests {
|
|
|
|
|
void registerTypeSeveralTimesAddsOnlyOneEntry() { |
|
|
|
|
this.resourceHints.registerType(String.class); |
|
|
|
|
this.resourceHints.registerType(TypeReference.of(String.class)); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies( |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies( |
|
|
|
|
patternOf("java/lang/String.class")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -75,7 +75,7 @@ class ResourceHintsTests {
@@ -75,7 +75,7 @@ class ResourceHintsTests {
|
|
|
|
|
void registerExactMatch() { |
|
|
|
|
this.resourceHints.registerPattern("com/example/test.properties"); |
|
|
|
|
this.resourceHints.registerPattern("com/example/another.properties"); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()) |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()) |
|
|
|
|
.anySatisfy(patternOf("com/example/test.properties")) |
|
|
|
|
.anySatisfy(patternOf("com/example/another.properties")) |
|
|
|
|
.hasSize(2); |
|
|
|
@ -84,7 +84,7 @@ class ResourceHintsTests {
@@ -84,7 +84,7 @@ class ResourceHintsTests {
|
|
|
|
|
@Test |
|
|
|
|
void registerPattern() { |
|
|
|
|
this.resourceHints.registerPattern("com/example/*.properties"); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies( |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies( |
|
|
|
|
patternOf("com/example/*.properties")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -92,7 +92,7 @@ class ResourceHintsTests {
@@ -92,7 +92,7 @@ class ResourceHintsTests {
|
|
|
|
|
void registerPatternWithIncludesAndExcludes() { |
|
|
|
|
this.resourceHints.registerPattern(resourceHint -> |
|
|
|
|
resourceHint.includes("com/example/*.properties").excludes("com/example/to-ignore.properties")); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies(patternOf( |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies(patternOf( |
|
|
|
|
List.of("com/example/*.properties"), |
|
|
|
|
List.of("com/example/to-ignore.properties"))); |
|
|
|
|
} |
|
|
|
@ -101,7 +101,7 @@ class ResourceHintsTests {
@@ -101,7 +101,7 @@ class ResourceHintsTests {
|
|
|
|
|
void registerIfPresentRegisterExistingLocation() { |
|
|
|
|
this.resourceHints.registerPatternIfPresent(null, "META-INF/", |
|
|
|
|
resourceHint -> resourceHint.includes("com/example/*.properties")); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies( |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies( |
|
|
|
|
patternOf("com/example/*.properties")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -110,7 +110,7 @@ class ResourceHintsTests {
@@ -110,7 +110,7 @@ class ResourceHintsTests {
|
|
|
|
|
void registerIfPresentIgnoreMissingLocation() { |
|
|
|
|
Consumer<ResourcePatternHints.Builder> hintBuilder = mock(Consumer.class); |
|
|
|
|
this.resourceHints.registerPatternIfPresent(null, "location/does-not-exist/", hintBuilder); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).isEmpty(); |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).isEmpty(); |
|
|
|
|
verifyNoInteractions(hintBuilder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -135,7 +135,7 @@ class ResourceHintsTests {
@@ -135,7 +135,7 @@ class ResourceHintsTests {
|
|
|
|
|
String path = "org/springframework/aot/hint/support"; |
|
|
|
|
ClassPathResource resource = new ClassPathResource(path); |
|
|
|
|
this.resourceHints.registerResource(resource); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies(patternOf(path)); |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies(patternOf(path)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -143,13 +143,13 @@ class ResourceHintsTests {
@@ -143,13 +143,13 @@ class ResourceHintsTests {
|
|
|
|
|
String path = "org/springframework/aot/hint/support"; |
|
|
|
|
ClassPathResource resource = new ClassPathResource("support", RuntimeHints.class); |
|
|
|
|
this.resourceHints.registerResource(resource); |
|
|
|
|
assertThat(this.resourceHints.resourcePatterns()).singleElement().satisfies(patternOf(path)); |
|
|
|
|
assertThat(this.resourceHints.resourcePatternHints()).singleElement().satisfies(patternOf(path)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void registerResourceBundle() { |
|
|
|
|
this.resourceHints.registerResourceBundle("com.example.message"); |
|
|
|
|
assertThat(this.resourceHints.resourceBundles()).singleElement() |
|
|
|
|
assertThat(this.resourceHints.resourceBundleHints()).singleElement() |
|
|
|
|
.satisfies(resourceBundle("com.example.message")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -157,7 +157,7 @@ class ResourceHintsTests {
@@ -157,7 +157,7 @@ class ResourceHintsTests {
|
|
|
|
|
void registerResourceBundleSeveralTimesAddsOneEntry() { |
|
|
|
|
this.resourceHints.registerResourceBundle("com.example.message") |
|
|
|
|
.registerResourceBundle("com.example.message"); |
|
|
|
|
assertThat(this.resourceHints.resourceBundles()).singleElement() |
|
|
|
|
assertThat(this.resourceHints.resourceBundleHints()).singleElement() |
|
|
|
|
.satisfies(resourceBundle("com.example.message")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|