From b1ca18e0dc0579defdc7ccaa6bb862185412ac92 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 15 Mar 2016 19:15:38 +0100 Subject: [PATCH] Document proxy support in ReflectionTestUtils Issue: SPR-14050 --- .../org/springframework/test/util/ReflectionTestUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spring-test/src/main/java/org/springframework/test/util/ReflectionTestUtils.java b/spring-test/src/main/java/org/springframework/test/util/ReflectionTestUtils.java index 156d5c3960..71fb0da936 100644 --- a/spring-test/src/main/java/org/springframework/test/util/ReflectionTestUtils.java +++ b/spring-test/src/main/java/org/springframework/test/util/ReflectionTestUtils.java @@ -138,6 +138,9 @@ public class ReflectionTestUtils { * Set the {@linkplain Field field} with the given {@code name}/{@code type} * on the provided {@code targetObject}/{@code targetClass} to the supplied * {@code value}. + *

If the supplied {@code targetObject} is a proxy, it will + * be {@linkplain AopTestUtils#getUltimateTargetObject unwrapped} allowing + * the field to be set on the ultimate target of the proxy. *

This method traverses the class hierarchy in search of the desired * field. In addition, an attempt will be made to make non-{@code public} * fields accessible, thus allowing one to set {@code protected}, @@ -154,6 +157,7 @@ public class ReflectionTestUtils { * @see ReflectionUtils#findField(Class, String, Class) * @see ReflectionUtils#makeAccessible(Field) * @see ReflectionUtils#setField(Field, Object, Object) + * @see AopTestUtils#getUltimateTargetObject(Object) * @since 4.2 */ public static void setField(Object targetObject, Class targetClass, String name, Object value, Class type) { @@ -217,6 +221,9 @@ public class ReflectionTestUtils { /** * Get the value of the {@linkplain Field field} with the given {@code name} * from the provided {@code targetObject}/{@code targetClass}. + *

If the supplied {@code targetObject} is a proxy, it will + * be {@linkplain AopTestUtils#getUltimateTargetObject unwrapped} allowing + * the field to be retrieved from the ultimate target of the proxy. *

This method traverses the class hierarchy in search of the desired * field. In addition, an attempt will be made to make non-{@code public} * fields accessible, thus allowing one to get {@code protected},