public class EasyMockMethodInvocationControl<T> extends java.lang.Object implements MethodInvocationControl
MethodInvocationControl
interface.Modifier and Type | Field and Description |
---|---|
private boolean |
hasReplayed |
private boolean |
hasVerified |
private org.easymock.internal.MockInvocationHandler |
invocationHandler |
private java.util.Set<java.lang.reflect.Method> |
mockedMethods |
private T |
mockInstance |
Constructor and Description |
---|
EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler,
java.util.Set<java.lang.reflect.Method> methodsToMock)
Initializes internal state.
|
EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler,
java.util.Set<java.lang.reflect.Method> methodsToMock,
T mockInstance)
Initializes internal state.
|
Modifier and Type | Method and Description |
---|---|
org.easymock.internal.MocksControl.MockType |
getMockType() |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] arguments) |
boolean |
isMocked(java.lang.reflect.Method method)
Determine whether a certain method is mocked by this Invocation Control.
|
java.lang.Object |
replay(java.lang.Object... mocks)
Replay the given objects or classes.
|
java.lang.Object |
reset(java.lang.Object... mocks)
Reset the given objects or classes.
|
java.lang.Object |
verify(java.lang.Object... mocks)
Verify the given objects or classes.
|
private org.easymock.internal.MockInvocationHandler invocationHandler
private java.util.Set<java.lang.reflect.Method> mockedMethods
private T mockInstance
private boolean hasReplayed
private boolean hasVerified
public EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler, java.util.Set<java.lang.reflect.Method> methodsToMock, T mockInstance)
invocationHandler
- The mock invocation handler to be associated with this
instance.methodsToMock
- The methods that are mocked for this instance. If
methodsToMock
is null all methods for the
invocationHandler
are considered to be mocked.mockInstance
- The actual mock instance. May be null
. Even
though the mock instance may not be used it's needed to keep a
reference to this object otherwise it may be garbage collected
in some situations. For example when mocking static methods we
don't return the mock object and thus it will be garbage
collected (and thus the finalize method will be invoked which
will be caught by the proxy and the test will fail because we
haven't setup expectations for this method) because then that
object has no reference. In order to avoid this we keep a
reference to this instance here.public EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler, java.util.Set<java.lang.reflect.Method> methodsToMock)
invocationHandler
- The mock invocation handler to be associated with this
instance.methodsToMock
- The methods that are mocked for this instance. If
methodsToMock
is null all methods for the
invocationHandler
are considered to be mocked.public boolean isMocked(java.lang.reflect.Method method)
isMocked
in interface MethodInvocationControl
method
- The method that should be checked.true
if the method is mocked, false
otherwise.public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] arguments) throws java.lang.Throwable
invoke
in interface java.lang.reflect.InvocationHandler
java.lang.Throwable
public org.easymock.internal.MocksControl.MockType getMockType()
public java.lang.Object replay(java.lang.Object... mocks)
replay
in interface DefaultBehavior
null
).public java.lang.Object verify(java.lang.Object... mocks)
verify
in interface DefaultBehavior
null
).public java.lang.Object reset(java.lang.Object... mocks)
reset
in interface DefaultBehavior
null
).