Browse Source

Harmonize accessors of RuntimeHints API

Closes gh-29269
pull/29282/head
Stephane Nicoll 2 years ago
parent
commit
efaee61f31
  1. 2
      spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorAotContributionTests.java
  2. 16
      spring-context/src/test/java/org/springframework/context/aot/ApplicationContextAotGeneratorTests.java
  3. 4
      spring-context/src/test/java/org/springframework/context/aot/RuntimeHintsBeanFactoryInitializationAotProcessorTests.java
  4. 6
      spring-core-test/src/main/java/org/springframework/aot/agent/HintType.java
  5. 2
      spring-core/src/main/java/org/springframework/aot/hint/ProxyHints.java
  6. 4
      spring-core/src/main/java/org/springframework/aot/hint/ResourceHints.java
  7. 2
      spring-core/src/main/java/org/springframework/aot/hint/SerializationHints.java
  8. 2
      spring-core/src/main/java/org/springframework/aot/hint/predicate/ProxyHintsPredicates.java
  9. 4
      spring-core/src/main/java/org/springframework/aot/hint/predicate/ResourceHintsPredicates.java
  10. 2
      spring-core/src/main/java/org/springframework/aot/hint/predicate/SerializationHintsPredicates.java
  11. 12
      spring-core/src/main/java/org/springframework/aot/nativex/NativeConfigurationWriter.java
  12. 2
      spring-core/src/main/java/org/springframework/aot/nativex/ProxyHintsWriter.java
  13. 6
      spring-core/src/main/java/org/springframework/aot/nativex/ResourceHintsWriter.java
  14. 2
      spring-core/src/main/java/org/springframework/aot/nativex/SerializationHintsWriter.java
  15. 8
      spring-core/src/test/java/org/springframework/aot/hint/ProxyHintsTests.java
  16. 26
      spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsTests.java
  17. 6
      spring-core/src/test/java/org/springframework/aot/hint/RuntimeHintsTests.java
  18. 2
      spring-core/src/test/java/org/springframework/aot/hint/SerializationHintsTests.java
  19. 18
      spring-core/src/test/java/org/springframework/aot/hint/support/FilePatternResourceHintsRegistrarTests.java

2
spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorAotContributionTests.java

