public void discoverCookies(WebClient client, String url) {

    HashSet<Cookie> foundCookies = new HashSet<Cookie>();
    Set<Cookie> cookies = client.getCookieManager().getCookies();

    if (cookies != null && cookies.size() > 0) {
      foundCookies.addAll(cookies);
    }

    System.out.println("--------------------------------");
    System.out.println("Cookies Found");
    for (Cookie cookie : foundCookies) {
      System.out.println(cookie.toString());
    }
  }
  @Test(groups = {"notLoggedIn"})
  public void testInterceptComponentMethodWithAjaxDeny() throws Exception {
    CookieManager cookieManager = webClient.getCookieManager();
    cookieManager.clearCookies();
    clickOnBasePage("componentMethodInterceptorWithAjax");
    // this executes window.location.replace so we have to wait for it. is there an event we could
    // listen instead?
    webClient.waitForBackgroundJavaScript(500);
    page = (HtmlPage) webClient.getCurrentWindow().getEnclosedPage();
    assertLoginPage();

    for (Cookie cookie : cookieManager.getCookies())
      if (cookie.getName().equals("shiroSavedRequest")) {
        // test we've stored a page render request, not the component event request. Could also just
        // test for existence of a dot
        assertEquals(cookie.getPath() + "/", APP_CONTEXT);
        return;
      }
    fail();
  }