use of org.apache.wicket.MockPageWithLinkAndComponent in project wicket by apache.
the class AjaxTimerBehaviorTest method addedInAjaxSetsTimout.
/**
* Tests timer behavior in a component added to an AjaxRequestTarget
*/
@Test
public void addedInAjaxSetsTimout() {
Duration dur = Duration.seconds(20);
final AjaxSelfUpdatingTimerBehavior timer = new AjaxSelfUpdatingTimerBehavior(dur);
final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
page.add(new WebComponent(MockPageWithLinkAndComponent.COMPONENT_ID).setOutputMarkupId(true));
page.add(new AjaxLink<Void>(MockPageWithLinkAndComponent.LINK_ID) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
WebMarkupContainer wmc = new WebMarkupContainer(MockPageWithLinkAndComponent.COMPONENT_ID);
wmc.setOutputMarkupId(true);
wmc.add(timer);
page.replace(wmc);
target.add(wmc);
}
});
tester.startPage(page);
tester.clickLink(MockPageWithLinkAndComponent.LINK_ID);
// first render sets timeout
assertMatches("Wicket.Timer.set", 1);
tester.executeBehavior(timer);
assertMatches("Wicket.Timer.set", 1);
}
use of org.apache.wicket.MockPageWithLinkAndComponent in project wicket by apache.
the class AjaxTimerBehaviorTest method ajaxUpdateDoesNotSetTimeout.
/**
* tests timer behavior in a WebPage.
*/
@Test
public void ajaxUpdateDoesNotSetTimeout() {
Duration dur = Duration.seconds(20);
final AjaxSelfUpdatingTimerBehavior timer = new AjaxSelfUpdatingTimerBehavior(dur);
final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
final Label label = new Label(MockPageWithLinkAndComponent.COMPONENT_ID, "Hello");
page.add(label);
page.add(new AjaxLink<Void>(MockPageWithLinkAndComponent.LINK_ID) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
target.add(label);
}
});
label.setOutputMarkupId(true);
label.add(timer);
tester.startPage(page);
assertMatches("Wicket.Timer.set", 1);
tester.clickLink(MockPageWithLinkAndComponent.LINK_ID);
assertMatches("Wicket.Timer.set", 1);
tester.executeBehavior(timer);
assertMatches("Wicket.Timer.set", 1);
}
Aggregations