Exemplo n.º 1
0
 /**
  * Tests if the {@link PageInstanceMapper} is used if {@link
  * org.apache.wicket.settings.def.PageSettings#getRecreateMountedPagesAfterExpiry()} is disabled
  */
 @Test
 public void testLinkOnPageWithRecreationDisabled() {
   tester.getApplication().getPageSettings().setRecreateMountedPagesAfterExpiry(false);
   PageWithLink page =
       tester.startPage(PageWithLink.class, new PageParameters().add("param", "value"));
   Link<?> link = (Link<?>) page.get("link");
   String url = link.getURL().toString();
   assertEquals("./wicket/page?0-1.ILinkListener-link", url);
   tester.executeUrl(url);
 }
Exemplo n.º 2
0
 /** ... and this should throw a {@link PageExpiredException} if the page is expired */
 @Test(expected = PageExpiredException.class)
 public void testExpiredPageWithRecreationDisabled() {
   tester.getApplication().getPageSettings().setRecreateMountedPagesAfterExpiry(false);
   PageWithLink page =
       tester.startPage(PageWithLink.class, new PageParameters().add("param", "value"));
   Link<?> link = (Link<?>) page.get("link");
   String url = link.getURL().toString();
   assertEquals("./wicket/page?0-1.ILinkListener-link", url);
   // simulate a page expiry
   url = url.replace("page?0", "page?3");
   tester.executeUrl(url);
 }
Exemplo n.º 3
0
  /**
   * Tests if it is possible to re-instantiate the page if it is expired. The page should be
   * instantiated with the same page parameters. The link will not be clicked however.
   */
  @Test
  public void testLinkOnExpiredPage() {
    PageWithLink page =
        tester.startPage(PageWithLink.class, new PageParameters().add("param", "value"));
    assertEquals("value", page.getPageParameters().get("param").toString());
    tester.assertContains("param=value");
    Link<?> link = (Link<?>) page.get("link");
    String url = link.getURL().toString();
    // simulate a page expiry
    url = url.replace("?0", "?3");
    tester.executeUrl(url);

    // request parameters to callback urls should be ignored for the re-created page
    // (WICKET-4594)
    tester.assertContainsNot("param=value");
  }
Exemplo n.º 4
0
 /**
  * Tests if the page parameters are part of the url of the link, and if the link actually works.
  */
 @Test
 public void testPageParametersInLink() {
   PageWithLink page =
       tester.startPage(PageWithLink.class, new PageParameters().add("param", "value"));
   Link<?> link = (Link<?>) page.get("link");
   String url = link.getURL().toString();
   if (mount)
     assertTrue(
         "URL for link should contain 'mount/value/part2': " + url,
         url.toString().contains("mount/value/part2"));
   else
     assertTrue(
         "URL for link should contain 'param=value': " + url,
         url.toString().contains("param=value"));
   tester.executeUrl(url);
 }