use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method iteratorShouldAllowRemovingComponentAfterIterationStarted3.
@Test
public void iteratorShouldAllowRemovingComponentAfterIterationStarted3() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Label label1;
Label label2;
Label label3;
wmc.add(label1 = new Label("label1", "Label1"));
wmc.add(label2 = new Label("label2", "Label2"));
wmc.add(label3 = new Label("label3", "Label3"));
Iterator<Component> iterator = wmc.iterator();
Assert.assertThat(iterator.next(), is(equalToObject(label1)));
Assert.assertThat(iterator.next(), is(equalToObject(label2)));
Assert.assertThat(iterator.next(), is(equalToObject(label3)));
wmc.remove(label1);
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method addingNewChildAfterIterationHasStartedShouldIterateNewChild.
@Test
public void addingNewChildAfterIterationHasStartedShouldIterateNewChild() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
// add one child
addNChildren(wmc, 1);
Iterator<Component> iterator = wmc.iterator();
// iterate
takeNChildren(iterator, 1);
// there are no more children to iterate
Assert.assertThat(iterator.hasNext(), is(false));
// add the new child
Label newChild = new Label("label1", "Label1");
wmc.add(newChild);
assertThat(wmc.size(), is(2));
// ensure that the newChild is up next (as it was added)
Assert.assertThat(iterator.next(), is(equalToObject(newChild)));
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method multipleChildIteratorRetainsOrderOfAddition.
@Test
public void multipleChildIteratorRetainsOrderOfAddition() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Label label1;
Label label2;
Label label3;
wmc.add(label1 = new Label("label1", "Label1"));
wmc.add(label2 = new Label("label2", "Label2"));
wmc.add(label3 = new Label("label3", "Label3"));
Iterator<Component> iterator = wmc.iterator();
Assert.assertThat(iterator.next(), is(equalToObject(label1)));
Assert.assertThat(iterator.next(), is(equalToObject(label2)));
Assert.assertThat(iterator.next(), is(equalToObject(label3)));
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class WicketTester method assertLabel.
/**
* Asserts the text of a <code>Label</code> <code>Component</code>.
*
* @param path
* path to <code>Label</code> <code>Component</code>
* @param expectedLabelText
* expected text of the <code>Label</code>
*/
public void assertLabel(String path, String expectedLabelText) {
Label label = (Label) getComponentFromLastRenderedPage(path);
assertEquals(expectedLabelText, label.getDefaultModelObjectAsString());
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class NodeBorderTest method properlyClosed.
/**
* WICKET-5447
*/
@Test
public void properlyClosed() throws Exception {
WicketTester tester = new WicketTester();
Label label = new Label("label");
label.add(new NodeBorder(new boolean[] { true, false, true }));
tester.startComponentInPage(label);
tester.assertResultPage("<div class=\"tree-branch tree-branch-mid\"><div class=\"tree-subtree\"><div class=\"tree-branch tree-branch-last\"><div class=\"tree-subtree\"><div class=\"tree-branch tree-branch-mid\"><span wicket:id=\"label\" class=\"tree-node\"></span></div></div></div></div></div>");
}
Aggregations