static void thenThrow(final OngoingStubbing<Object> whenPoolExecute,
      final FailureMode failureMode) {
    /*
     * We know execute() handles three kinds of exception from the pool:
     *
     * InternalFunctionInvocationTargetException
     *
     * keep trying without regard to retry attempt limit
     *
     * ServerOperationException | NoAvailableServersException
     *
     * re-throw
     *
     * ServerConnectivityException
     *
     * keep trying up to retry attempt limit
     */
    switch (failureMode) {
      case NO_FAILURE:
        whenPoolExecute.thenReturn(null);
        break;
      case THROW_SERVER_CONNECTIVITY_EXCEPTION:
        whenPoolExecute.thenThrow(new ServerConnectivityException(
            ConnectionManagerImpl.SOCKET_TIME_OUT_MSG));
        break;
      case THROW_SERVER_OPERATION_EXCEPTION:
        whenPoolExecute.thenThrow(new ServerOperationException("testing"));
        break;
      case THROW_NO_AVAILABLE_SERVERS_EXCEPTION:
        whenPoolExecute.thenThrow(new NoAvailableServersException("testing"));
        break;
      case THROW_INTERNAL_FUNCTION_INVOCATION_TARGET_EXCEPTION:
        /*
         * The product assumes that InternalFunctionInvocationTargetException will only be
         * encountered
         * when the target cache is going down. That condition is transient so the product
         * assume
         * it's
         * ok to keep trying forever. In order to test this situation (and for the test to not
         * hang)
         * we throw this exception first, then we throw ServerConnectivityException
         */
        whenPoolExecute.thenThrow(new InternalFunctionInvocationTargetException("testing"))
            .thenThrow(new ServerConnectivityException(ConnectionManagerImpl.SOCKET_TIME_OUT_MSG));
        break;
      default:
        throw new AssertionError("unknown FailureMode type: " + failureMode);
    }
  }
Add a {@link OngoingStubbing#thenThrow(Throwable...)} behavior to
{@param whenPoolExecute}

This method has to be {@code static} because it is called before
{@link ExecuteFunctionTestSupport} is constructed.

@param failureMode is the {@link FailureMode} that determines the kind of exception
       to {@code throw}
geode-core/src/test/java/org/apache/geode/cache/client/internal/ExecuteFunctionTestSupport.java