@Test
 public void testCheckCaptcha_singleCall_emptyAnswer() throws Exception {
   expect(requestMock.get(eq("captcha_answer"))).andReturn("").atLeastOnce();
   expect(requestMock.get(eq("captcha_type"))).andReturn("image").anyTimes();
   expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).anyTimes();
   replayDefault();
   assertFalse(captchaService.checkCaptcha());
   verifyDefault();
 }
 @Test
 public void testCheckCaptcha_singleCall_false() throws Exception {
   String wrongAnwser = "chetuck";
   expect(requestMock.get(eq("captcha_answer"))).andReturn(wrongAnwser).atLeastOnce();
   expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce();
   expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce();
   expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(wrongAnwser)))
       .andReturn(false)
       .once();
   replayDefault();
   assertFalse(captchaService.checkCaptcha());
   verifyDefault();
 }
 @Test
 public void testCheckCaptcha_doubleCall_true() throws Exception {
   String expectedAnwser = "chetuck";
   expect(requestMock.get(eq("captcha_answer"))).andReturn(expectedAnwser).atLeastOnce();
   expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce();
   expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce();
   expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser)))
       .andReturn(true)
       .once();
   expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser)))
       .andReturn(false)
       .anyTimes();
   replayDefault();
   assertTrue(captchaService.checkCaptcha());
   // check answer caching
   assertTrue(captchaService.checkCaptcha());
   verifyDefault();
 }
 @Override
 public void onEvent(Event event, Object source, Object data) {
   // Do not use the the LESS cache if we're doing an HTML export because we need that URLs located
   // in less file be
   // recomputed (see ExportURLFactory).
   XWikiContext xcontext = (XWikiContext) data;
   XWikiRequest request = xcontext.getRequest();
   String format = request.get("format");
   if ("html".equals(format)) {
     lessContext.setHtmlExport(true);
   }
 }