@ -145,7 +145,7 @@ class ConfigurationClassPostProcessorAotContributionTests { @@ -145,7 +145,7 @@ class ConfigurationClassPostProcessorAotContributionTests {
void applyToWhenHasImportAwareConfigurationRegistersHints() {
BeanFactoryInitializationAotContribution contribution = getContribution(ImportConfiguration.class);
contribution.applyTo(generationContext, beanFactoryInitializationCode);
assertThat(generationContext.getRuntimeHints().resources().resourcePatterns())
assertThat(generationContext.getRuntimeHints().resources().resourcePatternHints())
.singleElement()
.satisfies(resourceHint -> assertThat(resourceHint.getIncludes())
.map(ResourcePatternHint::getPattern)

16
spring-context/src/test/java/org/springframework/context/aot/ApplicationContextAotGeneratorTests.java

@ -121,8 +121,8 @@ class ApplicationContextAotGeneratorTests { @@ -121,8 +121,8 @@ class ApplicationContextAotGeneratorTests {
ResourceLoader resourceLoader = bean.getResourceLoader();
assertThat(resourceLoader).isNotInstanceOf(Proxy.class);
RuntimeHints runtimeHints = generationContext.getRuntimeHints();
assertThat(runtimeHints.proxies().jdkProxies()).satisfies(doesNotHaveProxyFor(ResourceLoader.class));
assertThat(runtimeHints.proxies().jdkProxies()).anySatisfy(proxyHint ->
assertThat(runtimeHints.proxies().jdkProxyHints()).satisfies(doesNotHaveProxyFor(ResourceLoader.class));
assertThat(runtimeHints.proxies().jdkProxyHints()).anySatisfy(proxyHint ->
assertThat(proxyHint.getProxiedInterfaces()).isEqualTo(TypeReference.listOf(
environment.getClass().getInterfaces())));
@ -137,8 +137,8 @@ class ApplicationContextAotGeneratorTests { @@ -137,8 +137,8 @@ class ApplicationContextAotGeneratorTests {
ResourceLoader resourceLoader = bean.getResourceLoader();
assertThat(resourceLoader).isInstanceOf(Proxy.class);
RuntimeHints runtimeHints = generationContext.getRuntimeHints();
assertThat(runtimeHints.proxies().jdkProxies()).satisfies(doesNotHaveProxyFor(Environment.class));
assertThat(runtimeHints.proxies().jdkProxies()).anySatisfy(proxyHint ->
assertThat(runtimeHints.proxies().jdkProxyHints()).satisfies(doesNotHaveProxyFor(Environment.class));
assertThat(runtimeHints.proxies().jdkProxyHints()).anySatisfy(proxyHint ->
assertThat(proxyHint.getProxiedInterfaces()).isEqualTo(TypeReference.listOf(
resourceLoader.getClass().getInterfaces())));
});
@ -152,8 +152,8 @@ class ApplicationContextAotGeneratorTests { @@ -152,8 +152,8 @@ class ApplicationContextAotGeneratorTests {
ResourceLoader resourceLoader = bean.getResourceLoader();
assertThat(resourceLoader).isNotInstanceOf(Proxy.class);
RuntimeHints runtimeHints = generationContext.getRuntimeHints();
assertThat(runtimeHints.proxies().jdkProxies()).satisfies(doesNotHaveProxyFor(ResourceLoader.class));
assertThat(runtimeHints.proxies().jdkProxies()).anySatisfy(proxyHint ->
assertThat(runtimeHints.proxies().jdkProxyHints()).satisfies(doesNotHaveProxyFor(ResourceLoader.class));
assertThat(runtimeHints.proxies().jdkProxyHints()).anySatisfy(proxyHint ->
assertThat(proxyHint.getProxiedInterfaces()).isEqualTo(TypeReference.listOf(
environment.getClass().getInterfaces())));
});
@ -169,8 +169,8 @@ class ApplicationContextAotGeneratorTests { @@ -169,8 +169,8 @@ class ApplicationContextAotGeneratorTests {
ResourceLoader resourceLoader = bean.getResourceLoader();
assertThat(resourceLoader).isNotInstanceOf(Proxy.class);
RuntimeHints runtimeHints = generationContext.getRuntimeHints();
assertThat(runtimeHints.proxies().jdkProxies()).satisfies(doesNotHaveProxyFor(ResourceLoader.class));
assertThat(runtimeHints.proxies().jdkProxies()).anySatisfy(proxyHint ->
assertThat(runtimeHints.proxies().jdkProxyHints()).satisfies(doesNotHaveProxyFor(ResourceLoader.class));
assertThat(runtimeHints.proxies().jdkProxyHints()).anySatisfy(proxyHint ->
assertThat(proxyHint.getProxiedInterfaces()).isEqualTo(TypeReference.listOf(
environment.getClass().getInterfaces())));
});

4
spring-context/src/test/java/org/springframework/context/aot/RuntimeHintsBeanFactoryInitializationAotProcessorTests.java

@ -100,7 +100,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests { @@ -100,7 +100,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests {
this.generator.processAheadOfTime(applicationContext,
this.generationContext);
RuntimeHints runtimeHints = this.generationContext.getRuntimeHints();
assertThat(runtimeHints.resources().resourceBundles().map(ResourceBundleHint::getBaseName))
assertThat(runtimeHints.resources().resourceBundleHints().map(ResourceBundleHint::getBaseName))
.containsOnly("com.example.example0", "sample");
assertThat(IncrementalRuntimeHintsRegistrar.counter.get()).isEqualTo(1);
}
@ -116,7 +116,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests { @@ -116,7 +116,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests {
private void assertThatSampleRegistrarContributed() {
Stream<ResourceBundleHint> bundleHints = this.generationContext.getRuntimeHints()
.resources().resourceBundles();
.resources().resourceBundleHints();
assertThat(bundleHints)
.anyMatch(bundleHint -> "sample".equals(bundleHint.getBaseName()));
}

6
spring-core-test/src/main/java/org/springframework/aot/agent/HintType.java

@ -40,12 +40,12 @@ public enum HintType { @@ -40,12 +40,12 @@ public enum HintType {
REFLECTION(ReflectionHints.class),
/**
* Resource pattern hint, as described by {@link org.springframework.aot.hint.ResourceHints#resourcePatterns()}.
* Resource pattern hint, as described by {@link org.springframework.aot.hint.ResourceHints#resourcePatternHints()}.
*/
RESOURCE_PATTERN(ResourcePatternHint.class),
/**
* Resource bundle hint, as described by {@link org.springframework.aot.hint.ResourceHints#resourceBundles()}.
* Resource bundle hint, as described by {@link org.springframework.aot.hint.ResourceHints#resourceBundleHints()}.
*/
RESOURCE_BUNDLE(ResourceBundleHint.class),
@ -55,7 +55,7 @@ public enum HintType { @@ -55,7 +55,7 @@ public enum HintType {
JAVA_SERIALIZATION(JavaSerializationHint.class),
/**
* JDK proxies hint, as described by {@link org.springframework.aot.hint.ProxyHints#jdkProxies()}.
* JDK proxies hint, as described by {@link org.springframework.aot.hint.ProxyHints#jdkProxyHints()}.
*/
JDK_PROXIES(JdkProxyHint.class);

2
spring-core/src/main/java/org/springframework/aot/hint/ProxyHints.java

@ -36,7 +36,7 @@ public class ProxyHints { @@ -36,7 +36,7 @@ public class ProxyHints {
* Return the interface-based proxies that are required.
* @return a stream of {@link JdkProxyHint}
*/
public Stream<JdkProxyHint> jdkProxies() {
public Stream<JdkProxyHint> jdkProxyHints() {
return this.jdkProxies.stream();
}

4
spring-core/src/main/java/org/springframework/aot/hint/ResourceHints.java

@ -54,7 +54,7 @@ public class ResourceHints { @@ -54,7 +54,7 @@ public class ResourceHints {
* Return the resources that should be made available at runtime.
* @return a stream of {@link ResourcePatternHints}
*/
public Stream<ResourcePatternHints> resourcePatterns() {
public Stream<ResourcePatternHints> resourcePatternHints() {
Stream<ResourcePatternHints> patterns = this.resourcePatternHints.stream();
return (this.types.isEmpty() ? patterns
: Stream.concat(Stream.of(typesPatternResourceHint()), patterns));
@ -64,7 +64,7 @@ public class ResourceHints { @@ -64,7 +64,7 @@ public class ResourceHints {
* Return the resource bundles that should be made available at runtime.
* @return a stream of {@link ResourceBundleHint}
*/
public Stream<ResourceBundleHint> resourceBundles() {
public Stream<ResourceBundleHint> resourceBundleHints() {
return this.resourceBundleHints.stream();
}

2
spring-core/src/main/java/org/springframework/aot/hint/SerializationHints.java

@ -45,7 +45,7 @@ public class SerializationHints { @@ -45,7 +45,7 @@ public class SerializationHints {
* that need to be serialized using Java serialization at runtime.
* @return a stream of {@link JavaSerializationHint java serialization hints}
*/
public Stream<JavaSerializationHint> javaSerialization() {
public Stream<JavaSerializationHint> javaSerializationHints() {
return this.javaSerializationHints.stream();
}

2
spring-core/src/main/java/org/springframework/aot/hint/predicate/ProxyHintsPredicates.java

@ -61,7 +61,7 @@ public class ProxyHintsPredicates { @@ -61,7 +61,7 @@ public class ProxyHintsPredicates {
public Predicate<RuntimeHints> forInterfaces(TypeReference... interfaces) {
Assert.notEmpty(interfaces, "'interfaces' should not be empty");
List<TypeReference> interfaceList = Arrays.asList(interfaces);
return hints -> hints.proxies().jdkProxies().anyMatch(proxyHint ->
return hints -> hints.proxies().jdkProxyHints().anyMatch(proxyHint ->
proxyHint.getProxiedInterfaces().equals(interfaceList));
}

4
spring-core/src/main/java/org/springframework/aot/hint/predicate/ResourceHintsPredicates.java

@ -51,7 +51,7 @@ public class ResourceHintsPredicates { @@ -51,7 +51,7 @@ public class ResourceHintsPredicates {
*/
public Predicate<RuntimeHints> forBundle(String bundleName) {
Assert.hasText(bundleName, "resource bundle name should not be empty");
return runtimeHints -> runtimeHints.resources().resourceBundles()
return runtimeHints -> runtimeHints.resources().resourceBundleHints()
.anyMatch(bundleHint -> bundleName.equals(bundleHint.getBaseName()));
}
@ -115,7 +115,7 @@ public class ResourceHintsPredicates { @@ -115,7 +115,7 @@ public class ResourceHintsPredicates {
static AggregatedResourcePatternHints of(ResourceHints resourceHints) {
List<ResourcePatternHint> includes = new ArrayList<>();
List<ResourcePatternHint> excludes = new ArrayList<>();
resourceHints.resourcePatterns().forEach(resourcePatternHint -> {
resourceHints.resourcePatternHints().forEach(resourcePatternHint -> {
includes.addAll(resourcePatternHint.getIncludes());
excludes.addAll(resourcePatternHint.getExcludes());
});

2
spring-core/src/main/java/org/springframework/aot/hint/predicate/SerializationHintsPredicates.java

@ -56,7 +56,7 @@ public class SerializationHintsPredicates { @@ -56,7 +56,7 @@ public class SerializationHintsPredicates {
*/
public Predicate<RuntimeHints> onType(TypeReference typeReference) {
Assert.notNull(typeReference, "'typeReference' should not be null");
return hints -> hints.serialization().javaSerialization().anyMatch(
return hints -> hints.serialization().javaSerializationHints().anyMatch(
hint -> hint.getType().equals(typeReference));
}

12
spring-core/src/main/java/org/springframework/aot/nativex/NativeConfigurationWriter.java

@ -40,17 +40,17 @@ public abstract class NativeConfigurationWriter { @@ -40,17 +40,17 @@ public abstract class NativeConfigurationWriter {
* @param hints the hints to handle
*/
public void write(RuntimeHints hints) {
if (hints.serialization().javaSerialization().findAny().isPresent()) {
writeJavaSerializationHints(hints.serialization());
if (hints.serialization().javaSerializationHints().findAny().isPresent()) {
writeSerializationHints(hints.serialization());
}
if (hints.proxies().jdkProxies().findAny().isPresent()) {
if (hints.proxies().jdkProxyHints().findAny().isPresent()) {
writeProxyHints(hints.proxies());
}
if (hints.reflection().typeHints().findAny().isPresent()) {
writeReflectionHints(hints.reflection());
}
if (hints.resources().resourcePatterns().findAny().isPresent() ||
hints.resources().resourceBundles().findAny().isPresent()) {
if (hints.resources().resourcePatternHints().findAny().isPresent() ||
hints.resources().resourceBundleHints().findAny().isPresent()) {
writeResourceHints(hints.resources());
}
if (hints.jni().typeHints().findAny().isPresent()) {
@ -66,7 +66,7 @@ public abstract class NativeConfigurationWriter { @@ -66,7 +66,7 @@ public abstract class NativeConfigurationWriter {
*/
protected abstract void writeTo(String fileName, Consumer<BasicJsonWriter> writer);
private void writeJavaSerializationHints(SerializationHints hints) {
private void writeSerializationHints(SerializationHints hints) {
writeTo("serialization-config.json", writer ->
SerializationHintsWriter.INSTANCE.write(writer, hints));
}

2
spring-core/src/main/java/org/springframework/aot/nativex/ProxyHintsWriter.java

@ -39,7 +39,7 @@ class ProxyHintsWriter { @@ -39,7 +39,7 @@ class ProxyHintsWriter {
public static final ProxyHintsWriter INSTANCE = new ProxyHintsWriter();
public void write(BasicJsonWriter writer, ProxyHints hints) {
writer.writeArray(hints.jdkProxies().map(this::toAttributes).toList());
writer.writeArray(hints.jdkProxyHints().map(this::toAttributes).toList());
}
private Map<String, Object> toAttributes(JdkProxyHint hint) {

6
spring-core/src/main/java/org/springframework/aot/nativex/ResourceHintsWriter.java

@ -47,15 +47,15 @@ class ResourceHintsWriter { @@ -47,15 +47,15 @@ class ResourceHintsWriter {
public void write(BasicJsonWriter writer, ResourceHints hints) {
Map<String, Object> attributes = new LinkedHashMap<>();
addIfNotEmpty(attributes, "resources", toAttributes(hints));
handleResourceBundles(attributes, hints.resourceBundles());
handleResourceBundles(attributes, hints.resourceBundleHints());
writer.writeObject(attributes);
}
private Map<String, Object> toAttributes(ResourceHints hint) {
Map<String, Object> attributes = new LinkedHashMap<>();
addIfNotEmpty(attributes, "includes", hint.resourcePatterns().map(ResourcePatternHints::getIncludes)
addIfNotEmpty(attributes, "includes", hint.resourcePatternHints().map(ResourcePatternHints::getIncludes)
.flatMap(List::stream).distinct().map(this::toAttributes).toList());
addIfNotEmpty(attributes, "excludes", hint.resourcePatterns().map(ResourcePatternHints::getExcludes)
addIfNotEmpty(attributes, "excludes", hint.resourcePatternHints().map(ResourcePatternHints::getExcludes)
.flatMap(List::stream).distinct().map(this::toAttributes).toList());
return attributes;
}

2
spring-core/src/main/java/org/springframework/aot/nativex/SerializationHintsWriter.java

@ -39,7 +39,7 @@ class SerializationHintsWriter { @@ -39,7 +39,7 @@ class SerializationHintsWriter {
public static final SerializationHintsWriter INSTANCE = new SerializationHintsWriter();
public void write(BasicJsonWriter writer, SerializationHints hints) {
writer.writeArray(hints.javaSerialization().map(this::toAttributes).toList());
writer.writeArray(hints.javaSerializationHints().map(this::toAttributes).toList());
}
private Map<String, Object> toAttributes(JavaSerializationHint serializationHint) {

8
spring-core/src/test/java/org/springframework/aot/hint/ProxyHintsTests.java

@ -53,20 +53,20 @@ class ProxyHintsTests { @@ -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 { @@ -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));
}

26
spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsTests.java

@ -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"));
}

6
spring-core/src/test/java/org/springframework/aot/hint/RuntimeHintsTests.java

@ -46,7 +46,7 @@ class RuntimeHintsTests { @@ -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 { @@ -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)));
}

2
spring-core/src/test/java/org/springframework/aot/hint/SerializationHintsTests.java

@ -35,7 +35,7 @@ class SerializationHintsTests { @@ -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));
}

18
spring-core/src/test/java/org/springframework/aot/hint/support/FilePatternResourceHintsRegistrarTests.java

@ -55,7 +55,7 @@ class FilePatternResourceHintsRegistrarTests { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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();
}

Loading…
Cancel
Save