From 062104f1d67c90f6796059c830683ce5b59f7e60 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sun, 25 Dec 2016 10:00:20 +0100 Subject: [PATCH] Fix TestRestTemplate#patchFor methods visibility Closes gh-7742 --- .../boot/test/web/client/TestRestTemplate.java | 12 ++++++------ .../boot/test/web/client/TestRestTemplateTests.java | 11 +++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java b/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java index 3cb73a2a52..7f77844163 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java @@ -575,10 +575,10 @@ public class TestRestTemplate { * @param the type of the return value * @return the converted object * @throws RestClientException on client-side HTTP error + * @since 1.4.4 * @see HttpEntity - * @since 1.4.3 */ - T patchForObject(String url, Object request, Class responseType, + public T patchForObject(String url, Object request, Class responseType, Object... uriVariables) throws RestClientException { return this.restTemplate.patchForObject(url, request, responseType, uriVariables); } @@ -598,10 +598,10 @@ public class TestRestTemplate { * @param the type of the return value * @return the converted object * @throws RestClientException on client-side HTTP error + * @since 1.4.4 * @see HttpEntity - * @since 1.4.3 */ - T patchForObject(String url, Object request, Class responseType, + public T patchForObject(String url, Object request, Class responseType, Map uriVariables) throws RestClientException { return this.restTemplate.patchForObject(url, request, responseType, uriVariables); } @@ -618,10 +618,10 @@ public class TestRestTemplate { * @param the type of the return value * @return the converted object * @throws RestClientException on client-side HTTP error + * @since 1.4.4 * @see HttpEntity - * @since 1.4.3 */ - T patchForObject(URI url, Object request, Class responseType) + public T patchForObject(URI url, Object request, Class responseType) throws RestClientException { return this.restTemplate.patchForObject(url, request, responseType); diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java index 4a7a4a4d5a..924e230c27 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java @@ -17,6 +17,7 @@ package org.springframework.boot.test.web.client; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.net.URI; import java.util.List; @@ -47,6 +48,7 @@ import static org.mockito.Mockito.mock; * * @author Dave Syer * @author Phillip Webb + * @author Stephane Nicoll */ public class TestRestTemplateTests { @@ -93,6 +95,9 @@ public class TestRestTemplateTests { throws IllegalArgumentException, IllegalAccessException { Method equivalent = ReflectionUtils.findMethod(TestRestTemplate.class, method.getName(), method.getParameterTypes()); + assertThat(equivalent).as("Method %s not found", method).isNotNull(); + assertThat(Modifier.isPublic(equivalent.getModifiers())) + .as("Method %s should have been public", equivalent).isTrue(); try { equivalent.invoke(restTemplate, mockArguments(method.getParameterTypes())); @@ -129,6 +134,12 @@ public class TestRestTemplateTests { return mock(type); } + }, new ReflectionUtils.MethodFilter() { + @Override + public boolean matches(Method method) { + return Modifier.isPublic(method.getModifiers()); + } + }); }