Class EasyMockMethodInvocationControl<T>
java.lang.Object
org.powermock.api.easymock.internal.invocationcontrol.EasyMockMethodInvocationControl<T>
- All Implemented Interfaces:
InvocationHandler
,DefaultBehavior
,MethodInvocationControl
The default implementation of the
MethodInvocationControl
interface.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private org.easymock.internal.MockInvocationHandler
private T
-
Constructor Summary
ConstructorsConstructorDescriptionEasyMockMethodInvocationControl
(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. -
Method Summary
Modifier and TypeMethodDescriptionorg.easymock.internal.MocksControl.MockType
boolean
Determine whether a certain method is mocked by this Invocation Control.Replay the given objects or classes.Reset the given objects or classes.Verify the given objects or classes.
-
Field Details
-
invocationHandler
private org.easymock.internal.MockInvocationHandler invocationHandler -
mockedMethods
-
mockInstance
-
hasReplayed
private boolean hasReplayed -
hasVerified
private boolean hasVerified
-
-
Constructor Details
-
EasyMockMethodInvocationControl
public EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler, Set<Method> methodsToMock, T mockInstance) Initializes internal state.- Parameters:
invocationHandler
- The mock invocation handler to be associated with this instance.methodsToMock
- The methods that are mocked for this instance. IfmethodsToMock
is null all methods for theinvocationHandler
are considered to be mocked.mockInstance
- The actual mock instance. May benull
. 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.
-
EasyMockMethodInvocationControl
public EasyMockMethodInvocationControl(org.easymock.internal.MockInvocationHandler invocationHandler, Set<Method> methodsToMock) Initializes internal state.- Parameters:
invocationHandler
- The mock invocation handler to be associated with this instance.methodsToMock
- The methods that are mocked for this instance. IfmethodsToMock
is null all methods for theinvocationHandler
are considered to be mocked.
-
-
Method Details
-
isMocked
Determine whether a certain method is mocked by this Invocation Control.- Specified by:
isMocked
in interfaceMethodInvocationControl
- Parameters:
method
- The method that should be checked.- Returns:
true
if the method is mocked,false
otherwise.
-
invoke
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-
getMockType
public org.easymock.internal.MocksControl.MockType getMockType() -
replay
Replay the given objects or classes. May throw exception if replay is not needed or not supported.- Specified by:
replay
in interfaceDefaultBehavior
- Returns:
- the result of the replay (may be
null
).
-
verify
Verify the given objects or classes. May throw exception if verify is not needed or not supported.- Specified by:
verify
in interfaceDefaultBehavior
- Returns:
- the result of the verification (may be
null
).
-
reset
Reset the given objects or classes. May throw exception if reset is not needed or not supported.- Specified by:
reset
in interfaceDefaultBehavior
- Returns:
- the result of the replay (may be
null
).
-