Package org.aopalliance.intercept

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


  @Test
  public void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
    MethodInvocation mi = mock(MethodInvocation.class);

    given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
    given(mi.proceed()).willThrow(new IllegalArgumentException());
    Log log = mock(Log.class);

    PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
    try {
      interceptor.invokeUnderTrace(mi, log);
View Full Code Here


  public void testExceptionPathStillLogsCorrectly() throws Throwable {
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
    given(mi.getThis()).willReturn(this);
    IllegalArgumentException exception = new IllegalArgumentException();
    given(mi.proceed()).willThrow(exception);

    Log log = mock(Log.class);

    final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
View Full Code Here

  public void testExceptionPathStillLogsCorrectly() throws Throwable {

    MethodInvocation methodInvocation = mock(MethodInvocation.class);

    IllegalArgumentException exception = new IllegalArgumentException();
    given(methodInvocation.proceed()).willThrow(exception);

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

    DebugInterceptor interceptor = new StubDebugInterceptor(log);
View Full Code Here

    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 = massageReturnTypeIfNecessary(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.
      if (retVal != null && retVal == target && method.getReturnType().isInstance(proxy) &&
          !RawTargetAccess.class.isAssignableFrom(method.getDeclaringClass())) {
View Full Code Here

  @Test
  public void invoke_A$MethodInvocation() throws Throwable {
    MemcachedCacheResultInterceptor interceptor = new MemcachedCacheResultInterceptor();
    MethodInvocation invocation = mock(MethodInvocation.class);
        when(invocation.getMethod()).thenReturn(Foo.class.getDeclaredMethod("doSomething"));
        when(invocation.proceed()).thenReturn("foo");
    Object result = interceptor.invoke(invocation);
    Object expected = "foo";
    assertThat(result, is(equalTo(expected)));
  }
View Full Code Here

            else {
              throw new IllegalStateException(
                  "MethodInvocation of the wrong type detected - this should not happen with Spring AOP, so please raise an issue if you see this exception");
            }

            Object value = clone.proceed();
            if (voidReturnType) {
              return RepeatStatus.CONTINUABLE;
            }
            if (!isComplete(value)) {
              // Save the last result
View Full Code Here

        final MethodInvocation temp = invocation;
        return asyncLoadTemplate.execute(new AsyncLoadCallback() {

            public Object doAsyncLoad() {
                try {
                    return temp.proceed();
                } catch (Throwable e) {
                    throw new AsyncLoadException("AsyncLoadInterceptor invoke error!", e);
                }
            }
        }, invocation.getMethod().getReturnType()); // 这里指定了返回目标class
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.