Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInvocation.proceed()


    EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
    interceptor.setApplicationEventClass(MyEvent.class);
    interceptor.setApplicationEventPublisher(ctx);
    interceptor.afterPropertiesSet();

    given(invocation.proceed()).willReturn(new Object());
    given(invocation.getThis()).willReturn(new Object());
    interceptor.invoke(invocation);
    verify(ctx).publishEvent(isA(MyEvent.class));
  }
View Full Code Here


    @Override
    public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
      MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args,
          this.targetClass, this.adviceChain, methodProxy);
      // If we get here, we need to create a MethodInvocation.
      Object retVal = invocation.proceed();
      retVal = processReturnType(proxy, this.target, method, retVal);
      return retVal;
    }
  }
View Full Code Here

      }
      else {
        // We need to create a method invocation...
        invocation = new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain);
        // Proceed to the joinpoint through the interceptor chain.
        retVal = invocation.proceed();
      }

      // Massage return value if necessary.
      Class<?> returnType = method.getReturnType();
      if (retVal != null && retVal == target && returnType.isInstance(proxy) &&
View Full Code Here

  public void testNotInvoked() throws Throwable {
    MyThrowsHandler th = new MyThrowsHandler();
    ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
    Object ret = new Object();
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.proceed()).willReturn(ret);
    assertEquals(ret, ti.invoke(mi));
    assertEquals(0, th.getCalls());
  }

  @Test
View Full Code Here

    MyThrowsHandler th = new MyThrowsHandler();
    ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
    assertEquals(2, ti.getHandlerMethodCount());
    Exception ex = new Exception();
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.proceed()).willThrow(ex);
    try {
      ti.invoke(mi);
      fail();
    }
    catch (Exception caught) {
View Full Code Here

    ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
    FileNotFoundException ex = new FileNotFoundException();
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.getMethod()).willReturn(Object.class.getMethod("hashCode", (Class[]) null));
    given(mi.getThis()).willReturn(new Object());
    given(mi.proceed()).willThrow(ex);
    try {
      ti.invoke(mi);
      fail();
    }
    catch (Exception caught) {
View Full Code Here

    MethodInvocation methodInvocation = mock(MethodInvocation.class);

    IllegalArgumentException exception = new IllegalArgumentException();
    given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
    given(methodInvocation.getThis()).willReturn(this);
    given(methodInvocation.proceed()).willThrow(exception);

    Log log = mock(Log.class);
    given(log.isTraceEnabled()).willReturn(true);

    CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
View Full Code Here

    MyThrowsHandler th = new MyThrowsHandler();
    ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
    // Extends RemoteException
    TransactionRolledbackException ex = new TransactionRolledbackException();
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.proceed()).willThrow(ex);
    try {
      ti.invoke(mi);
      fail();
    }
    catch (Exception caught) {
View Full Code Here

    ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
    // Extends RemoteException
    TransactionRolledbackException ex = new TransactionRolledbackException();
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.proceed()).willThrow(ex);
    try {
      ti.invoke(mi);
      fail();
    }
    catch (Throwable caught) {
View Full Code Here

    MethodInvocation methodInvocation = mock(MethodInvocation.class);

    given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
    given(methodInvocation.getThis()).willReturn(this);
    given(methodInvocation.getArguments()).willReturn(new Object[]{"$ One \\$", new Long(2)});
    given(methodInvocation.proceed()).willReturn("Hello!");

    Log log = mock(Log.class);
    given(log.isTraceEnabled()).willReturn(true);

    CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.