Java 类org.mockito.internal.creation.DelegatingMethod 实例源码

项目:dexmaker    文件:InvocationHandlerAdapter.java   
/**
 * 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()));
}
项目:mockito-cglib    文件:MethodInterceptorFilter.java   
public MockitoMethod createMockitoMethod(Method method) {
    if (mockSettings.isSerializable()) {
        return new SerializableMethod(method);
    } else {
        return new DelegatingMethod(method);
    }
}
项目:mockito-cglib    文件:MethodInterceptorFilterTest.java   
@Test
public void shouldCreateJustDelegatingMethodIfIsNotSerializableMock() throws Exception {
    MethodInterceptorFilter filter = new MethodInterceptorFilter(handler, (MockSettingsImpl) withSettings());
    Method method = new InvocationBuilder().toInvocation().getMethod();

    // when
    MockitoMethod mockitoMethod = filter.createMockitoMethod(method);

    // then
    assertThat(mockitoMethod, instanceOf(DelegatingMethod.class));
}
项目:dexmaker    文件:InvocationHandlerAdapter.java   
@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()));
}
项目:dexmaker    文件:InvocationHandlerAdapter.java   
private ProxyInvocation(Object proxy, Method method, Object[] rawArgs, DelegatingMethod
        mockitoMethod, int sequenceNumber, Location location) {
    this.rawArgs = rawArgs;
    this.proxy = proxy;
    this.method = method;
    this.sequenceNumber = sequenceNumber;
    this.location = location;
    args = ArgumentsProcessor.expandArgs(mockitoMethod, rawArgs);
}
项目:dexmaker    文件:InvocationHandlerAdapter.java   
private ProxyInvocation(Object proxy, Method method, Object[] rawArgs, DelegatingMethod
                        mockitoMethod, int sequenceNumber, Location location) {
    this.rawArgs = rawArgs;
    this.proxy = proxy;
    this.method = method;
    this.sequenceNumber = sequenceNumber;
    this.location = location;
    args = ArgumentsProcessor.expandArgs(mockitoMethod, rawArgs);
}
项目:astor    文件:ObjectMethodsGuru.java   
public boolean isToString(Method method) {
    return isToString(new DelegatingMethod(method));
}
项目:astor    文件:ObjectMethodsGuru.java   
public boolean isToString(Method method) {
    return isToString(new DelegatingMethod(method));
}
项目:dexmaker    文件:InvocationHandlerAdapter.java   
/**
 * 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()));
}