Harmonize accessors of RuntimeHints API
Closes gh-29269
This commit is contained in:
@@ -53,20 +53,20 @@ class ProxyHintsTests {
|
||||
@Test
|
||||
void registerJdkProxyWithInterface() {
|
||||
this.proxyHints.registerJdkProxy(Function.class);
|
||||
assertThat(this.proxyHints.jdkProxies()).singleElement().satisfies(proxiedInterfaces(Function.class));
|
||||
assertThat(this.proxyHints.jdkProxyHints()).singleElement().satisfies(proxiedInterfaces(Function.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerJdkProxyWithTypeReferences() {
|
||||
this.proxyHints.registerJdkProxy(TypeReference.of(Function.class), TypeReference.of("com.example.Advised"));
|
||||
assertThat(this.proxyHints.jdkProxies()).singleElement()
|
||||
assertThat(this.proxyHints.jdkProxyHints()).singleElement()
|
||||
.satisfies(proxiedInterfaces(Function.class.getName(), "com.example.Advised"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerJdkProxyWithConsumer() {
|
||||
this.proxyHints.registerJdkProxy(springProxy("com.example.Test"));
|
||||
assertThat(this.proxyHints.jdkProxies()).singleElement().satisfies(proxiedInterfaces(
|
||||
assertThat(this.proxyHints.jdkProxyHints()).singleElement().satisfies(proxiedInterfaces(
|
||||
"com.example.Test",
|
||||
"org.springframework.aop.SpringProxy",
|
||||
"org.springframework.aop.framework.Advised",
|
||||
@@ -77,7 +77,7 @@ class ProxyHintsTests {
|
||||
void registerJdkProxyTwiceExposesOneHint() {
|
||||
this.proxyHints.registerJdkProxy(Function.class);
|
||||
this.proxyHints.registerJdkProxy(TypeReference.of(Function.class.getName()));
|
||||
assertThat(this.proxyHints.jdkProxies()).singleElement().satisfies(proxiedInterfaces(Function.class));
|
||||
assertThat(this.proxyHints.jdkProxyHints()).singleElement().satisfies(proxiedInterfaces(Function.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 {
|
||||
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 {
|
||||
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 {
|
||||
@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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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"));
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class RuntimeHintsTests {
|
||||
@Test
|
||||
void resourceHintWithClass() {
|
||||
this.hints.resources().registerType(String.class);
|
||||
assertThat(this.hints.resources().resourcePatterns()).singleElement().satisfies(resourceHint -> {
|
||||
assertThat(this.hints.resources().resourcePatternHints()).singleElement().satisfies(resourceHint -> {
|
||||
assertThat(resourceHint.getIncludes()).map(ResourcePatternHint::getPattern).containsExactly("java/lang/String.class");
|
||||
assertThat(resourceHint.getExcludes()).isEmpty();
|
||||
});
|
||||
@@ -55,14 +55,14 @@ class RuntimeHintsTests {
|
||||
@Test
|
||||
void javaSerializationHintWithClass() {
|
||||
this.hints.serialization().registerType(String.class);
|
||||
assertThat(this.hints.serialization().javaSerialization().map(JavaSerializationHint::getType))
|
||||
assertThat(this.hints.serialization().javaSerializationHints().map(JavaSerializationHint::getType))
|
||||
.containsExactly(TypeReference.of(String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void jdkProxyWithClass() {
|
||||
this.hints.proxies().registerJdkProxy(Function.class);
|
||||
assertThat(this.hints.proxies().jdkProxies()).singleElement().satisfies(jdkProxyHint ->
|
||||
assertThat(this.hints.proxies().jdkProxyHints()).singleElement().satisfies(jdkProxyHint ->
|
||||
assertThat(jdkProxyHint.getProxiedInterfaces()).containsExactly(TypeReference.of(Function.class)));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class SerializationHintsTests {
|
||||
void registerTypeTwiceExposesOneHint() {
|
||||
this.serializationHints.registerType(URL.class);
|
||||
this.serializationHints.registerType(TypeReference.of(URL.class.getName()));
|
||||
assertThat(this.serializationHints.javaSerialization()).singleElement()
|
||||
assertThat(this.serializationHints.javaSerializationHints()).singleElement()
|
||||
.extracting(JavaSerializationHint::getType).isEqualTo(TypeReference.of(URL.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
void registerWithSinglePattern() {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test"), List.of(""), List.of(".txt"))
|
||||
.registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).singleElement()
|
||||
assertThat(this.hints.resourcePatternHints()).singleElement()
|
||||
.satisfies(includes("test*.txt"));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
void registerWithMultipleNames() {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test", "another"), List.of(""), List.of(".txt"))
|
||||
.registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).singleElement()
|
||||
assertThat(this.hints.resourcePatternHints()).singleElement()
|
||||
.satisfies(includes("test*.txt", "another*.txt"));
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
void registerWithMultipleLocations() {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test"), List.of("", "META-INF"), List.of(".txt"))
|
||||
.registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).singleElement()
|
||||
assertThat(this.hints.resourcePatternHints()).singleElement()
|
||||
.satisfies(includes("test*.txt", "META-INF/test*.txt"));
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
void registerWithMultipleExtensions() {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test"), List.of(""), List.of(".txt", ".conf"))
|
||||
.registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).singleElement()
|
||||
assertThat(this.hints.resourcePatternHints()).singleElement()
|
||||
.satisfies(includes("test*.txt", "test*.conf"));
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
void registerWithLocationWithoutTrailingSlash() {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test"), List.of("META-INF"), List.of(".txt"))
|
||||
.registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).singleElement()
|
||||
assertThat(this.hints.resourcePatternHints()).singleElement()
|
||||
.satisfies(includes("META-INF/test*.txt"));
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
void registerWithLocationWithLeadingSlash() {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test"), List.of("/"), List.of(".txt"))
|
||||
.registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).singleElement()
|
||||
assertThat(this.hints.resourcePatternHints()).singleElement()
|
||||
.satisfies(includes("test*.txt"));
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
void registerWithLocationUsingResourceClasspathPrefix() {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test"), List.of("classpath:META-INF"), List.of(".txt"))
|
||||
.registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).singleElement()
|
||||
assertThat(this.hints.resourcePatternHints()).singleElement()
|
||||
.satisfies(includes("META-INF/test*.txt"));
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
void registerWithLocationUsingResourceClasspathPrefixAndTrailingSlash() {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test"), List.of("classpath:/META-INF"), List.of(".txt"))
|
||||
.registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).singleElement()
|
||||
assertThat(this.hints.resourcePatternHints()).singleElement()
|
||||
.satisfies(includes("META-INF/test*.txt"));
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ class FilePatternResourceHintsRegistrarTests {
|
||||
new FilePatternResourceHintsRegistrar(List.of("test"),
|
||||
List.of("does-not-exist/", "another-does-not-exist/"),
|
||||
List.of(".txt")).registerHints(this.hints, null);
|
||||
assertThat(this.hints.resourcePatterns()).isEmpty();
|
||||
assertThat(this.hints.resourcePatternHints()).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user