use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class SelectTest method option_groups_precede_ungroup_options.
@Test
public void option_groups_precede_ungroup_options() throws Exception {
ValidationTracker tracker = mockValidationTracker();
OptionGroupModel husbands = new OptionGroupModelImpl("Husbands", false, TapestryInternalUtils.toOptionModels("Fred,Barney"));
Select select = new Select();
train_getInput(tracker, select, null);
replay();
select.setModel(new SelectModelImpl(Collections.singletonList(husbands), TapestryInternalUtils.toOptionModels("Wilma,Betty")));
select.setValueEncoder(new StringValueEncoder());
select.setValue("Fred");
select.setValidationTracker(tracker);
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("select");
select.options(writer);
writer.end();
assertEquals(writer.toString(), read("option_groups_precede_ungroup_options.txt"));
verify();
}
use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class SelectTest method option_group_attributes.
@Test
public void option_group_attributes() throws Exception {
ValidationTracker tracker = mockValidationTracker();
Map<String, String> attributes = Collections.singletonMap("class", "pixie");
OptionGroupModel husbands = new OptionGroupModelImpl("Husbands", false, TapestryInternalUtils.toOptionModels("Fred,Barney"), attributes);
Select select = new Select();
train_getInput(tracker, select, null);
replay();
select.setModel(new SelectModelImpl(Collections.singletonList(husbands), null));
select.setValueEncoder(new StringValueEncoder());
select.setValue("Fred");
select.setValidationTracker(tracker);
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("select");
select.options(writer);
writer.end();
assertEquals(writer.toString(), read("option_group_attributes.txt"));
verify();
}
use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class TextOutputTest method normal_output.
@Test
public void normal_output() {
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
TextOutput component = new TextOutput();
component.injectValue("Fred\nBarney\rWilma\r\nBetty\nBam-Bam\n");
writer.element("div");
component.beginRender(writer);
writer.end();
assertEquals(writer.toString(), "<?xml version=\"1.0\"?>\n" + "<div><p>Fred</p><p>Barney</p><p>Wilma</p><p>Betty</p><p>Bam-Bam</p></div>");
}
use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class DOMTest method remove_while_rendering.
@Test
public void remove_while_rendering() {
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("ul");
for (int i = 0; i < 4; i++) {
Element e = writer.element("li");
if (i != 2) {
writer.write(String.valueOf(i));
}
writer.end();
if (e.getChildren().isEmpty()) {
e.remove();
}
}
writer.end();
assertEquals(writer.toString(), "<?xml version=\"1.0\"?>\n" + "<ul><li>0</li><li>1</li><li>3</li></ul>");
}
Aggregations