mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 14:09:25 +00:00
Polish "Add hints to instantiate HttpService group adapters"
See gh-35038
This commit is contained in:
+10
-21
@@ -16,43 +16,32 @@
|
||||
|
||||
package org.springframework.web.client.support;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import org.springframework.beans.factory.aot.AotServices;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link RestClientHttpServiceGroupAdapterRuntimeHints}.
|
||||
* Tests for {@link RestClientHttpServiceGroupAdapter}.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class RestClientHttpServiceGroupAdapterRuntimeHintsRegistrarTests {
|
||||
|
||||
private RuntimeHints hints;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.hints = new RuntimeHints();
|
||||
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
|
||||
.load(RuntimeHintsRegistrar.class)
|
||||
.forEach(registrar ->
|
||||
registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
|
||||
}
|
||||
class RestClientHttpServiceGroupAdapterTests {
|
||||
|
||||
@Test
|
||||
void shouldRegisterHintsForAdapter() {
|
||||
void registerInstantiationHints() throws Exception {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
AotServices.factories().load(RuntimeHintsRegistrar.class)
|
||||
.forEach(registrar -> registrar.registerHints(hints,
|
||||
ClassUtils.getDefaultClassLoader()));
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(RestClientHttpServiceGroupAdapter.class)
|
||||
.withMemberCategory(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.accepts(this.hints);
|
||||
|
||||
.onConstructorInvocation(RestClientHttpServiceGroupAdapter.class.getConstructor())).accepts(hints);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user