public class MockitoMethodInvocationControl extends Object implements org.powermock.core.spi.MethodInvocationControl
MethodInvocationControl
interface.Constructor and Description |
---|
MockitoMethodInvocationControl(org.mockito.internal.creation.MethodInterceptorFilter methodInterceptionFilter,
Object mockInstance,
Method... methodsToMock)
Creates a new instance.
|
MockitoMethodInvocationControl(org.mockito.internal.creation.MethodInterceptorFilter methodInterceptionFilter,
Object delegator,
Object mockInstance,
Method... methodsToMock)
Creates a new instance with a delegator.
|
Modifier and Type | Method and Description |
---|---|
org.mockito.internal.creation.MethodInterceptorFilter |
getInvocationHandler() |
Object |
invoke(Object obj,
Method method,
Object[] arguments) |
boolean |
isMocked(Method method) |
Object |
replay(Object... mocks) |
Object |
reset(Object... mocks) |
Object |
verify(Object... mocks) |
void |
verifyNoMoreInteractions() |
public MockitoMethodInvocationControl(org.mockito.internal.creation.MethodInterceptorFilter methodInterceptionFilter, Object mockInstance, Method... methodsToMock)
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.public MockitoMethodInvocationControl(org.mockito.internal.creation.MethodInterceptorFilter methodInterceptionFilter, Object delegator, Object mockInstance, Method... methodsToMock)
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.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.public boolean isMocked(Method method)
isMocked
in interface org.powermock.core.spi.MethodInvocationControl
public Object invoke(Object obj, Method method, Object[] arguments) throws Throwable
invoke
in interface InvocationHandler
Throwable
public Object replay(Object... mocks)
replay
in interface org.powermock.core.spi.DefaultBehavior
public Object reset(Object... mocks)
reset
in interface org.powermock.core.spi.DefaultBehavior
public Object verify(Object... mocks)
verify
in interface org.powermock.core.spi.DefaultBehavior
public void verifyNoMoreInteractions()
public org.mockito.internal.creation.MethodInterceptorFilter getInvocationHandler()
Copyright © 2007–2015. All rights reserved.