diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java index 921de6b724..37963967b3 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java @@ -30,7 +30,6 @@ import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker; import org.springframework.boot.actuate.endpoint.invoke.OperationParameters; import org.springframework.boot.actuate.endpoint.invoke.reflect.OperationMethod; import org.springframework.lang.Nullable; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -124,9 +123,8 @@ public class CachingOperationInvokerAdvisorTests { OperationInvoker advised = this.advisor.apply("foo", OperationType.READ, parameters, this.invoker); assertThat(advised).isInstanceOf(CachingOperationInvoker.class); - assertThat(ReflectionTestUtils.getField(advised, "invoker")) - .isEqualTo(this.invoker); - assertThat(ReflectionTestUtils.getField(advised, "timeToLive")).isEqualTo(100L); + assertThat(advised).hasFieldOrPropertyWithValue("invoker", this.invoker); + assertThat(advised).hasFieldOrPropertyWithValue("timeToLive", 100L); } private OperationParameters getParameters(String methodName, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java index 3c4a2803fc..6ae72f6482 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java @@ -59,7 +59,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -478,8 +477,8 @@ public class JacksonAutoConfigurationTests { .getBean(ObjectMapper.class).getDeserializationConfig(); AnnotationIntrospector annotationIntrospector = deserializationConfig .getAnnotationIntrospector().allIntrospectors().iterator().next(); - assertThat(ReflectionTestUtils.getField(annotationIntrospector, - "creatorBinding")).isEqualTo(expectedMode); + assertThat(annotationIntrospector) + .hasFieldOrPropertyWithValue("creatorBinding", expectedMode); }); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java index 49fddc7e34..25f32e245f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java @@ -31,7 +31,6 @@ import org.springframework.boot.testsupport.rule.OutputCapture; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; -import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -105,8 +104,7 @@ public class BannerTests { application.setBanner(banner); this.context = application.run(); Banner printedBanner = (Banner) this.context.getBean("springBootBanner"); - assertThat(ReflectionTestUtils.getField(printedBanner, "banner")) - .isEqualTo(banner); + assertThat(printedBanner).hasFieldOrPropertyWithValue("banner", banner); verify(banner).printBanner(any(Environment.class), this.sourceClassCaptor.capture(), any(PrintStream.class)); reset(banner); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java index 47cfd04d6b..cff2df1f17 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java @@ -414,8 +414,8 @@ public class RestTemplateBuilderTests { .getRequestFactory(); assertThat(actualRequestFactory) .isInstanceOf(InterceptingClientHttpRequestFactory.class); - assertThat(ReflectionTestUtils.getField(actualRequestFactory, - "requestFactory")).isSameAs(requestFactory); + assertThat(actualRequestFactory).hasFieldOrPropertyWithValue( + "requestFactory", requestFactory); }).build(); } @@ -444,8 +444,7 @@ public class RestTemplateBuilderTests { ClientHttpRequestFactory requestFactory = this.builder .requestFactory(SimpleClientHttpRequestFactory.class) .setConnectTimeout(null).build().getRequestFactory(); - assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout")) - .isEqualTo(-1); + assertThat(requestFactory).hasFieldOrPropertyWithValue("connectTimeout", -1); } @Test @@ -453,8 +452,7 @@ public class RestTemplateBuilderTests { ClientHttpRequestFactory requestFactory = this.builder .requestFactory(SimpleClientHttpRequestFactory.class).setReadTimeout(null) .build().getRequestFactory(); - assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout")) - .isEqualTo(-1); + assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", -1); } @Test @@ -480,8 +478,7 @@ public class RestTemplateBuilderTests { ClientHttpRequestFactory requestFactory = this.builder .requestFactory(SimpleClientHttpRequestFactory.class) .setConnectTimeout(Duration.ofMillis(1234)).build().getRequestFactory(); - assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout")) - .isEqualTo(1234); + assertThat(requestFactory).hasFieldOrPropertyWithValue("connectTimeout", 1234); } @Test @@ -489,8 +486,7 @@ public class RestTemplateBuilderTests { ClientHttpRequestFactory requestFactory = this.builder .requestFactory(SimpleClientHttpRequestFactory.class) .setReadTimeout(Duration.ofMillis(1234)).build().getRequestFactory(); - assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout")) - .isEqualTo(1234); + assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", 1234); } @Test @@ -520,8 +516,7 @@ public class RestTemplateBuilderTests { .requestFactory( () -> new BufferingClientHttpRequestFactory(requestFactory)) .setConnectTimeout(Duration.ofMillis(1234)).build(); - assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout")) - .isEqualTo(1234); + assertThat(requestFactory).hasFieldOrPropertyWithValue("connectTimeout", 1234); } @Test @@ -531,8 +526,7 @@ public class RestTemplateBuilderTests { .requestFactory( () -> new BufferingClientHttpRequestFactory(requestFactory)) .setReadTimeout(Duration.ofMillis(1234)).build(); - assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout")) - .isEqualTo(1234); + assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", 1234); } @Test @@ -552,8 +546,7 @@ public class RestTemplateBuilderTests { ClientHttpRequestFactory requestFactory = this.builder .requestFactory(SimpleClientHttpRequestFactory.class) .setConnectTimeout(1234).build().getRequestFactory(); - assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout")) - .isEqualTo(1234); + assertThat(requestFactory).hasFieldOrPropertyWithValue("connectTimeout", 1234); } @Test @@ -562,8 +555,7 @@ public class RestTemplateBuilderTests { ClientHttpRequestFactory requestFactory = this.builder .requestFactory(SimpleClientHttpRequestFactory.class).setReadTimeout(1234) .build().getRequestFactory(); - assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout")) - .isEqualTo(1234); + assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", 1234); } public static class RestTemplateSubclass extends RestTemplate {