public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { if (objectMethodsGuru.isEqualsMethod(method)) { return proxy == args[0]; } else if (objectMethodsGuru.isHashCodeMethod(method)) { return hashCodeForMock(proxy); } else if (acrossJVMSerializationFeature.isWriteReplace(method)) { return acrossJVMSerializationFeature.writeReplace(proxy); } MockitoMethodProxy mockitoMethodProxy = createMockitoMethodProxy(methodProxy); new CGLIBHacker().setMockitoNamingPolicy(methodProxy); MockitoMethod mockitoMethod = createMockitoMethod(method); CleanTraceRealMethod realMethod = new CleanTraceRealMethod(mockitoMethodProxy); Invocation invocation = new InvocationImpl(proxy, mockitoMethod, args, SequenceNumber.next(), realMethod); return handler.handle(invocation); }
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { if (objectMethodsGuru.isEqualsMethod(method)) { return proxy == args[0]; } else if (objectMethodsGuru.isHashCodeMethod(method)) { return hashCodeForMock(proxy); } MockitoMethodProxy mockitoMethodProxy = createMockitoMethodProxy(methodProxy); cglibHacker.setMockitoNamingPolicy(mockitoMethodProxy); MockitoMethod mockitoMethod = createMockitoMethod(method); FilteredCGLIBProxyRealMethod realMethod = new FilteredCGLIBProxyRealMethod(mockitoMethodProxy); Invocation invocation = new Invocation(proxy, mockitoMethod, args, SequenceNumber.next(), realMethod); return handler.handle(invocation); }
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { if (objectMethodsGuru.isEqualsMethod(method)) { return proxy == args[0]; } else if (objectMethodsGuru.isHashCodeMethod(method)) { return hashCodeForMock(proxy); } else if (acrossJVMSerializationFeature.isWriteReplace(method)) { return acrossJVMSerializationFeature.writeReplace(proxy); } MockitoMethodProxy mockitoMethodProxy = createMockitoMethodProxy(methodProxy); cglibHacker.setMockitoNamingPolicy(mockitoMethodProxy); MockitoMethod mockitoMethod = createMockitoMethod(method); FilteredCGLIBProxyRealMethod realMethod = new FilteredCGLIBProxyRealMethod(mockitoMethodProxy); Invocation invocation = new InvocationImpl(proxy, mockitoMethod, args, SequenceNumber.next(), realMethod); return handler.handle(invocation); }
/** * Intercept a method call. Called <u>before</u> a method is called by the proxied method. * * <p>This does the same as {@link #interceptEntryHook(Object, Method, Object[], * InterceptedInvocation.SuperMethod)} but this handles proxied methods. We only proxy abstract * methods. * * @param proxy proxies object * @param method method that was called * @param argsIn arguments to the method * * @return mocked result * @throws Throwable An exception if thrown */ @Override public Object invoke(final Object proxy, final Method method, Object[] argsIn) throws Throwable { // args can be null if the method invoked has no arguments, but Mockito expects a non-null // array final Object[] args = argsIn != null ? argsIn : new Object[0]; if (isEqualsMethod(method)) { return proxy == args[0]; } else if (isHashCodeMethod(method)) { return System.identityHashCode(proxy); } return handler.handle(new ProxyInvocation(proxy, method, args, new DelegatingMethod (method), SequenceNumber.next(), new LocationImpl())); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (objectMethodsGuru.isEqualsMethod(method)) { return proxy == args[0]; } else if (objectMethodsGuru.isHashCodeMethod(method)) { return System.identityHashCode(proxy); } if (args == null) { throw new IllegalArgumentException(); } ProxiedMethod proxiedMethod = new ProxiedMethod(method); return handler.handle(new InvocationImpl(proxy, proxiedMethod, args, SequenceNumber.next(), proxiedMethod)); }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // args can be null if the method invoked has no arguments, but Mockito expects a non-null array args = args != null ? args : new Object[0]; if (isEqualsMethod(method)) { return proxy == args[0]; } else if (isHashCodeMethod(method)) { return System.identityHashCode(proxy); } return handler.handle(new ProxyInvocation(proxy, method, args, new DelegatingMethod (method), SequenceNumber.next(), new LocationImpl())); }
/** * Intercept a method call. Called <u>before</u> a method is called by the method entry hook. * * <p>This does the same as {@link #invoke(Object, Method, Object[])} but this handles methods * that got and entry hook. * * @param mock mocked object * @param method method that was called * @param args arguments to the method * @param superMethod The super method * * @return mocked result * @throws Throwable An exception if thrown */ Object interceptEntryHook(Object mock, Method method, Object[] args, InterceptedInvocation.SuperMethod superMethod) throws Throwable { return handler.handle(new InterceptedInvocation(mock, new DelegatingMethod(method), args, superMethod, SequenceNumber.next())); }