public void testCookieRateControl() {
RateFlowController controller = new RateFlowController(new OWSRequestMatcher(), 2,
Long.MAX_VALUE, 1000, new CookieKeyGenerator());
// run the first request
Request firstRequest = buildCookieRequest(null);
assertTrue(controller.requestIncoming(firstRequest, Integer.MAX_VALUE));
checkHeaders(firstRequest, "Any OGC request", 2, 1);
// grab the cookie
Cookie cookie = (Cookie) ((MockHttpServletResponse) firstRequest.getHttpResponse())
.getCookies().get(0);
String cookieValue = cookie.getValue();
// second request
Request request = buildCookieRequest(cookieValue);
assertTrue(controller.requestIncoming(request, Integer.MAX_VALUE));
checkHeaders(request, "Any OGC request", 2, 0);
// third one, this one will have to wait
long start = System.currentTimeMillis();