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 String
DONT_MOCK_NEXT_CALL
Used to tell the MockGateway that the next call should not be mocked regardless if aMethodInvocationControl
is found in theMockRepository
.static boolean
MOCK_GET_CLASS_METHOD
Tells PowerMock whether or not to mockObject.getClass()
.static boolean
MOCK_STANDARD_METHODS
Tells PowerMock to mock standard methods.static Object
PROCEED
static Object
SUPPRESS
-
Constructor Summary
Constructors Constructor Description MockGateway()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Object
constructorCall(Class<?> type, Object[] args, Class<?>[] sig)
static Object
fieldCall(Object instanceOrClassContainingTheField, Class<?> classDefiningField, String fieldName, Class<?> fieldType)
static Object
methodCall(Class<?> type, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString)
static Object
methodCall(Object instance, String methodName, Object[] args, Class<?>[] sig, String returnTypeAsString)
static Object
newInstanceCall(Class<?> type, Object[] args, Class<?>[] sig)
static Object
staticConstructorCall(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 aMethodInvocationControl
is 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)
-
-