public class UnitTestUtils extends Object
| Constructor and Description |
|---|
UnitTestUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
callMethod(Object target,
String methodName) |
static List<Field> |
getAllFields(List<Field> fields,
Class<?> type) |
static Object |
getPrivateEnum(Class<SupportAuthenticationModuleAdapter> klass,
String enumName,
String constantName) |
static Object |
getPrivateField(Object target,
String fieldName) |
static <T> T |
getPrivateField(Object target,
String fieldName,
Class<T> type) |
static Object |
getSuperPrivateField(Object target,
String fieldName) |
static <T> T |
replaceWithSpy(Object target,
String fieldName,
Class<T> type)
This method extracts a named field, replaces it with a spy, and returns
the spy.
|
static void |
setPrivateField(Object target,
String fieldName,
Object value) |
public static void setPrivateField(Object target, String fieldName, Object value) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException
public static Object getPrivateField(Object target, String fieldName) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException
public static Object getSuperPrivateField(Object target, String fieldName) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException
public static <T> T getPrivateField(Object target, String fieldName, Class<T> type) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException
public static <T> T replaceWithSpy(Object target, String fieldName, Class<T> type) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException
T - the class of object which is being replaced with a spy.target - The object requiring a hot spy injectionfieldName - the field to spy ontype - The type of the spyNoSuchFieldException - if a field is not found. (Thrown from the java reflection API)IllegalArgumentException - if an argument is illegal. (Thrown from the java reflection API)IllegalAccessException - if access is exceptional. (Thrown from the java reflection API)public static Object getPrivateEnum(Class<SupportAuthenticationModuleAdapter> klass, String enumName, String constantName)
Copyright © 2014 JBoss by Red Hat. All Rights Reserved.