org.powermock.api.easymock.internal.invocationcontrol
Class EasyMockMethodInvocationControl<T>

java.lang.Object
  extended by org.powermock.api.easymock.internal.invocationcontrol.EasyMockMethodInvocationControl<T>
All Implemented Interfaces:
InvocationHandler, DefaultBehavior, MethodInvocationControl

public class EasyMockMethodInvocationControl<T>
extends Object
implements MethodInvocationControl

The default implementation of the MethodInvocationControl interface.


Constructor Summary
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.
 
Method Summary
 org.easymock.internal.MocksControl.MockType getMockType()
           
 Object invoke(Object proxy, Method method, Object[] arguments)
           
 boolean isMocked(Method method)
          
 Object replay(Object... mocks)
          
 Object reset(Object... mocks)
          
 Object verify(Object... mocks)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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. 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.

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. If methodsToMock is null all methods for the invocationHandler are considered to be mocked.
Method Detail

isMocked

public boolean isMocked(Method method)

Specified by:
isMocked in interface MethodInvocationControl

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] arguments)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

getMockType

public org.easymock.internal.MocksControl.MockType getMockType()

replay

public Object replay(Object... mocks)

Specified by:
replay in interface DefaultBehavior

verify

public Object verify(Object... mocks)

Specified by:
verify in interface DefaultBehavior

reset

public Object reset(Object... mocks)

Specified by:
reset in interface DefaultBehavior


Copyright © 2007-2013. All Rights Reserved.