|
|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.http.client;
@@ -18,6 +18,7 @@ package org.springframework.boot.http.client;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
|
import java.lang.reflect.Method; |
|
|
|
|
import java.time.Duration; |
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
@ -26,6 +27,7 @@ import org.springframework.aot.hint.predicate.ReflectionHintsPredicates;
@@ -26,6 +27,7 @@ import org.springframework.aot.hint.predicate.ReflectionHintsPredicates;
|
|
|
|
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; |
|
|
|
|
import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper; |
|
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; |
|
|
|
|
import org.springframework.http.client.JdkClientHttpRequestFactory; |
|
|
|
|
import org.springframework.http.client.JettyClientHttpRequestFactory; |
|
|
|
|
import org.springframework.http.client.ReactorClientHttpRequestFactory; |
|
|
|
|
import org.springframework.http.client.SimpleClientHttpRequestFactory; |
|
|
|
|
@ -60,6 +62,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
@@ -60,6 +62,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(HttpComponentsClientHttpRequestFactory.class, "setConnectTimeout", int.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection.onMethodInvocation( |
|
|
|
|
method(HttpComponentsClientHttpRequestFactory.class, "setConnectTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(HttpComponentsClientHttpRequestFactory.class, "setReadTimeout", int.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(HttpComponentsClientHttpRequestFactory.class, "setReadTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@ -70,9 +81,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
@@ -70,9 +81,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setConnectTimeout", int.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setConnectTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setReadTimeout", long.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setReadTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@ -83,9 +100,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
@@ -83,9 +100,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setConnectTimeout", int.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setConnectTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setReadTimeout", long.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setReadTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@ -96,9 +119,28 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
@@ -96,9 +119,28 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setConnectTimeout", int.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setConnectTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setReadTimeout", int.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setReadTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void shouldRegisterJdkHttpHints() { |
|
|
|
|
RuntimeHints hints = new RuntimeHints(); |
|
|
|
|
new ClientHttpRequestFactoryRuntimeHints().registerHints(hints, getClass().getClassLoader()); |
|
|
|
|
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection(); |
|
|
|
|
assertThat( |
|
|
|
|
reflection.onMethodInvocation(method(JdkClientHttpRequestFactory.class, "setReadTimeout", int.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
assertThat(reflection |
|
|
|
|
.onMethodInvocation(method(JdkClientHttpRequestFactory.class, "setReadTimeout", Duration.class))) |
|
|
|
|
.accepts(hints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static Method method(Class<?> target, String name, Class<?>... parameterTypes) { |
|
|
|
|
|