Package org.powermock.core
Class MockGateway
- java.lang.Object
-
- org.powermock.core.MockGateway
-
public class MockGateway extends Object
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
Fields Modifier and Type Field Description static StringDONT_MOCK_NEXT_CALLUsed to tell the MockGateway that the next call should not be mocked regardless if aMethodInvocationControlis found in theMockRepository.static booleanMOCK_GET_CLASS_METHODTells PowerMock whether or not to mockObject.getClass().static booleanMOCK_STANDARD_METHODSTells PowerMock to mock standard methods.static ObjectPROCEEDstatic ObjectSUPPRESS
-
Constructor Summary
Constructors Constructor Description MockGateway()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectconstructorCall(Class<?> type, Object[] args, Class<?>[] sig)static ObjectfieldCall(Object instanceOrClassContainingTheField, Class<?> classDefiningField, String fieldName, Class<?> fieldType)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)static ObjectstaticConstructorCall(String className)
-
-
-
Field Detail
-
PROCEED
public static final Object PROCEED
-
SUPPRESS
public static final Object SUPPRESS
-
DONT_MOCK_NEXT_CALL
public static final String 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:
- Constant Field Values
-
MOCK_STANDARD_METHODS
public static boolean MOCK_STANDARD_METHODS
Tells 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_METHOD
Tells PowerMock whether or not to mockObject.getClass().
-
-
Method Detail
-
methodCall
public static Object methodCall(Class<?> type, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString) throws Throwable
- Throws:
Throwable
-
methodCall
public static Object methodCall(Object instance, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString) throws Throwable
- Throws:
Throwable
-
newInstanceCall
public static Object newInstanceCall(Class<?> type, Object[] args, Class<?>[] sig) throws Throwable
- Throws:
Throwable
-
fieldCall
public static Object fieldCall(Object instanceOrClassContainingTheField, Class<?> classDefiningField, String fieldName, Class<?> fieldType)
-
-