org.jage.test
Class ReflectionTestUtils

java.lang.Object
  extended by org.jage.test.ReflectionTestUtils

public class ReflectionTestUtils
extends Object

ReflectionTestUtils is a collection of reflection-based utility methods for use in unit and integration testing scenarios.

This class is actually just an facade to the Spring implementation, aiming to centralize and hide that coupling.

Author:
AGH AgE Team
See Also:
org.springframework.test.util.ReflectionTestUtils

Constructor Summary
ReflectionTestUtils()
           
 
Method Summary
static Object getField(Object target, String name)
          Get the field with the given name from the provided target object.
static void setField(Object target, String name, Object value)
          Set the field with the given name on the provided target object to the supplied value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionTestUtils

public ReflectionTestUtils()
Method Detail

setField

public static void setField(Object target,
                            String name,
                            Object value)
Set the field with the given name on the provided target object to the supplied value.

This method traverses the class hierarchy in search of the desired field. In addition, an attempt will be made to make non-public fields accessible, thus allowing one to set protected, private, and package-private fields.

Parameters:
target - the target object on which to set the field
name - the name of the field to set
value - the value to set
See Also:
org.springframework.test.util.ReflectionTestUtils#setField(Object, String, Object)

getField

public static Object getField(Object target,
                              String name)
Get the field with the given name from the provided target object.

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

Parameters:
target - the target object on which to set the field
name - the name of the field to get
Returns:
the field's current value
See Also:
org.springframework.test.util.ReflectionTestUtils#getField(Object, String)


Copyright © 2006-2011 AGH University of Science and Technology. All Rights Reserved.