### Question:
InjectionUtil { public static <T> T callMethod(Class<T> retClass, Class<?> targetClass, Object target, String method, Class[] argClasses, Object[] args) { try { Method classMethod = targetClass.getDeclaredMethod(method, argClasses); return AccessController.doPrivileged( new SetMethodPrivilegedAction<T>(classMethod, target, args)); } catch (NoSuchMethodException e) { throw new TransfuseInjectionException("Exception during method injection: NoSuchFieldException", e); } catch (PrivilegedActionException e) { throw new TransfuseInjectionException("PrivilegedActionException Exception during field injection", e); } catch (Exception e) { throw new TransfuseInjectionException("Exception during field injection", e); } } private  InjectionUtil(); static T getField(Class<T> returnType, Class<?> targetClass, Object target, String field); static T getField(GenericType<T> returnType, Class<?> targetClass, Object target, String field); static void setField(Class<?> targetClass, Object target, String field, Object value); static T callMethod(Class<T> retClass, Class<?> targetClass, Object target, String method, Class[] argClasses, Object[] args); static T callMethod(GenericType<T> retClass, Class<?> targetClass, Object target, String method, Class[] argClasses, Object[] args); static T callConstructor(Class<T> targetClass, Class[] argClasses, Object[] args); static T callConstructor(GenericType<T> targetClass, Class[] argClasses, Object[] args); static final String GET_FIELD_METHOD; static final String SET_FIELD_METHOD; static final String CALL_METHOD_METHOD; static final String CALL_CONSTRUCTOR_METHOD; }### Answer:
@Test public void testPrivateMethodInjection() { Target target = new Target(); assertNull(target.getValue()); InjectionUtil.callMethod(Void.class, Target.class, target, "setPrivateValue", new Class[]{String.class}, new Object[]{TEST_VALUE}); assertEquals(TEST_VALUE, target.getValue()); }
@Test public void testPrivateMethodGet() { Target target = new Target(); assertNull(target.getValue()); target.setValue(TEST_VALUE); assertEquals(TEST_VALUE, InjectionUtil.callMethod(String.class, Target.class, target, "getPrivateValue", new Class[]{}, new Object[]{})); }
@Test public void testPrivateSuperMethodInjection() { Target target = new Target(); assertNull(target.getValue()); InjectionUtil.callMethod(Void.class, TargetSuper.class, target, "setSuperValue", new Class[]{String.class}, new Object[]{TEST_VALUE}); assertEquals(TEST_VALUE, target.getSuperValue()); }