protected MockHttpServletResponse login(final String username, final String password,
                                            final String fromAddress) throws Exception {
        val context = MockRequestContext.create();
        val request = context.getHttpServletRequest();
        val response = context.getHttpServletResponse();

        context.setMethod(HttpMethod.POST);
        context.setParameter(CasProtocolConstants.PARAMETER_USERNAME, username);
        context.setParameter(CasProtocolConstants.PARAMETER_PASSWORD, password);
        request.setRemoteAddr(fromAddress);
        request.addHeader(HttpHeaders.USER_AGENT, "Firefox");
        request.setAttribute("flowRequestContext", context);
        request.setRequestURI("/cas/login");
        context.setCurrentEvent(new Event(StringUtils.EMPTY, "error"));
        ClientInfoHolder.setClientInfo(ClientInfo.from(request));
        getThrottle().preHandle(request, response, getThrottle());

        try {
            val transaction = CoreAuthenticationTestUtils.getAuthenticationTransactionFactory()
                .newTransaction(CoreAuthenticationTestUtils.getService(), credentials(username, password));
            response.setStatus(HttpServletResponse.SC_OK);
            authenticationManager.authenticate(transaction);
        } catch (final Throwable e) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
            getThrottle().postHandle(request, response, getThrottle(), null);
        } finally {
            getThrottle().afterCompletion(request, response, getThrottle(), null);
        }
        return response;
    }
Base class for submission throttle tests.

@author Marvin S. Addison
@since 3.0.0
support/cas-server-support-throttle/src/test/java/org/apereo/cas/web/support/BaseThrottledSubmissionHandlerInterceptorAdapterTests.java