Package org.apache.wicket

Examples of org.apache.wicket.MockPageWithLink


   *
   */
  @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

   *
   */
  @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

  /**
   *
   */
  public void testAssertComponentOnAjaxResponse()
  {
    final Page page = new MockPageWithLink();
    AjaxLink ajaxLink = new AjaxLink(MockPageWithLink.LINK_ID)
    {
      private static final long serialVersionUID = 1L;

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

          public void onClick()
          {
            // Do nothing
          }
        };
        link.setOutputMarkupId(true);

        page.replace(link);

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

    page.add(ajaxLink);

    tester.startPage(new ITestPageSource()
    {
      private static final long serialVersionUID = 1L;

View Full Code Here

  /**
   *
   */
  public void testAssertComponentOnAjaxResponse()
  {
    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.addComponent(link);
      }
    };
    ajaxLink.setOutputMarkupId(true);

    page.add(ajaxLink);

    tester.startPage(new ITestPageSource()
    {
      private static final long serialVersionUID = 1L;

View Full Code Here

  /**
   *
   */
  public void testAssertComponentOnAjaxResponse()
  {
    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.addComponent(link);
      }
    };
    ajaxLink.setOutputMarkupId(true);

    page.add(ajaxLink);

    tester.startPage(new ITestPageSource()
    {
      private static final long serialVersionUID = 1L;

View Full Code Here

  @Test
  public void testSetBodyModel()
  {
    final String linkBody = "Link body";

    MockPageWithLink mockPageWithLink = new MockPageWithLink();
    AbstractLink link = new AbstractLink("link")
    {
      private static final long serialVersionUID = 1L;
    };
    link.setMarkupId("link");
    link.setBody(Model.of(linkBody));
    mockPageWithLink.add(link);

    wicketTester.startPage(mockPageWithLink);
    TagTester tagTester = wicketTester.getTagById("link");
    Assert.assertEquals(linkBody, tagTester.getValue());
  }
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.