use of org.apache.wicket.MockPageWithOneComponent in project wicket by apache.
the class WicketTesterTest method executeAjaxEvent.
/**
* Test that the executeAjaxEvent on the WicketTester works.
*/
@Test
public void executeAjaxEvent() {
// Setup mocks
final MockPageWithOneComponent page = new MockPageWithOneComponent();
Label label = new Label("component", "Dblclick This To See Magick");
label.add(new AjaxEventBehavior("dblclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
eventExecuted = true;
}
});
page.add(label);
// Start the page
tester.startPage(page);
// tester.setupRequestAndResponse();
// Execute the event
tester.executeAjaxEvent(label, "dblclick");
assertTrue(eventExecuted);
}
use of org.apache.wicket.MockPageWithOneComponent in project wicket by apache.
the class BehaviorTest method onTagTest.
@Test
public void onTagTest() {
WebMarkupContainer component = new WebMarkupContainer(MockPageWithOneComponent.COMPONENT_ID);
MockPageWithOneComponent page = new MockPageWithOneComponent();
page.add(component);
String value = "value";
String key = "key";
component.add(Behavior.onTag((c, tag) -> tag.put(key, value)));
component.add(Behavior.onAttribute("class", oldValue -> "zzz"));
tester.startPage(page);
TagTester tagTester = tester.getTagByWicketId(MockPageWithOneComponent.COMPONENT_ID);
assertThat(tagTester.getAttribute(key), is(equalTo(value)));
assertThat(tagTester.getAttribute("class"), is(equalTo("zzz")));
}
use of org.apache.wicket.MockPageWithOneComponent in project wicket by apache.
the class BehaviorTest method onAttributeTest.
@Test
public void onAttributeTest() {
WebMarkupContainer component = new WebMarkupContainer(MockPageWithOneComponent.COMPONENT_ID);
MockPageWithOneComponent page = new MockPageWithOneComponent();
page.add(component);
String value = "value";
String key = "key";
component.add(Behavior.onAttribute(key, oldValue -> value));
tester.startPage(page);
TagTester tagTester = tester.getTagByWicketId(MockPageWithOneComponent.COMPONENT_ID);
assertThat(tagTester.getAttribute(key), is(equalTo(value)));
}
Aggregations