use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method withButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired.
@Test
public void withButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired() {
final WicketTester tester = new WicketTester();
final boolean[] onSubmitCalled = new boolean[1];
final Form<Void> underTest = new Form<Void>("underTest") {
@Override
protected void onSubmit() {
onSubmitCalled[0] = true;
}
@Override
protected MethodMismatchResponse onMethodMismatch() {
return MethodMismatchResponse.ABORT;
}
};
tester.startPage(new FormWithButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
tester.getRequest().setMethod("GET");
formTester.submit("button");
assertFalse(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesWithCorrectMethod.
@Test
public void withAjaxButtonFormSubmittedContinuesWithCorrectMethod() {
final WicketTester tester = new WicketTester();
final boolean[] onSubmitCalled = new boolean[1];
final Form<Void> underTest = new Form<Void>("underTest") {
@Override
protected void onSubmit() {
onSubmitCalled[0] = true;
}
};
tester.startPage(new FormWithAjaxButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
formTester.submit("button");
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesByDefaultWithMismatchingMethod.
@Test
public void withAjaxButtonFormSubmittedContinuesByDefaultWithMismatchingMethod() {
final WicketTester tester = new WicketTester();
final boolean[] onSubmitCalled = new boolean[1];
final Form<Void> underTest = new Form<Void>("underTest") {
@Override
protected void onSubmit() {
onSubmitCalled[0] = true;
}
};
tester.startPage(new FormWithAjaxButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
tester.getRequest().setMethod("GET");
formTester.submit("button");
assertTrue(onSubmitCalled[0]);
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class TransparentWebMarkupContainerTest method ajaxUpdate.
/**
* Test case for <a href="https://issues.apache.org/jira/browse/WICKET-3719">WICKET-3719</a>
*/
@Test
public void ajaxUpdate() {
WicketTester wicketTester = new WicketTester() {
@Override
protected IPageManagerProvider newTestPageManagerProvider() {
return new IPageManagerProvider() {
@Override
public IPageManager apply(IPageManagerContext context) {
return new MockPageManager() {
@Override
public void touchPage(IManageablePage page) {
page = WicketObjects.cloneObject(page);
super.touchPage(page);
}
};
}
};
}
};
wicketTester.startPage(TransparentWithAjaxUpdatePage.class);
wicketTester.clickLink("link", true);
wicketTester.destroy();
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class AutoLinkInPanelsTest method setUp.
@Before
public void setUp() {
tester = new WicketTester(new WebApplication() {
@Override
public Class<? extends Page> getHomePage() {
return TestPage.class;
}
@Override
protected void init() {
super.init();
getMarkupSettings().setAutomaticLinking(true);
}
});
}
Aggregations