Replace ReflectionTestUtils usage by hasFieldOrPropertyWithValue
Closes gh-14696
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user