Skip to content

Commit e35140d

Browse files
committed
Add tests for SpringApplicationRuntimeHints
1 parent 5c057a2 commit e35140d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
import org.mockito.Mockito;
4242
import reactor.core.publisher.Mono;
4343

44+
import org.springframework.aot.hint.MemberCategory;
45+
import org.springframework.aot.hint.RuntimeHints;
46+
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
4447
import org.springframework.beans.CachedIntrospectionResults;
4548
import org.springframework.beans.factory.BeanCreationException;
4649
import org.springframework.beans.factory.BeanCurrentlyInCreationException;
@@ -53,6 +56,7 @@
5356
import org.springframework.beans.factory.support.BeanNameGenerator;
5457
import org.springframework.beans.factory.support.DefaultBeanNameGenerator;
5558
import org.springframework.boot.BootstrapRegistry.InstanceSupplier;
59+
import org.springframework.boot.SpringApplication.SpringApplicationRuntimeHints;
5660
import org.springframework.boot.SpringApplicationHooks.Hook;
5761
import org.springframework.boot.availability.AvailabilityChangeEvent;
5862
import org.springframework.boot.availability.AvailabilityState;
@@ -1301,6 +1305,15 @@ void hookIsCalledAndCanPreventRefreshWhenApplicationIsRun() throws Exception {
13011305
assertThat(this.context.isRunning()).isFalse();
13021306
}
13031307

1308+
@Test
1309+
void shouldRegisterHints() {
1310+
RuntimeHints hints = new RuntimeHints();
1311+
new SpringApplicationRuntimeHints().registerHints(hints, getClass().getClassLoader());
1312+
assertThat(RuntimeHintsPredicates.reflection().onType(SpringApplication.class)
1313+
.withMemberCategories(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_PUBLIC_METHODS))
1314+
.accepts(hints);
1315+
}
1316+
13041317
private <S extends AvailabilityState> ArgumentMatcher<ApplicationEvent> isAvailabilityChangeEventWithState(
13051318
S state) {
13061319
return (argument) -> (argument instanceof AvailabilityChangeEvent<?>)

0 commit comments

Comments
 (0)