001
014
015 package com.liferay.portal.test.aspects;
016
017 import com.liferay.portal.kernel.util.ReflectionUtil;
018
019 import org.aspectj.lang.ProceedingJoinPoint;
020 import org.aspectj.lang.annotation.Around;
021 import org.aspectj.lang.annotation.Aspect;
022
023
026 @Aspect
027 public class ReflectionUtilAdvice {
028
029 public static void setDeclaredFieldThrowable(
030 Throwable declaredFieldThrowable) {
031
032 _declaredFieldThrowable = declaredFieldThrowable;
033 }
034
035 public static void setDeclaredMethodThrowable(
036 Throwable declaredMethodThrowable)
037 throws ClassNotFoundException {
038
039 Class.forName(
040 ReflectionUtil.class.getName(), true,
041 ReflectionUtil.class.getClassLoader());
042
043 _declaredMethodThrowable = declaredMethodThrowable;
044 }
045
046 @Around(
047 "execution(public static java.lang.reflect.Field " +
048 "com.liferay.portal.kernel.util.ReflectionUtil." +
049 "getDeclaredField(Class, String))")
050 public Object getDeclaredField(ProceedingJoinPoint proceedingJoinPoint)
051 throws Throwable {
052
053 if (_declaredFieldThrowable != null) {
054 throw _declaredFieldThrowable;
055 }
056
057 return proceedingJoinPoint.proceed();
058 }
059
060 @Around(
061 "execution(public static java.lang.reflect.Method " +
062 "com.liferay.portal.kernel.util.ReflectionUtil." +
063 "getDeclaredMethod(Class, String, Class...))")
064 public Object getDeclaredMethod(ProceedingJoinPoint proceedingJoinPoint)
065 throws Throwable {
066
067 if (_declaredMethodThrowable != null) {
068 throw _declaredMethodThrowable;
069 }
070
071 return proceedingJoinPoint.proceed();
072 }
073
074 private static Throwable _declaredFieldThrowable;
075 private static Throwable _declaredMethodThrowable;
076
077 }