Package org.apache.wicket

Examples of org.apache.wicket.MockPageWithLink


  @Test
  public void setComponentPathAttributeName()
  {
    String attributeName = "data-wicket-path";
    tester.getApplication().getDebugSettings().setComponentPathAttributeName(attributeName);
    MockPageWithLink page = new MockPageWithLink();
    Component link = new Link(MockPageWithLink.LINK_ID)
    {
      @Override
      public void onClick()
      {
      }
    }.setMarkupId(MockPageWithLink.LINK_ID);
    page.add(link);
    tester.startPage(page);

    TagTester tagTester = tester.getTagById(MockPageWithLink.LINK_ID);
    String wicketPath = tagTester.getAttribute(attributeName);
    assertEquals(link.getPageRelativePath(), wicketPath);
View Full Code Here


   */
  @Test
  public void setComponentPathAttributeNameDeprected()
  {
    tester.getApplication().getDebugSettings().setOutputComponentPath(true);
    MockPageWithLink page = new MockPageWithLink();
    Component link = new Link(MockPageWithLink.LINK_ID)
    {
      @Override
      public void onClick()
      {
      }
    }.setMarkupId(MockPageWithLink.LINK_ID);
    page.add(link);
    tester.startPage(page);

    TagTester tagTester = tester.getTagById(MockPageWithLink.LINK_ID);
    String wicketPath = tagTester.getAttribute("wicketpath");
    assertEquals(link.getPageRelativePath(), wicketPath);
View Full Code Here

   *
   */
  @Test
  public void assertComponentOnAjaxResponse()
  {
    final Page page = new MockPageWithLink();
    AjaxLink<Void> ajaxLink = new AjaxLink<Void>(MockPageWithLink.LINK_ID)
    {
      private static final long serialVersionUID = 1L;

      @Override
      public void onClick(AjaxRequestTarget target)
      {
        // Replace the link with a normal Link
        Link<Void> link = new Link<Void>(MockPageWithLink.LINK_ID)
        {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick()
          {
          }
        };
        link.setOutputMarkupId(true);

        page.replace(link);

        target.add(link);
      }
    };
    ajaxLink.setOutputMarkupId(true);

    page.add(ajaxLink);

    tester.startPage(page);

    // Click the link
    tester.clickLink(MockPageWithLink.LINK_ID);
View Full Code Here

   * Clicking on ResourceLink should deliver the resource content
   */
  @Test
  public void clickResourceLinkWithResource()
  {
    MockPageWithLink page = new MockPageWithLink();
    String content = "content";
    ByteArrayResource resource = new ByteArrayResource("text/plain", content.getBytes(),
      "fileName.txt");
    ResourceLink<Void> link = new ResourceLink<Void>(MockPageWithLink.LINK_ID, resource);
    page.add(link);
    tester.startPage(page);
    tester.clickLink(MockPageWithLink.LINK_ID, false);
    assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain");
    assertEquals(content, tester.getLastResponseAsString());
  }
View Full Code Here

   * Clicking on ResourceLink should deliver the resource reference's content
   */
  @Test
  public void clickResourceLinkWithResourceReference()
  {
    MockPageWithLink page = new MockPageWithLink();
    String content = "content";
    final ByteArrayResource resource = new ByteArrayResource("text/plain", content.getBytes(),
        "fileName.txt");
    ResourceReference reference = new ResourceReference(WicketTesterTest.class, "resourceLinkWithResourceReferenceTest")
    {
      @Override
      public IResource getResource()
      {
        return resource;
      }
    };
    ResourceLink<Void> link = new ResourceLink<Void>(MockPageWithLink.LINK_ID, reference);
    page.add(link);
    tester.startPage(page);
    tester.clickLink(MockPageWithLink.LINK_ID, false);
    assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain");
    assertEquals(content, tester.getLastResponseAsString());
  }
View Full Code Here

   * https://issues.apache.org/jira/browse/WICKET-3849
   */
  @Test
  public void enforceMounts()
  {
    MockPageWithLink pageWithLink = new MockPageWithLink();
    pageWithLink.add(new Link<Void>(MockPageWithLink.LINK_ID)
    {
      private static final long serialVersionUID = 1L;

      @Override
      public void onClick()
View Full Code Here

   *
   */
  @Test
  public void assertComponentOnAjaxResponse()
  {
    final Page page = new MockPageWithLink();
    AjaxLink<Void> ajaxLink = new AjaxLink<Void>(MockPageWithLink.LINK_ID)
    {
      private static final long serialVersionUID = 1L;

      @Override
      public void onClick(AjaxRequestTarget target)
      {
        // Replace the link with a normal Link
        Link<Void> link = new Link<Void>(MockPageWithLink.LINK_ID)
        {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick()
          {
          }
        };
        link.setOutputMarkupId(true);

        page.replace(link);

        target.add(link);
      }
    };
    ajaxLink.setOutputMarkupId(true);

    page.add(ajaxLink);

    tester.startPage(page);

    // Click the link
    tester.clickLink(MockPageWithLink.LINK_ID);
View Full Code Here

   * Clicking on ResourceLink should deliver the resource content
   */
  @Test
  public void clickResourceLink()
  {
    MockPageWithLink page = new MockPageWithLink();
    String content = "content";
    ByteArrayResource resource = new ByteArrayResource("text/plain", content.getBytes(), "fileName.txt");
    ResourceLink<Void> link = new ResourceLink<Void>(MockPageWithLink.LINK_ID, resource);
    page.add(link);
    tester.startPage(page);
    tester.clickLink(MockPageWithLink.LINK_ID, false);
    assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain");
    assertEquals(content, tester.getLastResponseAsString());
  }
View Full Code Here

   *
   */
  @Test
  public void assertComponentOnAjaxResponse()
  {
    final Page page = new MockPageWithLink();
    AjaxLink<Void> ajaxLink = new AjaxLink<Void>(MockPageWithLink.LINK_ID)
    {
      private static final long serialVersionUID = 1L;

      @Override
      public void onClick(AjaxRequestTarget target)
      {
        // Replace the link with a normal Link
        Link<Void> link = new Link<Void>(MockPageWithLink.LINK_ID)
        {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick()
          {
          }
        };
        link.setOutputMarkupId(true);

        page.replace(link);

        target.add(link);
      }
    };
    ajaxLink.setOutputMarkupId(true);

    page.add(ajaxLink);

    tester.startPage(page);

    // Click the link
    tester.clickLink(MockPageWithLink.LINK_ID);
View Full Code Here

   * Clicking on ResourceLink should deliver the resource content
   */
  @Test
  public void clickResourceLinkWithResource()
  {
    MockPageWithLink page = new MockPageWithLink();
    String content = "content";
    ByteArrayResource resource = new ByteArrayResource("text/plain", content.getBytes(),
      "fileName.txt");
    ResourceLink<Void> link = new ResourceLink<Void>(MockPageWithLink.LINK_ID, resource);
    page.add(link);
    tester.startPage(page);
    tester.clickLink(MockPageWithLink.LINK_ID, false);
    assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain");
    assertEquals(content, tester.getLastResponseAsString());
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.MockPageWithLink

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.