Exemplo n.º 1
0
  /*
   * public static Cookie getSessionCookie(HttpClient client) { // Get the state for the JSESSIONID HttpState state =
   * client.getState(); // Get the JSESSIONID so we can reset the host Cookie[] cookies = state.getCookies(); Cookie sessionID
   * = null; for (int c = 0; c < cookies.length; c++) { Cookie k = cookies[c]; if (k.getName().equalsIgnoreCase("JSESSIONID"))
   * { sessionID = k; } } return sessionID; }
   *
   * public static void setCookieDomainToThisServer(HttpClient client, String server) { // Get the session cookie Cookie
   * sessionID = getSessionCookie(client); if (sessionID == null) { throw new
   * IllegalStateException("No session cookie found on " + client); } // Reset the domain so that the cookie will be sent to
   * server1 sessionID.setDomain(server); client.getState().addCookie(sessionID); }
   */
  public static void validateExpectedAttributes(
      Map<String, Object> expected, BasicRequestHandler handler) {
    assertFalse(handler.isNewSession());

    if (handler.isCheckAttributeNames()) {
      assertEquals(expected.size(), handler.getAttributeNames().size());
    }
    Map<String, Object> checked = handler.getCheckedAttributes();
    assertEquals(expected.size(), checked.size());
    for (Map.Entry<String, Object> entry : checked.entrySet()) {
      assertEquals(entry.getKey(), expected.get(entry.getKey()), entry.getValue());
    }
  }
Exemplo n.º 2
0
 public static void validateNewSession(BasicRequestHandler handler) {
   assertTrue(handler.isNewSession());
   assertEquals(handler.getCreationTime(), handler.getLastAccessedTime());
   if (handler.isCheckAttributeNames()) {
     assertEquals(0, handler.getAttributeNames().size());
   }
   Map<String, Object> checked = handler.getCheckedAttributes();
   for (Map.Entry<String, Object> entry : checked.entrySet()) {
     assertNull(entry.getKey(), entry.getValue());
   }
 }