Пример #1
0
 public void testToScope1() throws Exception {
   PageScopeHandlerImpl handler = new PageScopeHandlerImpl();
   assertFalse(handler.toScope(null, null));
   register(AaaPage.class, "aaaPage");
   PageDesc pageDesc = new PageDescImpl(AaaPage.class, "aaaPage");
   assertFalse(handler.toScope(pageDesc, getFacesContext()));
 }
Пример #2
0
  public void testToScope2() throws Exception {
    PageScopeHandlerImpl handler = new PageScopeHandlerImpl();
    Aaa2Page page = new Aaa2Page();
    page.setAaa("A");
    page.setBbb(new Integer(1));
    register(page, "aaa2Page");
    PageDesc pageDesc = new PageDescImpl(Aaa2Page.class, "aaa2Page");

    handler.toScope(pageDesc, getFacesContext());
    Map map = ScopeValueHelper.getOrCreatePageScopeValues(getFacesContext());
    assertEquals("A", map.get("aaa"));
    assertEquals(null, map.get("bbb"));
  }
Пример #3
0
  public void testToPage2() throws Exception {
    PageScopeHandlerImpl handler = new PageScopeHandlerImpl();
    Aaa2Page page = new Aaa2Page();
    register(page, "aaa2Page");
    PageDesc pageDesc = new PageDescImpl(Aaa2Page.class, "aaa2Page");
    Map map = ScopeValueHelper.getOrCreatePageScopeValues(getFacesContext());
    map.put("aaa", "A");
    map.put("bbb", new Integer(1));

    handler.toPage(pageDesc, getFacesContext());
    assertEquals("A", page.getAaa());
    assertNull(page.getBbb());
    PageScope.removeContext(getFacesContext());
  }