public class EasyMockMethodInvocationControl<T> extends Object implements MethodInvocationControl
MethodInvocationControl
interface.Constructor and Description |
---|
EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler,
Set<Method> methodsToMock)
Initializes internal state.
|
EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler,
Set<Method> methodsToMock,
T mockInstance)
Initializes internal state.
|
Modifier and Type | Method and Description |
---|---|
org.easymock.MockType |
getMockType() |
Object |
invoke(Object proxy,
Method method,
Object[] arguments) |
boolean |
isMocked(Method method)
Determine whether a certain method is mocked by this Invocation Control.
|
Object |
replay(Object... mocks)
Replay the given objects or classes.
|
Object |
reset(Object... mocks)
Reset the given objects or classes.
|
Object |
verify(Object... mocks) |
public EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler, Set<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, Set<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(Method method)
MethodInvocationControl
isMocked
in interface MethodInvocationControl
method
- The method that should be checked.true
if the method is mocked, false
otherwise.public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable
invoke
in interface InvocationHandler
Throwable
public org.easymock.MockType getMockType()
public Object replay(Object... mocks)
DefaultBehavior
replay
in interface DefaultBehavior
mocks
- The object(s) to replay. May be null
.null
).public Object reset(Object... mocks)
DefaultBehavior
reset
in interface DefaultBehavior
mocks
- The object(s) to replay. May be null
.null
).Copyright © 2019. All rights reserved.