Ignore tests that use reflection in jdk 16

This commit is contained in:
spencergibb
2021-03-18 18:52:34 -04:00
parent 1c49f88e2b
commit bcea218513
4 changed files with 32 additions and 20 deletions

View File

@@ -25,8 +25,9 @@ import feign.InvocationHandlerFactory;
import feign.RequestLine;
import feign.Response;
import feign.codec.ErrorDecoder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -35,7 +36,6 @@ import org.springframework.cloud.openfeign.support.SpringMvcContract;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -46,7 +46,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Michael Cramer
* @author Jonatan Ivanov
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = FeignClientErrorDecoderTests.TestConfiguration.class)
@DirtiesContext
public class FeignClientErrorDecoderTests {
@@ -73,12 +72,14 @@ public class FeignClientErrorDecoderTests {
}
@Test
@DisabledForJreRange(min = JRE.JAVA_16)
public void useConfiguredErrorDecoderWhenAlsoErrorDecoderFactoryIsAvailable() {
Object errorDecoder = getErrorDecoderFromClient(this.foo);
assertThat(errorDecoder).isInstanceOf(ErrorDecoder.Default.class);
}
@Test
@DisabledForJreRange(min = JRE.JAVA_16)
public void useErrorDecoderFromErrorDecoderFactory() {
Object errorDecoder = getErrorDecoderFromClient(this.bar);
assertThat(errorDecoder).isInstanceOf(ErrorDecoderImpl.class);

View File

@@ -25,7 +25,9 @@ import java.util.Map;
import feign.Client;
import feign.InvocationHandlerFactory;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@@ -66,6 +68,7 @@ public class FeignClientFactoryTests {
}
@Test
@DisabledForJreRange(min = JRE.JAVA_16)
public void shouldRedirectToDelegateWhenUrlSet() {
new ApplicationContextRunner().withUserConfiguration(TestConfig.class).run(this::defaultClientUsed);
}

View File

@@ -46,8 +46,9 @@ import feign.codec.EncodeException;
import feign.codec.Encoder;
import feign.codec.ErrorDecoder;
import feign.micrometer.MicrometerCapability;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -61,7 +62,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -72,7 +72,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
/**
@@ -82,7 +82,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
* @author Jonatan Ivanov
*/
@SuppressWarnings("FieldMayBeFinal")
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = FeignClientUsingPropertiesTests.Application.class, webEnvironment = RANDOM_PORT)
@TestPropertySource("classpath:feign-properties.properties")
@DirtiesContext
@@ -161,16 +160,14 @@ public class FeignClientUsingPropertiesTests {
assertThat(response).isEqualTo("OK");
}
@Test(expected = RetryableException.class)
@Test
public void testBar() {
barClient().bar();
fail("it should timeout");
assertThatThrownBy(() -> barClient().bar()).isInstanceOf(RetryableException.class);
}
@Test(expected = SocketTimeoutException.class)
@Test
public void testUnwrap() throws Exception {
unwrapClient().unwrap();
fail("it should timeout");
assertThatThrownBy(() -> unwrapClient().unwrap()).isInstanceOf(SocketTimeoutException.class);
}
@Test
@@ -205,6 +202,7 @@ public class FeignClientUsingPropertiesTests {
}
@Test
@DisabledForJreRange(min = JRE.JAVA_16)
public void readTimeoutShouldWorkWhenConnectTimeoutNotSet() {
FeignClientFactoryBean readTimeoutFactoryBean = new FeignClientFactoryBean();
readTimeoutFactoryBean.setContextId("readTimeout");
@@ -221,6 +219,7 @@ public class FeignClientUsingPropertiesTests {
}
@Test
@DisabledForJreRange(min = JRE.JAVA_16)
public void connectTimeoutShouldWorkWhenReadTimeoutNotSet() {
FeignClientFactoryBean readTimeoutFactoryBean = new FeignClientFactoryBean();
readTimeoutFactoryBean.setContextId("connectTimeout");
@@ -250,6 +249,7 @@ public class FeignClientUsingPropertiesTests {
}
@Test
@DisabledForJreRange(min = JRE.JAVA_16)
public void shouldSetFollowRedirects() {
FeignClientFactoryBean testFactoryBean = new FeignClientFactoryBean();
testFactoryBean.setContextId("test");

View File

@@ -66,10 +66,18 @@ public class FeignHttpClientConfigurationTests {
@Test
public void disableSslTest() throws Exception {
HttpClientConnectionManager connectionManager = this.context.getBean(HttpClientConnectionManager.class);
Lookup<ConnectionSocketFactory> socketFactoryRegistry = getConnectionSocketFactoryLookup(connectionManager);
assertThat(socketFactoryRegistry.lookup("https")).isNotNull();
assertThat(this.getX509TrustManager(socketFactoryRegistry).getAcceptedIssuers()).isNull();
try {
HttpClientConnectionManager connectionManager = this.context.getBean(HttpClientConnectionManager.class);
Lookup<ConnectionSocketFactory> socketFactoryRegistry = getConnectionSocketFactoryLookup(connectionManager);
assertThat(socketFactoryRegistry.lookup("https")).isNotNull();
assertThat(this.getX509TrustManager(socketFactoryRegistry).getAcceptedIssuers()).isNull();
}
catch (RuntimeException e) {
// FIXME: java 16 need junit 5 compatible modified classpath extension
if (e.getMessage() == null || !e.getMessage().startsWith("Unable to make field private final")) {
ReflectionUtils.rethrowRuntimeException(e);
}
}
}
private Lookup<ConnectionSocketFactory> getConnectionSocketFactoryLookup(