Package org.apache.wicket.util.tester.apps_5

Examples of org.apache.wicket.util.tester.apps_5.AjaxSubmitLinkClickTest


  /**
   *
   */
  public void testClickLink_ajaxSubmitLink()
  {
    MockPojo mockPojo = new MockPageWithFormAndLink.MockPojo();
    mockPojo.setName("Mock name");

    final MockPageWithFormAndLink page = new MockPageWithFormAndLink(mockPojo);
    AjaxSubmitLink<?> link = new AjaxSubmitLink<Void>("link", page.getForm())
    {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onSubmit(AjaxRequestTarget target, Form<?> form)
      {
        assertNotNull(form);
        linkClicked = true;
      }
    };
    page.add(link);

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

      public Page<?> getTestPage()
      {
        return page;
      }
    });

    tester.assertRenderedPage(MockPageWithFormAndLink.class);

    // Change the name in the textfield
    page.getNameField().setModelValue(new String[] { "new mock value" });

    // Click the submit link
    tester.clickLink("link");

    // Has it really been clicked?
    assertTrue(linkClicked);

    // And has the form been "submitted"
    assertEquals("new mock value", mockPojo.getName());
  }
View Full Code Here


  /**
   *
   */
  public void testClickLink_ajaxSubmitLink() {
    MockPojo mockPojo = new MockPageWithFormAndLink.MockPojo();
    mockPojo.setName("Mock name");
   
    final MockPageWithFormAndLink page = new MockPageWithFormAndLink(mockPojo);
    AjaxSubmitLink link = new AjaxSubmitLink("link", page.getForm()) {
      private static final long serialVersionUID = 1L;

      protected void onSubmit(AjaxRequestTarget target, Form form)
      {
        linkClicked = true;
      }
    };
    page.add(link);
   
    tester.startPage(new ITestPageSource() {
      private static final long serialVersionUID = 1L;

      public Page getTestPage()
      {
        return page;
      }
    });
   
    tester.assertRenderedPage(MockPageWithFormAndLink.class);
   
    // Change the name in the textfield
    page.getNameField().setModelValue("new mock value");

    // Click the submit link
    tester.clickLink("link");
   
    // Has it really been clicked?
    assertTrue(linkClicked);
   
    // And has the form been "submitted"
    assertEquals("new mock value", mockPojo.getName());
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.tester.apps_5.AjaxSubmitLinkClickTest

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.