use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class MarkupWriterImplTest method write_whitespace_before_start_of_root_element_is_retained.
@Test
public void write_whitespace_before_start_of_root_element_is_retained() {
MarkupWriter w = new MarkupWriterImpl(new XMLMarkupModel());
w.write(" ");
w.element("root");
w.end();
assertEquals(w.toString(), "<?xml version=\"1.0\"?>\n" + " <root/>");
}
use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class MarkupWriterImplTest method namespaced_elements_and_attributes.
@Test
public void namespaced_elements_and_attributes() {
MarkupWriter w = new MarkupWriterImpl(new XMLMarkupModel());
Element root = w.elementNS("fredns", "root");
assertSame(root.defineNamespace("fredns", "fred"), root);
root.defineNamespace("barneyns", "barney");
assertSame(w.attributeNS("fredns", "foo", "bar"), root);
Element child = w.elementNS("barneyns", "child");
assertSame(child.getContainer(), root);
// child
w.end();
// root
w.end();
assertEquals(w.toString(), "<?xml version=\"1.0\"?>\n<fred:root fred:foo=\"bar\" xmlns:barney=\"barneyns\" xmlns:fred=\"fredns\"><barney:child/></fred:root>");
}
use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class MarkupWriterImplTest method preamble_content.
@Test
public void preamble_content() throws Exception {
MarkupWriter w = new MarkupWriterImpl(new XMLMarkupModel());
w.comment(" preamble start ");
w.write("preamble text");
w.cdata("CDATA content");
w.writeRaw(" ");
w.element("root");
w.end();
// You really shouldn't have any text after the close tag of the document, so it
// gets moved to the top, to the "preamble", before the first element.
w.comment(" content after root element in preamble ");
assertEquals(w.getDocument().toString(), readFile("preamble_content.txt"));
}
use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class MarkupWriterImplTest method cdata_content.
@Test
public void cdata_content() {
MarkupWriter w = new MarkupWriterImpl(new XMLMarkupModel());
w.element("root");
w.write("Normal Text ");
w.cdata("< & >");
w.write("More Normal Text");
assertEquals(w.toString(), "<?xml version=\"1.0\"?>\n<root>Normal Text <![CDATA[< & >]]>More Normal Text</root>");
}
use of org.apache.tapestry5.dom.XMLMarkupModel in project tapestry-5 by apache.
the class SelectTest method current_selection_from_validation_tracker.
@Test
public void current_selection_from_validation_tracker() throws Exception {
ValidationTracker tracker = mockValidationTracker();
List<OptionModel> options = TapestryInternalUtils.toOptionModels("fred=Fred Flintstone,barney=Barney Rubble");
Select select = new Select();
train_getInput(tracker, select, "fred");
replay();
select.setModel(new SelectModelImpl(null, options));
select.setValueEncoder(new StringValueEncoder());
select.setValue("barney");
select.setValidationTracker(tracker);
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("select");
select.options(writer);
writer.end();
// fred will be selected, not barney, because the validation tracker
// takes precendence.
assertEquals(writer.toString(), read("current_selection_from_validation_tracker.txt"));
verify();
}
Aggregations