Exemple #1
0
 public void test_setPageProperty() {
   PageState state1 = PageState.getPageState(cr, "id123", true);
   PageState state2 = PageState.getPageState(cr, "abc", true);
   state1.setPageProperty("first", "123");
   state1.setPageProperty("second", "456");
   state2.setPageProperty("third", "789");
   assertEquals("properties in first PageState", "first, second", getPropertyNames(state1));
   assertEquals("properties in second PageState", "third", getPropertyNames(state2));
 }
Exemple #2
0
 public void test_getPageProperty() {
   PageState state1 = PageState.getPageState(cr, "id123", true);
   PageState state2 = PageState.getPageState(cr, "abc", true);
   state1.setPageProperty("first", "123");
   state1.setPageProperty("second", "456");
   state2.setPageProperty("third", "789");
   assertEquals("value of first property", "123", state1.getPageProperty("first"));
   assertEquals("value of third property", "789", state2.getPageProperty("third"));
   assertEquals("missing property", null, state2.getPageProperty("first"));
 }
Exemple #3
0
  public void test_flushPageState() {
    PageState state1 = PageState.getPageState(cr, "id123", true);
    PageState state2 = PageState.getPageState(cr, "abc", true);
    state1.setPageProperty("first", "123");
    state1.setPageProperty("second", "456");
    state2.setPageProperty("third", "789");

    // Without deleting AllPageState.
    state1.flushPageState(cr);
    PageState.AllPageInfo pageInfo1 =
        (PageState.AllPageInfo) cr.getServletRequest().getSession().getAttribute("fiz.PageState");
    assertEquals("AllPageInfo has state1", state1, pageInfo1.get("id123"));
    assertEquals("AllPageInfo has state2", state2, pageInfo1.get("abc"));

    // With AllPageState deleted.
    cr.getServletRequest().getSession().removeAttribute("fiz.PageState");
    cr.pageId = "id123";
    state1.flushPageState(cr);
    PageState.AllPageInfo pageInfo2 =
        (PageState.AllPageInfo) cr.getServletRequest().getSession().getAttribute("fiz.PageState");
    assertEquals("AllPageInfo has state1", state1, pageInfo2.get("id123"));
    assertEquals("AllPageInfo has only one PageState", 1, pageInfo2.size());
  }