Migrate to updated native hints API and new reachability JSON
Replace hint API calls with updated version and fix tests that relied on previous JSON files. See gh-45487 Co-authored-by: Phillip Webb <phil.webb@broadcom.com>
This commit is contained in:
committed by
Phillip Webb
parent
5ea0674bad
commit
a0944b00d0
@@ -38,7 +38,7 @@ class CloudFoundryWebFluxEndpointHandlerMappingTests {
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
new CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints().registerHints(runtimeHints,
|
||||
getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(CloudFoundryLinksHandler.class, "links").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(CloudFoundryLinksHandler.class, "links"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(Link.class)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class CloudFoundryWebEndpointServletHandlerMappingTests {
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
new CloudFoundryWebEndpointServletHandlerMappingRuntimeHints().registerHints(runtimeHints,
|
||||
getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(CloudFoundryLinksHandler.class, "links").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(CloudFoundryLinksHandler.class, "links"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(Link.class)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -84,7 +84,7 @@ class ServiceLevelObjectiveBoundaryTests {
|
||||
getClass().getClassLoader());
|
||||
ReflectionUtils.doWithLocalMethods(ServiceLevelObjectiveBoundary.class, (method) -> {
|
||||
if ("valueOf".equals(method.getName())) {
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(method)).accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(method)).accepts(runtimeHints);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,7 +47,7 @@ class OperationReflectiveProcessorTests {
|
||||
void shouldRegisterMethodAsInvokable() {
|
||||
Method method = ReflectionUtils.findMethod(Methods.class, "string");
|
||||
runProcessor(method);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(method)).accepts(this.runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(method)).accepts(this.runtimeHints);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,12 +82,10 @@ class OperationReflectiveProcessorTests {
|
||||
private void assertHintsForDto() {
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(Dto.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(this.runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(NestedDto.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(this.runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.runtimeHints);
|
||||
}
|
||||
|
||||
private void runProcessor(Method method) {
|
||||
|
||||
@@ -37,7 +37,7 @@ class WebFluxEndpointHandlerMappingTests {
|
||||
void shouldRegisterHints() {
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
new WebFluxEndpointHandlerMappingRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(WebFluxLinksHandler.class, "links").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(WebFluxLinksHandler.class, "links"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(Link.class)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class WebMvcEndpointHandlerMappingTests {
|
||||
void shouldRegisterHints() {
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
new WebMvcEndpointHandlerMappingRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(WebMvcLinksHandler.class, "links").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(WebMvcLinksHandler.class, "links"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(Link.class)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,8 +41,7 @@ class HealthEndpointWebExtensionRuntimeHintsTests {
|
||||
for (Class<?> bindingType : bindingTypes) {
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(bindingType)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,8 +39,7 @@ class BuildInfoContributorTests {
|
||||
new BuildInfoContributorRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(BuildProperties.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -90,8 +90,7 @@ class GitInfoContributorTests {
|
||||
new GitInfoContributorRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(GitProperties.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,8 +49,7 @@ class JavaInfoContributorTests {
|
||||
new JavaInfoContributorRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(JavaInfo.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,8 +49,7 @@ class OsInfoContributorTests {
|
||||
new OsInfoContributorRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(OsInfo.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ class ProcessInfoContributorTests {
|
||||
new ProcessInfoContributorRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(ProcessInfo.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,8 +56,7 @@ class SslInfoContributorTests {
|
||||
new SslInfoContributorRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(SslInfo.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -164,16 +164,17 @@ class LoggersEndpointTests {
|
||||
new ReflectiveRuntimeHintsRegistrar().registerRuntimeHints(runtimeHints, LoggersEndpoint.class);
|
||||
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
|
||||
assertThat(reflection.onType(LoggerLevelsDescriptor.class)).accepts(runtimeHints);
|
||||
assertThat(reflection.onMethod(LoggerLevelsDescriptor.class, "getConfiguredLevel").invoke())
|
||||
assertThat(reflection.onMethodInvocation(LoggerLevelsDescriptor.class, "getConfiguredLevel"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(reflection.onType(SingleLoggerLevelsDescriptor.class)).accepts(runtimeHints);
|
||||
assertThat(reflection.onMethod(SingleLoggerLevelsDescriptor.class, "getEffectiveLevel").invoke())
|
||||
assertThat(reflection.onMethodInvocation(SingleLoggerLevelsDescriptor.class, "getEffectiveLevel"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(reflection.onMethod(SingleLoggerLevelsDescriptor.class, "getConfiguredLevel").invoke())
|
||||
assertThat(reflection.onMethodInvocation(SingleLoggerLevelsDescriptor.class, "getConfiguredLevel"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(reflection.onType(GroupLoggerLevelsDescriptor.class)).accepts(runtimeHints);
|
||||
assertThat(reflection.onMethod(GroupLoggerLevelsDescriptor.class, "getMembers").invoke()).accepts(runtimeHints);
|
||||
assertThat(reflection.onMethod(GroupLoggerLevelsDescriptor.class, "getConfiguredLevel").invoke())
|
||||
assertThat(reflection.onMethodInvocation(GroupLoggerLevelsDescriptor.class, "getMembers"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(reflection.onMethodInvocation(GroupLoggerLevelsDescriptor.class, "getConfiguredLevel"))
|
||||
.accepts(runtimeHints);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class HazelcastCacheMeterBinderProviderTests {
|
||||
void shouldRegisterHints() {
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
new HazelcastCacheMeterBinderProviderRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(HazelcastCache.class, "getNativeCache").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(HazelcastCache.class, "getNativeCache"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(HazelcastCacheMetrics.class)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -105,8 +105,7 @@ class QuartzEndpointWebExtensionTests {
|
||||
for (Class<?> bindingType : bindingTypes) {
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(bindingType)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -206,8 +206,7 @@ class ScheduledTasksEndpointTests {
|
||||
for (Class<?> bindingType : bindingTypes) {
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(bindingType)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,8 +39,7 @@ class DispatcherHandlersMappingDescriptionProviderTests {
|
||||
getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(DispatcherHandlerMappingDescription.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,8 +39,7 @@ class DispatcherServletsMappingDescriptionProviderTests {
|
||||
getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(DispatcherServletMappingDescription.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,8 +38,7 @@ class FiltersMappingDescriptionProviderTests {
|
||||
new FiltersMappingDescriptionProviderRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(FilterRegistrationMappingDescription.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,8 +38,7 @@ class ServletsMappingDescriptionProviderTests {
|
||||
new ServletsMappingDescriptionProviderRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(ServletRegistrationMappingDescription.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public class GraphQlAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.resources().registerPattern("graphql/*.graphqls").registerPattern("graphql/*.gqls");
|
||||
hints.resources().registerPattern("graphql/**/*.graphqls").registerPattern("graphql/**/*.gqls");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class LiquibaseAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.resources().registerPattern("db/changelog/*");
|
||||
hints.resources().registerPattern("db/changelog/**");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ class TemplateRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.resources().registerPatternIfPresent(classLoader, "templates", (hint) -> hint.includes("templates/*"));
|
||||
hints.resources().registerPatternIfPresent(classLoader, "templates", (hint) -> hint.includes("templates/**"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -335,11 +335,12 @@ class HttpMessageConvertersAutoConfigurationTests {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new HttpMessageConvertersAutoConfigurationRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(Encoding.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(Encoding.class, "getCharset").invoke()).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(Encoding.class, "setCharset").invoke()).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(Encoding.class, "isForce").invoke()).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(Encoding.class, "setForce").invoke()).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(Encoding.class, "shouldForce")).rejects(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(Encoding.class, "getCharset")).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(Encoding.class, "setCharset")).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(Encoding.class, "isForce")).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(Encoding.class, "setForce")).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(Encoding.class, "shouldForce"))
|
||||
.rejects(hints);
|
||||
}
|
||||
|
||||
private ApplicationContextRunner allOptionsRunner() {
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.time.Duration;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator.Mode;
|
||||
@@ -56,7 +55,6 @@ import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.predicate.ReflectionHintsPredicates;
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||
import org.springframework.beans.factory.BeanCurrentlyInCreationException;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
|
||||
@@ -501,17 +499,9 @@ class JacksonAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void shouldRegisterPropertyNamingStrategyHints() {
|
||||
shouldRegisterPropertyNamingStrategyHints(PropertyNamingStrategies.class, "LOWER_CAMEL_CASE",
|
||||
"UPPER_CAMEL_CASE", "SNAKE_CASE", "UPPER_SNAKE_CASE", "LOWER_CASE", "KEBAB_CASE", "LOWER_DOT_CASE");
|
||||
}
|
||||
|
||||
private void shouldRegisterPropertyNamingStrategyHints(Class<?> type, String... fieldNames) {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new JacksonAutoConfigurationRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
|
||||
Stream.of(fieldNames)
|
||||
.map((name) -> reflection.onField(type, name))
|
||||
.forEach((predicate) -> assertThat(predicate).accepts(hints));
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(PropertyNamingStrategies.class)).accepts(hints);
|
||||
}
|
||||
|
||||
private void assertParameterNamesModuleCreatorBinding(Mode expectedMode, Class<?>... configClasses) {
|
||||
|
||||
@@ -416,7 +416,7 @@ class JmsAutoConfigurationTests {
|
||||
context.register(TestConfiguration2.class, JmsAutoConfiguration.class);
|
||||
TestGenerationContext generationContext = new TestGenerationContext();
|
||||
new ApplicationContextAotGenerator().processAheadOfTime(context, generationContext);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(AcknowledgeMode.class, "of").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(AcknowledgeMode.class, "of"))
|
||||
.accepts(generationContext.getRuntimeHints());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +66,7 @@ class WebResourcesRuntimeHintsTests {
|
||||
}
|
||||
|
||||
private Consumer<ResourcePatternHints> include(String... patterns) {
|
||||
return (hint) -> {
|
||||
assertThat(hint.getIncludes()).map(ResourcePatternHint::getPattern).contains(patterns);
|
||||
assertThat(hint.getExcludes()).isEmpty();
|
||||
};
|
||||
return (hint) -> assertThat(hint.getIncludes()).map(ResourcePatternHint::getPattern).contains(patterns);
|
||||
}
|
||||
|
||||
private static class TestClassLoader extends ClassLoader {
|
||||
|
||||
@@ -268,7 +268,7 @@ class SpringBootContextLoaderTests {
|
||||
.buildMergedContextConfiguration();
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
contextLoader.loadContextForAotProcessing(contextConfiguration, runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(ConfigWithMain.class, "main").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(ConfigWithMain.class, "main"))
|
||||
.accepts(runtimeHints);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,9 +54,7 @@ class AotTests {
|
||||
Path targetClasses = project.toPath().resolve("target/classes");
|
||||
assertThat(collectRelativePaths(targetClasses)).contains(
|
||||
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-resource-generation",
|
||||
"reflect-config.json"),
|
||||
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-resource-generation",
|
||||
"resource-config.json"),
|
||||
"reachability-metadata.json"),
|
||||
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-resource-generation",
|
||||
"native-image.properties"),
|
||||
Path.of("generated-resource"), Path.of("nested/generated-resource"));
|
||||
@@ -69,11 +67,7 @@ class AotTests {
|
||||
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
|
||||
assertThat(collectRelativePaths(aotDirectory.resolve("resources"))).contains(
|
||||
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-jdk-proxy",
|
||||
"reflect-config.json"),
|
||||
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-jdk-proxy",
|
||||
"resource-config.json"),
|
||||
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-jdk-proxy",
|
||||
"proxy-config.json"),
|
||||
"reachability-metadata.json"),
|
||||
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-jdk-proxy",
|
||||
"native-image.properties"));
|
||||
});
|
||||
@@ -155,9 +149,7 @@ class AotTests {
|
||||
mavenBuild.project("aot-jdk-proxy").goals("package").execute((project) -> {
|
||||
Path classesDirectory = project.toPath().resolve("target/classes/META-INF/native-image");
|
||||
assertThat(collectRelativePaths(classesDirectory)).contains(
|
||||
Path.of("org.springframework.boot.maven.it", "aot-jdk-proxy", "reflect-config.json"),
|
||||
Path.of("org.springframework.boot.maven.it", "aot-jdk-proxy", "resource-config.json"),
|
||||
Path.of("org.springframework.boot.maven.it", "aot-jdk-proxy", "proxy-config.json"),
|
||||
Path.of("org.springframework.boot.maven.it", "aot-jdk-proxy", "reachability-metadata.json"),
|
||||
Path.of("org.springframework.boot.maven.it", "aot-jdk-proxy", "native-image.properties"));
|
||||
});
|
||||
}
|
||||
@@ -179,7 +171,7 @@ class AotTests {
|
||||
"SampleApplicationTests__TestContext001_ApplicationContextInitializer.java"));
|
||||
Path testClassesDirectory = project.toPath().resolve("target/test-classes");
|
||||
assertThat(collectRelativePaths(testClassesDirectory)).contains(Path.of("META-INF", "native-image",
|
||||
"org.springframework.boot.maven.it", "aot-test", "reflect-config.json"));
|
||||
"org.springframework.boot.maven.it", "aot-test", "reachability-metadata.json"));
|
||||
assertThat(collectRelativePaths(testClassesDirectory)).contains(Path.of("org", "test",
|
||||
"SampleApplicationTests__TestContext001_ApplicationContextInitializer.class"));
|
||||
});
|
||||
|
||||
@@ -192,7 +192,7 @@ public class JsonComponentModule extends SimpleModule implements BeanFactoryAwar
|
||||
BeanFactoryInitializationCode beanFactoryInitializationCode) {
|
||||
ReflectionHints reflection = generationContext.getRuntimeHints().reflection();
|
||||
this.innerComponents.forEach((outer, inners) -> {
|
||||
reflection.registerType(outer, MemberCategory.DECLARED_CLASSES);
|
||||
reflection.registerType(outer);
|
||||
inners.forEach((inner) -> reflection.registerType(inner, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -188,8 +188,8 @@ class SpringBootJoranConfigurator extends JoranConfigurator {
|
||||
serializationTypes(this.model).forEach(serializationHints::registerType);
|
||||
reflectionTypes(this.model).forEach((type) -> generationContext.getRuntimeHints()
|
||||
.reflection()
|
||||
.registerType(TypeReference.of(type), MemberCategory.INTROSPECT_PUBLIC_METHODS,
|
||||
MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
.registerType(TypeReference.of(type), MemberCategory.INVOKE_PUBLIC_METHODS,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
}
|
||||
|
||||
private byte[] serializeModel() {
|
||||
|
||||
@@ -52,13 +52,13 @@ class ApplicationPropertiesTests {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new ApplicationPropertiesRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(ApplicationProperties.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(ApplicationProperties.class, "setBannerMode").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(ApplicationProperties.class, "setBannerMode"))
|
||||
.accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(ApplicationProperties.class, "getSources").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(ApplicationProperties.class, "getSources"))
|
||||
.accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(ApplicationProperties.class, "setSources").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(ApplicationProperties.class, "setSources"))
|
||||
.accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(ApplicationProperties.class, "getBannerMode"))
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(ApplicationProperties.class, "getBannerMode"))
|
||||
.rejects(hints);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,10 +114,8 @@ class ConfigDataLocationRuntimeHintsTests {
|
||||
}
|
||||
|
||||
private Consumer<ResourcePatternHints> includes(String... patterns) {
|
||||
return (hint) -> {
|
||||
assertThat(hint.getIncludes().stream().map(ResourcePatternHint::getPattern)).contains(patterns);
|
||||
assertThat(hint.getExcludes()).isEmpty();
|
||||
};
|
||||
return (hint) -> assertThat(hint.getIncludes().stream().map(ResourcePatternHint::getPattern))
|
||||
.contains(patterns);
|
||||
}
|
||||
|
||||
static class TestConfigDataLocationRuntimeHints extends ConfigDataLocationRuntimeHints {
|
||||
|
||||
@@ -38,7 +38,7 @@ class ConfigDataPropertiesRuntimeHintsTests {
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(ConfigDataProperties.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(ConfigDataLocation.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(Activate.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(ConfigDataLocation.class, "of").invoke())
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(ConfigDataLocation.class, "of"))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,7 +49,7 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
Field requestFactoryField = ReflectionUtils.findField(AbstractClientHttpRequestFactoryWrapper.class,
|
||||
"requestFactory");
|
||||
assertThat(requestFactoryField).isNotNull();
|
||||
assertThat(reflection.onField(requestFactoryField)).accepts(hints);
|
||||
assertThat(reflection.onFieldAccess(requestFactoryField)).accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,7 +58,7 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
new ClientHttpRequestFactoryRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
|
||||
assertThat(reflection
|
||||
.onMethod(method(HttpComponentsClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.onMethodInvocation(method(HttpComponentsClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@@ -67,9 +67,11 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new ClientHttpRequestFactoryRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
|
||||
assertThat(reflection.onMethod(method(JettyClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection.onMethod(method(JettyClientHttpRequestFactory.class, "setReadTimeout", long.class)))
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setReadTimeout", long.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@@ -78,9 +80,11 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new ClientHttpRequestFactoryRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
|
||||
assertThat(reflection.onMethod(method(ReactorClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection.onMethod(method(ReactorClientHttpRequestFactory.class, "setReadTimeout", long.class)))
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setReadTimeout", long.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@@ -89,9 +93,11 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new ClientHttpRequestFactoryRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
|
||||
assertThat(reflection.onMethod(method(SimpleClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection.onMethod(method(SimpleClientHttpRequestFactory.class, "setReadTimeout", int.class)))
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setReadTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -134,9 +134,8 @@ class JsonComponentModuleTests {
|
||||
TestGenerationContext generationContext = new TestGenerationContext();
|
||||
contribution.applyTo(generationContext, null);
|
||||
RuntimeHints runtimeHints = generationContext.getRuntimeHints();
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(ComponentWithInnerAbstractClass.class)
|
||||
.withMemberCategory(MemberCategory.DECLARED_CLASSES)).accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(ComponentWithInnerAbstractClass.class))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(ConcreteSerializer.class)
|
||||
.withMemberCategory(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,10 +67,7 @@ class JsonMixinModuleEntriesBeanRegistrationAotProcessorTests {
|
||||
RuntimeHints runtimeHints = this.generationContext.getRuntimeHints();
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(RenameMixInClass.class)
|
||||
.withMemberCategories(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethod(RenameMixInClass.class, "getName").introspect())
|
||||
.accepts(runtimeHints);
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -267,8 +267,7 @@ class LogbackConfigurationAotContributionTests {
|
||||
private Predicate<RuntimeHints> invokePublicConstructorsAndInspectAndInvokePublicMethodsOf(Class<?> type) {
|
||||
return RuntimeHintsPredicates.reflection()
|
||||
.onType(TypeReference.of(type))
|
||||
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INTROSPECT_PUBLIC_METHODS,
|
||||
MemberCategory.INVOKE_PUBLIC_METHODS);
|
||||
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS);
|
||||
}
|
||||
|
||||
private Consumer<RuntimeHints> hasValidTypeName(Class<?> type) {
|
||||
|
||||
@@ -96,12 +96,12 @@ class ElasticCommonSchemaPropertiesTests {
|
||||
new ElasticCommonSchemaPropertiesRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(ElasticCommonSchemaProperties.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onConstructor(ElasticCommonSchemaProperties.class.getConstructor(Service.class))
|
||||
.invoke()).accepts(hints);
|
||||
.onConstructorInvocation(ElasticCommonSchemaProperties.class.getConstructor(Service.class))).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(Service.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onConstructor(Service.class.getConstructor(String.class, String.class, String.class, String.class))
|
||||
.invoke()).accepts(hints);
|
||||
.onConstructorInvocation(
|
||||
Service.class.getConstructor(String.class, String.class, String.class, String.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -109,12 +109,13 @@ class GraylogExtendedLogFormatPropertiesTests {
|
||||
new GraylogExtendedLogFormatPropertiesRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(GraylogExtendedLogFormatProperties.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onConstructor(GraylogExtendedLogFormatProperties.class.getConstructor(String.class, Service.class))
|
||||
.invoke()).accepts(hints);
|
||||
.onConstructorInvocation(
|
||||
GraylogExtendedLogFormatProperties.class.getConstructor(String.class, Service.class)))
|
||||
.accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(Service.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onConstructor(GraylogExtendedLogFormatProperties.Service.class.getConstructor(String.class))
|
||||
.invoke()).accepts(hints);
|
||||
.onConstructorInvocation(GraylogExtendedLogFormatProperties.Service.class.getConstructor(String.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -90,17 +90,17 @@ class StructuredLoggingJsonPropertiesTests {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new StructuredLoggingJsonPropertiesRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(StructuredLoggingJsonProperties.class)).accepts(hints);
|
||||
assertThat(
|
||||
RuntimeHintsPredicates.reflection()
|
||||
.onConstructorInvocation(StructuredLoggingJsonProperties.class.getDeclaredConstructor(Set.class,
|
||||
Set.class, Map.class, Map.class, StackTrace.class, Context.class, Set.class)))
|
||||
.accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onConstructor(StructuredLoggingJsonProperties.class.getDeclaredConstructor(Set.class, Set.class, Map.class,
|
||||
Map.class, StackTrace.class, Context.class, Set.class))
|
||||
.invoke()).accepts(hints);
|
||||
.onConstructorInvocation(StackTrace.class.getDeclaredConstructor(String.class, Root.class, Integer.class,
|
||||
Integer.class, Boolean.class, Boolean.class)))
|
||||
.accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onConstructor(StackTrace.class.getDeclaredConstructor(String.class, Root.class, Integer.class,
|
||||
Integer.class, Boolean.class, Boolean.class))
|
||||
.invoke()).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onConstructor(Context.class.getDeclaredConstructor(boolean.class, String.class))
|
||||
.invoke()).accepts(hints);
|
||||
.onConstructorInvocation(Context.class.getDeclaredConstructor(boolean.class, String.class))).accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
package org.springframework.boot.web.embedded.undertow;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import io.undertow.Undertow;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.predicate.ReflectionHintsPredicates.FieldHintPredicate;
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||
import org.springframework.boot.web.embedded.undertow.UndertowWebServer.UndertowWebServerRuntimeHints;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -38,17 +39,19 @@ class UndertowWebServerRuntimeHintsTests {
|
||||
void registersHints() throws ClassNotFoundException {
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
new UndertowWebServerRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onField(Undertow.class, "listeners")).accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onField(Undertow.class, "channels")).accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onFieldAccess(Undertow.class, "listeners"))
|
||||
.accepts(runtimeHints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onFieldAccess(Undertow.class, "channels")).accepts(runtimeHints);
|
||||
assertThat(reflectionOnField("io.undertow.Undertow$ListenerConfig", "type")).accepts(runtimeHints);
|
||||
assertThat(reflectionOnField("io.undertow.Undertow$ListenerConfig", "port")).accepts(runtimeHints);
|
||||
assertThat(reflectionOnField("io.undertow.protocols.ssl.UndertowAcceptingSslChannel", "ssl"))
|
||||
.accepts(runtimeHints);
|
||||
}
|
||||
|
||||
private FieldHintPredicate reflectionOnField(String className, String fieldName) throws ClassNotFoundException {
|
||||
private Predicate<RuntimeHints> reflectionOnField(String className, String fieldName)
|
||||
throws ClassNotFoundException {
|
||||
return RuntimeHintsPredicates.reflection()
|
||||
.onField(ReflectionUtils.findField(Class.forName(className), fieldName));
|
||||
.onFieldAccess(ReflectionUtils.findField(Class.forName(className), fieldName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user