2 Replies Latest reply on Nov 4, 2004 2:19 PM by André Dantas Rocha

    Intercept invoke(Object, Object[])

    André Dantas Rocha Newbie


      I'd like to intercept all calls to java.lang.reflect.Method->invoke(Object, Object[]) inside method junit.framework.TestCase->runTest() made from classes that extends junit.framework.TestCase.

      I'm using runtime weaving via xml and created the class:

      public class TestCaseInterceptor extends ReflectionAspect {
       protected Object interceptMethod(Invocation invocation, Method method,
       Object instance, Object[] args) throws Throwable {
       return instance;

      I don't know how to create the xml file and restrict my pointcut, so my second approch was to create a normal java class and try this xml file (still not working):

      <interceptor class="aftt.weaving.TestCaseInterceptor"/>
       <bind pointcut="execution(public Object java.lang.reflect.Method->invoke(Object, Object[]) throws
       IllegalAccessException, IllegalArgumentException, InvocationTargetException)
       withincode(protected void $instanceof{junit.framework.TestCase}->runTest() throws Throwable)">
       <interceptor-ref name="aftt.weaving.TestCaseInterceptor"/>

      How can I do it?