diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidatorTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidatorTests.java index 797a1eaed8..82f2a945f9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidatorTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidatorTests.java @@ -111,9 +111,8 @@ public class ReactiveTokenValidatorTests { assertThat(((CloudFoundryAuthorizationException) ex).getReason()) .isEqualTo(Reason.INVALID_KEY_ID); }).verify(); - Object cachedTokenKeys = ReflectionTestUtils.getField(this.tokenValidator, - "cachedTokenKeys"); - assertThat(cachedTokenKeys).isEqualTo(VALID_KEYS); + assertThat(this.tokenValidator).hasFieldOrPropertyWithValue("cachedTokenKeys", + VALID_KEYS); fetchTokenKeys.assertWasSubscribed(); } @@ -133,9 +132,8 @@ public class ReactiveTokenValidatorTests { .create(this.tokenValidator.validate( new Token(getSignedToken(header.getBytes(), claims.getBytes())))) .verifyComplete(); - Object cachedTokenKeys = ReflectionTestUtils.getField(this.tokenValidator, - "cachedTokenKeys"); - assertThat(cachedTokenKeys).isEqualTo(VALID_KEYS); + assertThat(this.tokenValidator).hasFieldOrPropertyWithValue("cachedTokenKeys", + VALID_KEYS); fetchTokenKeys.assertWasSubscribed(); } @@ -152,9 +150,8 @@ public class ReactiveTokenValidatorTests { .create(this.tokenValidator.validate( new Token(getSignedToken(header.getBytes(), claims.getBytes())))) .verifyComplete(); - Object cachedTokenKeys = ReflectionTestUtils.getField(this.tokenValidator, - "cachedTokenKeys"); - assertThat(cachedTokenKeys).isEqualTo(VALID_KEYS); + assertThat(this.tokenValidator).hasFieldOrPropertyWithValue("cachedTokenKeys", + VALID_KEYS); fetchTokenKeys.assertWasSubscribed(); } @@ -177,9 +174,8 @@ public class ReactiveTokenValidatorTests { assertThat(((CloudFoundryAuthorizationException) ex).getReason()) .isEqualTo(Reason.INVALID_KEY_ID); }).verify(); - Object cachedTokenKeys = ReflectionTestUtils.getField(this.tokenValidator, - "cachedTokenKeys"); - assertThat(cachedTokenKeys).isEqualTo(VALID_KEYS); + assertThat(this.tokenValidator).hasFieldOrPropertyWithValue("cachedTokenKeys", + VALID_KEYS); fetchTokenKeys.assertWasSubscribed(); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfigurationTests.java index 51c76f18ad..5f48fdd380 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfigurationTests.java @@ -31,7 +31,6 @@ import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.servlet.DispatcherServlet; import static org.assertj.core.api.Assertions.assertThat; @@ -54,8 +53,7 @@ public class ServletEndpointManagementContextConfigurationTests { assertThat(context).hasSingleBean(ServletEndpointRegistrar.class); ServletEndpointRegistrar bean = context .getBean(ServletEndpointRegistrar.class); - String basePath = (String) ReflectionTestUtils.getField(bean, "basePath"); - assertThat(basePath).isEqualTo("/test/actuator"); + assertThat(bean).hasFieldOrPropertyWithValue("basePath", "/test/actuator"); }); } @@ -67,8 +65,7 @@ public class ServletEndpointManagementContextConfigurationTests { assertThat(context).hasSingleBean(ServletEndpointRegistrar.class); ServletEndpointRegistrar bean = context .getBean(ServletEndpointRegistrar.class); - String basePath = (String) ReflectionTestUtils.getField(bean, "basePath"); - assertThat(basePath).isEqualTo("/actuator"); + assertThat(bean).hasFieldOrPropertyWithValue("basePath", "/actuator"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index d791d98022..5b7ea0287b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -326,8 +326,8 @@ public class RabbitAutoConfigurationTests { .withPropertyValues("spring.rabbitmq.template.queue:default-queue") .run((context) -> { RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class); - assertThat(ReflectionTestUtils.getField(rabbitTemplate, "queue")) - .isEqualTo("default-queue"); + assertThat(rabbitTemplate).hasFieldOrPropertyWithValue("queue", + "default-queue"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java index f6dad0c0d2..5866a59b94 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java @@ -32,7 +32,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletContext; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.servlet.View; import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter; @@ -131,8 +130,8 @@ public class FreeMarkerAutoConfigurationServletIntegrationTests { registerAndRefreshContext("spring.freemarker.allow-session-override:true"); AbstractTemplateViewResolver viewResolver = this.context .getBean(FreeMarkerViewResolver.class); - assertThat(ReflectionTestUtils.getField(viewResolver, "allowSessionOverride")) - .isEqualTo(true); + assertThat(viewResolver).hasFieldOrPropertyWithValue("allowSessionOverride", + true); } @SuppressWarnings("deprecation") diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfigurationTests.java index 4194f84cdd..c081d2bc62 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfigurationTests.java @@ -28,7 +28,6 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jms.connection.CachingConnectionFactory; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -82,10 +81,10 @@ public class ActiveMQAutoConfigurationTests { .getBean(CachingConnectionFactory.class); assertThat(connectionFactory.getTargetConnectionFactory()) .isInstanceOf(ActiveMQConnectionFactory.class); - assertThat(ReflectionTestUtils.getField(connectionFactory, - "cacheConsumers")).isEqualTo(false); - assertThat(ReflectionTestUtils.getField(connectionFactory, - "cacheProducers")).isEqualTo(true); + assertThat(connectionFactory) + .hasFieldOrPropertyWithValue("cacheConsumers", false); + assertThat(connectionFactory) + .hasFieldOrPropertyWithValue("cacheProducers", true); assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1); }); } @@ -101,10 +100,10 @@ public class ActiveMQAutoConfigurationTests { assertThat(context).hasSingleBean(CachingConnectionFactory.class); CachingConnectionFactory connectionFactory = context .getBean(CachingConnectionFactory.class); - assertThat(ReflectionTestUtils.getField(connectionFactory, - "cacheConsumers")).isEqualTo(true); - assertThat(ReflectionTestUtils.getField(connectionFactory, - "cacheProducers")).isEqualTo(false); + assertThat(connectionFactory) + .hasFieldOrPropertyWithValue("cacheConsumers", true); + assertThat(connectionFactory) + .hasFieldOrPropertyWithValue("cacheProducers", false); assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(10); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java index 8985127847..359a1231e9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java @@ -53,7 +53,6 @@ import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.SessionCallback; import org.springframework.jms.support.destination.DestinationResolver; import org.springframework.jms.support.destination.DynamicDestinationResolver; -import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -82,10 +81,10 @@ public class ArtemisAutoConfigurationTests { .getBean(CachingConnectionFactory.class); assertThat(connectionFactory.getTargetConnectionFactory()) .isInstanceOf(ActiveMQConnectionFactory.class); - assertThat(ReflectionTestUtils.getField(connectionFactory, - "cacheConsumers")).isEqualTo(false); - assertThat(ReflectionTestUtils.getField(connectionFactory, - "cacheProducers")).isEqualTo(true); + assertThat(connectionFactory) + .hasFieldOrPropertyWithValue("cacheConsumers", false); + assertThat(connectionFactory) + .hasFieldOrPropertyWithValue("cacheProducers", true); assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1); }); } @@ -101,10 +100,10 @@ public class ArtemisAutoConfigurationTests { assertThat(context).hasSingleBean(CachingConnectionFactory.class); CachingConnectionFactory connectionFactory = context .getBean(CachingConnectionFactory.class); - assertThat(ReflectionTestUtils.getField(connectionFactory, - "cacheConsumers")).isEqualTo(true); - assertThat(ReflectionTestUtils.getField(connectionFactory, - "cacheProducers")).isEqualTo(false); + assertThat(connectionFactory) + .hasFieldOrPropertyWithValue("cacheConsumers", true); + assertThat(connectionFactory) + .hasFieldOrPropertyWithValue("cacheProducers", false); assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(10); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java index ff689da62c..9046573753 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java @@ -102,10 +102,9 @@ public class JmxAutoConfigurationTests { assertThat(mBeanExporter).isNotNull(); MetadataNamingStrategy naming = (MetadataNamingStrategy) ReflectionTestUtils .getField(mBeanExporter, "namingStrategy"); - assertThat(ReflectionTestUtils.getField(naming, "defaultDomain")) - .isEqualTo("my-test-domain"); - assertThat(ReflectionTestUtils.getField(naming, "ensureUniqueRuntimeObjectNames")) - .isEqualTo(true); + assertThat(naming).hasFieldOrPropertyWithValue("defaultDomain", "my-test-domain"); + assertThat(naming).hasFieldOrPropertyWithValue("ensureUniqueRuntimeObjectNames", + true); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java index 160d43b06d..a0f4afaa42 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java @@ -48,8 +48,7 @@ public class LdapAutoConfigurationTests { public void contextSourceWithDefaultUrl() { this.contextRunner.run((context) -> { LdapContextSource contextSource = context.getBean(LdapContextSource.class); - String[] urls = (String[]) ReflectionTestUtils.getField(contextSource, - "urls"); + String[] urls = getUrls(contextSource); assertThat(urls).containsExactly("ldap://localhost:389"); assertThat(contextSource.isAnonymousReadOnly()).isFalse(); }); @@ -61,8 +60,7 @@ public class LdapAutoConfigurationTests { .run((context) -> { ContextSource contextSource = context .getBean(LdapContextSource.class); - String[] urls = (String[]) ReflectionTestUtils.getField(contextSource, - "urls"); + String[] urls = getUrls(contextSource); assertThat(urls).containsExactly("ldap://localhost:123"); }); } @@ -76,8 +74,7 @@ public class LdapAutoConfigurationTests { ContextSource contextSource = context .getBean(LdapContextSource.class); LdapProperties ldapProperties = context.getBean(LdapProperties.class); - String[] urls = (String[]) ReflectionTestUtils.getField(contextSource, - "urls"); + String[] urls = getUrls(contextSource); assertThat(urls).containsExactly("ldap://localhost:123", "ldap://mycompany:123"); assertThat(ldapProperties.getUrls()).hasSize(2); @@ -117,13 +114,16 @@ public class LdapAutoConfigurationTests { .run((context) -> { LdapContextSource contextSource = context .getBean(LdapContextSource.class); - String[] urls = (String[]) ReflectionTestUtils.getField(contextSource, - "urls"); + String[] urls = getUrls(contextSource); assertThat(urls).containsExactly("ldap://localhost:389"); assertThat(contextSource.isAnonymousReadOnly()).isFalse(); }); } + private String[] getUrls(ContextSource contextSource) { + return (String[]) ReflectionTestUtils.getField(contextSource, "urls"); + } + @Configuration static class PooledContextSourceConfig { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java index ebef2df606..590dd98c93 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java @@ -180,9 +180,8 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat .getField(filter, "httpSessionIdResolver"); DefaultCookieSerializer cookieSerializer = (DefaultCookieSerializer) ReflectionTestUtils .getField(sessionIdResolver, "cookieSerializer"); - String cookieName = (String) ReflectionTestUtils.getField(cookieSerializer, - "cookieName"); - assertThat(cookieName).isEqualTo("testname"); + assertThat(cookieSerializer).hasFieldOrPropertyWithValue("cookieName", + "testname"); }); } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java index 7c36406b9c..6b89913dec 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,8 +63,7 @@ public class RestartApplicationListenerTests { @Test public void initializeWithReady() { testInitialize(false); - assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "args")) - .isEqualTo(ARGS); + assertThat(Restarter.getInstance()).hasFieldOrPropertyWithValue("args", ARGS); assertThat(Restarter.getInstance().isFinished()).isTrue(); assertThat((List) ReflectionTestUtils.getField(Restarter.getInstance(), "rootContexts")).isNotEmpty(); @@ -73,8 +72,7 @@ public class RestartApplicationListenerTests { @Test public void initializeWithFail() { testInitialize(true); - assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "args")) - .isEqualTo(ARGS); + assertThat(Restarter.getInstance()).hasFieldOrPropertyWithValue("args", ARGS); assertThat(Restarter.getInstance().isFinished()).isTrue(); assertThat((List) ReflectionTestUtils.getField(Restarter.getInstance(), "rootContexts")).isEmpty(); @@ -84,8 +82,7 @@ public class RestartApplicationListenerTests { public void disableWithSystemProperty() { System.setProperty(ENABLED_PROPERTY, "false"); testInitialize(false); - assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "enabled")) - .isEqualTo(false); + assertThat(Restarter.getInstance()).hasFieldOrPropertyWithValue("enabled", false); } private void testInitialize(boolean failed) { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockTests.java index 8ae6a30751..a0b9a63263 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; @@ -78,8 +77,8 @@ public class SpringBootTestWebEnvironmentMockTests { @Test public void resourcePath() { - assertThat(ReflectionTestUtils.getField(this.servletContext, "resourceBasePath")) - .isEqualTo("src/main/webapp"); + assertThat(this.servletContext).hasFieldOrPropertyWithValue("resourceBasePath", + "src/main/webapp"); } @Configuration diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests.java index 032ffdb349..83cc7adc36 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import static org.assertj.core.api.Assertions.assertThat; @@ -51,8 +50,8 @@ public class SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests { @Test public void resourcePath() { - assertThat(ReflectionTestUtils.getField(this.servletContext, "resourceBasePath")) - .isEqualTo("src/mymain/mywebapp"); + assertThat(this.servletContext).hasFieldOrPropertyWithValue("resourceBasePath", + "src/mymain/mywebapp"); } @Configuration diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java index a1c177ae6d..89040e206e 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java @@ -372,10 +372,8 @@ public class TestRestTemplateTests { assertThat(requestFactoryInterceptors).hasSize(1); ClientHttpRequestInterceptor interceptor = requestFactoryInterceptors.get(0); assertThat(interceptor).isInstanceOf(BasicAuthorizationInterceptor.class); - assertThat(ReflectionTestUtils.getField(interceptor, "username")) - .isEqualTo(username); - assertThat(ReflectionTestUtils.getField(interceptor, "password")) - .isEqualTo(password); + assertThat(interceptor).hasFieldOrPropertyWithValue("username", username); + assertThat(interceptor).hasFieldOrPropertyWithValue("password", password); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderSimpleIntegrationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderSimpleIntegrationTests.java index 4892675c55..f1e9c8e8df 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderSimpleIntegrationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderSimpleIntegrationTests.java @@ -25,7 +25,6 @@ import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.SimpleClientHttpRequestFactory; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.ws.transport.WebServiceMessageSender; import org.springframework.ws.transport.http.ClientHttpRequestMessageSender; @@ -56,10 +55,8 @@ public class HttpWebServiceMessageSenderBuilderSimpleIntegrationTests { .setReadTimeout(Duration.ofSeconds(2)).build(); SimpleClientHttpRequestFactory requestFactory = assertSimpleClientRequestFactory( messageSender); - assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout")) - .isEqualTo(5000); - assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout")) - .isEqualTo(2000); + assertThat(requestFactory).hasFieldOrPropertyWithValue("connectTimeout", 5000); + assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", 2000); } private SimpleClientHttpRequestFactory assertSimpleClientRequestFactory( diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderTests.java index 02cffe982f..932ec0d63c 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderTests.java @@ -56,10 +56,8 @@ public class HttpWebServiceMessageSenderBuilderTests { .setReadTimeout(Duration.ofSeconds(2))); SimpleClientHttpRequestFactory requestFactory = (SimpleClientHttpRequestFactory) messageSender .getRequestFactory(); - assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout")) - .isEqualTo(5000); - assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout")) - .isEqualTo(2000); + assertThat(requestFactory).hasFieldOrPropertyWithValue("connectTimeout", 5000); + assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", 2000); } @Test