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 Details

  • 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

      private static boolean shouldMockMethod(String methodName, Class<?>[] sig)
    • isJavaStandardMethod

      private static boolean isJavaStandardMethod(String methodName, Class<?>[] sig)
    • isGetClassMethod

      private static boolean isGetClassMethod(String methodName, Class<?>[] sig)
    • 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

      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)
    • staticConstructorCall

      public static Object staticConstructorCall(String className)
    • constructorCall

      public static Object constructorCall(Class<?> type, Object[] args, Class<?>[] sig) throws Throwable
      Throws:
      Throwable
    • copyArgumentsForInnerOrLocalOrAnonymousClass

      private static Object[] copyArgumentsForInnerOrLocalOrAnonymousClass(Object[] args, boolean excludeEnclosingInstance)
      The first parameter of an inner, local or anonymous inner class is null or 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.