org.powermock.api.mockito.internal.invocation
Class MockitoMethodInvocationControl
java.lang.Object
org.powermock.api.mockito.internal.invocation.MockitoMethodInvocationControl
- All Implemented Interfaces:
- InvocationHandler, DefaultBehavior, MethodInvocationControl
public class MockitoMethodInvocationControl
- extends Object
- implements MethodInvocationControl
A Mockito implementation of the MethodInvocationControl
interface.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MockitoMethodInvocationControl
public MockitoMethodInvocationControl(org.mockito.internal.creation.MethodInterceptorFilter methodInterceptionFilter,
Object mockInstance,
Method... methodsToMock)
- Creates a new instance.
- Parameters:
methodInterceptionFilter
- The methodInterceptionFilter to be associated with this
instance.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.methodsToMock
- The methods that are mocked for this instance. If
methodsToMock
is null or empty, all methods for
the invocationHandler
are considered to be
mocked.
MockitoMethodInvocationControl
public MockitoMethodInvocationControl(org.mockito.internal.creation.MethodInterceptorFilter methodInterceptionFilter,
Object delegator,
Object mockInstance,
Method... methodsToMock)
- Creates a new instance with a delegator. This delegator may be
null
(if it is then no calls will be forwarded to this
instance). If a delegator exists (i.e. not null) all non-mocked calls
will be delegated to that instance.
- Parameters:
methodInterceptionFilter
- The methodInterceptionFilter to be associated with this
instance.delegator
- If the user spies on an instance the original instance must be
injected here.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.methodsToMock
- The methods that are mocked for this instance. If
methodsToMock
is null or empty, all methods for
the invocationHandler
are considered to be
mocked.
isMocked
public boolean isMocked(Method method)
-
- Specified by:
isMocked
in interface MethodInvocationControl
invoke
public Object invoke(Object obj,
Method method,
Object[] arguments)
throws Throwable
- Specified by:
invoke
in interface InvocationHandler
- Throws:
Throwable
replay
public Object replay(Object... mocks)
- Specified by:
replay
in interface DefaultBehavior
reset
public Object reset(Object... mocks)
- Specified by:
reset
in interface DefaultBehavior
verify
public Object verify(Object... mocks)
- Specified by:
verify
in interface DefaultBehavior
verifyNoMoreInteractions
public void verifyNoMoreInteractions()
getInvocationHandler
public org.mockito.internal.creation.MethodInterceptorFilter getInvocationHandler()
Copyright © 2007-2014. All Rights Reserved.