Top Description Inners Constructors Methods
org.easymock.internal

public final Class AndroidClassProxyFactory

extends Object
implements IProxyFactory
Class Inheritance
All Implemented Interfaces
org.easymock.internal.IProxyFactory
Imports
java.io.IOException, java.lang.reflect.Constructor, .InvocationHandler, .Method, .Modifier, java.util.Arrays, .HashSet, .Set, org.easymock.ConstructorArgs, org.droidparts.dexmaker.stock.ProxyBuilder

Mocks concrete classes for Android's runtime by generating dex files.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <T> T
createProxy(Class<T>
the class to mock by the factory
toMock
,
InvocationHandler
the handler that will be linked to the created proxy
handler
,
Method[]
the subset of toMock's methods to mock, or null to mock all methods.
mockedMethods
,
ConstructorArgs
the constructor arguments to use, or null to use heuristics to choose a constructor.
constructorArgs
)

Implements org.easymock.internal.IProxyFactory.createProxy.

public InvocationHandler
getInvocationHandler(Object
a mock instance previously returned by createProxy.
mock
)

Implements org.easymock.internal.IProxyFactory.getInvocationHandler.

Returns the invocation handler for mock;
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AndroidClassProxyFactoryback to summary
public AndroidClassProxyFactory()

Method Detail

createProxyback to summary
public <T> T createProxy(Class<T> toMock, InvocationHandler handler, Method[] mockedMethods, ConstructorArgs constructorArgs)

Implements org.easymock.internal.IProxyFactory.createProxy.

Parameters
<T>

Doc from org.easymock.internal.IProxyFactory.createProxy. type of the class to mock

toMock:Class<T>

Doc from org.easymock.internal.IProxyFactory.createProxy.

the class to mock by the factory

handler:InvocationHandler

Doc from org.easymock.internal.IProxyFactory.createProxy.

the handler that will be linked to the created proxy

mockedMethods:Method[]

Doc from org.easymock.internal.IProxyFactory.createProxy.

the subset of toMock's methods to mock, or null to mock all methods.

constructorArgs:ConstructorArgs

Doc from org.easymock.internal.IProxyFactory.createProxy.

the constructor arguments to use, or null to use heuristics to choose a constructor.

Returns:T

Doc from org.easymock.internal.IProxyFactory.createProxy.

the newly created proxy

getInvocationHandlerback to summary
public InvocationHandler getInvocationHandler(Object mock)

Implements org.easymock.internal.IProxyFactory.getInvocationHandler.

Doc from org.easymock.internal.IProxyFactory.getInvocationHandler.

Returns the invocation handler for mock;

Parameters
mock:Object

a mock instance previously returned by createProxy.

Returns:InvocationHandler

the handler handling method calls for the mock

org.easymock.internal back to summary

private Class AndroidClassProxyFactory.MockHandler

extends Object
implements InvocationHandler
Class Inheritance
All Implemented Interfaces
java.lang.reflect.InvocationHandler

Field Summary

Modifier and TypeField and Description
private final InvocationHandler
private final Set<Method>

Constructor Summary

AccessConstructor and Description
public
MockHandler(InvocationHandler delegate, Method... mockedMethods)

Method Summary

Modifier and TypeMethod and Description
public Object
invoke(Object
the proxy instance that the method was invoked on
obj
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.
private boolean
isMocked(Method method)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final InvocationHandler delegate
mockedMethodsback to summary
private final Set<Method> mockedMethods

Constructor Detail

MockHandlerback to summary
public MockHandler(InvocationHandler delegate, Method... mockedMethods)

Method Detail

invokeback to summary
public Object invoke(Object obj, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
obj:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.
isMockedback to summary
private boolean isMocked(Method method)