Package org.powermock.core
Class MockGateway
java.lang.Object
org.powermock.core.MockGateway
All mock invocations are routed through this gateway. This includes method
calls, construction of new instances and more. Do not use this class
directly, but always go through the PowerMock facade.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringUsed to tell the MockGateway that the next call should not be mocked regardless if aMethodInvocationControlis found in theMockRepository.static booleanTells PowerMock whether or not to mockObject.getClass().static booleanTells PowerMock to mock standard methods.static final Objectstatic final Object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectconstructorCall(Class<?> type, Object[] args, Class<?>[] sig) private static Object[]copyArgumentsForInnerOrLocalOrAnonymousClass(Object[] args, boolean excludeEnclosingInstance) The first parameter of an inner, local or anonymous inner class isnullor the enclosing instance.private static ObjectdoMethodCall(Object object, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString) static ObjectfieldCall(Object instanceOrClassContainingTheField, Class<?> classDefiningField, String fieldName, Class<?> fieldType) private static booleanisGetClassMethod(String methodName, Class<?>[] sig) private static booleanisJavaStandardMethod(String methodName, Class<?>[] sig) static ObjectmethodCall(Class<?> type, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString) static ObjectmethodCall(Object instance, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString) static ObjectnewInstanceCall(Class<?> type, Object[] args, Class<?>[] sig) private static booleanshouldMockMethod(String methodName, Class<?>[] sig) private static booleanstatic ObjectstaticConstructorCall(String className)
-
Field Details
-
PROCEED
-
SUPPRESS
-
DONT_MOCK_NEXT_CALL
Used to tell the MockGateway that the next call should not be mocked regardless if aMethodInvocationControlis found in theMockRepository. Used to allow for e.g. recursive partial mocking.- See Also:
-
MOCK_STANDARD_METHODS
public static boolean MOCK_STANDARD_METHODSTells PowerMock to mock standard methods. These areObject.toString(),Object.hashCode()andObject.equals(Object). By default this istrue. -
MOCK_GET_CLASS_METHOD
public static boolean MOCK_GET_CLASS_METHODTells PowerMock whether or not to mockObject.getClass().
-
-
Constructor Details
-
MockGateway
public MockGateway()
-
-
Method Details
-
methodCall
public static Object methodCall(Class<?> type, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString) throws Throwable - Throws:
Throwable
-
doMethodCall
private static Object doMethodCall(Object object, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString) throws Throwable - Throws:
Throwable
-
shouldMockMethod
-
isJavaStandardMethod
-
isGetClassMethod
-
shouldMockThisCall
private static boolean shouldMockThisCall() -
methodCall
public static Object methodCall(Object instance, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString) throws Throwable - Throws:
Throwable
-
newInstanceCall
- Throws:
Throwable
-
fieldCall
-
staticConstructorCall
-
constructorCall
- Throws:
Throwable
-
copyArgumentsForInnerOrLocalOrAnonymousClass
private static Object[] copyArgumentsForInnerOrLocalOrAnonymousClass(Object[] args, boolean excludeEnclosingInstance) The first parameter of an inner, local or anonymous inner class isnullor the enclosing instance. This should not be included in the substitute invocation since it is never expected by the user. Seems with Javassist 3.17.1-GA invalid input: '&' Java 7, the 'null' is passed as the last argument.
-