|
| 1 | +package org.springframework.ldap.aot.hint; |
| 2 | + |
| 3 | +import org.junit.Before; |
| 4 | +import org.junit.Test; |
| 5 | + |
| 6 | +import org.springframework.aot.hint.MemberCategory; |
| 7 | +import org.springframework.aot.hint.RuntimeHints; |
| 8 | +import org.springframework.aot.hint.RuntimeHintsRegistrar; |
| 9 | +import org.springframework.aot.hint.TypeReference; |
| 10 | +import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; |
| 11 | +import org.springframework.core.io.support.SpringFactoriesLoader; |
| 12 | +import org.springframework.ldap.core.support.AbstractContextSource; |
| 13 | +import org.springframework.ldap.core.support.DefaultDirObjectFactory; |
| 14 | +import org.springframework.util.ClassUtils; |
| 15 | + |
| 16 | +import static org.assertj.core.api.Assertions.assertThat; |
| 17 | + |
| 18 | +/** |
| 19 | + * Tests for {@link LdapCoreRuntimeHints} |
| 20 | + */ |
| 21 | +public class LdapCoreRuntimeHintsTests { |
| 22 | + |
| 23 | + private final RuntimeHints hints = new RuntimeHints(); |
| 24 | + |
| 25 | + @Before |
| 26 | + public void setup() { |
| 27 | + SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories").load(RuntimeHintsRegistrar.class) |
| 28 | + .forEach((registrar) -> registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader())); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void ldapCtxFactoryHasHints() { |
| 33 | + assertThat(RuntimeHintsPredicates.reflection().onType(TypeReference.of("com.sun.jndi.ldap.LdapCtxFactory")).withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)) |
| 34 | + .accepts(this.hints); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + public void abstractContextSourceHasHints() { |
| 39 | + assertThat(RuntimeHintsPredicates.reflection().onType(AbstractContextSource.class).withMemberCategories(MemberCategory.INTROSPECT_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS)) |
| 40 | + .accepts(this.hints); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void defaultDirObjectFactoryHasHints() { |
| 45 | + assertThat(RuntimeHintsPredicates.reflection().onType(DefaultDirObjectFactory.class).withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)) |
| 46 | + .accepts(this.hints); |
| 47 | + } |
| 48 | + |
| 49 | +} |
0 commit comments