use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.
the class OutputTest method simple_output_with_filter_disabled.
@Test
public void simple_output_with_filter_disabled() {
MarkupWriter writer = createMarkupWriter();
ComponentResources resources = mockComponentResources();
replay();
Output component = new Output();
component.setup(value, filterFormat, false, null, resources);
writer.element("root");
assertFalse(component.beginRender(writer));
writer.end();
verify();
// It's not valid XML output, but that's why it's called programmer error :-)
assertEquals(writer.toString(), "<root><22.70></root>");
}
use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.
the class OutputTest method simple_output_with_filter.
@Test
public void simple_output_with_filter() {
MarkupWriter writer = createMarkupWriter();
ComponentResources resources = mockComponentResources();
replay();
Output component = new Output();
component.setup(value, filterFormat, true, null, resources);
writer.element("root");
assertFalse(component.beginRender(writer));
writer.end();
verify();
assertEquals(writer.toString(), "<root><22.70></root>");
}
use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.
the class OutputTest method null_format_is_a_noop.
@Test
public void null_format_is_a_noop() {
String elementName = "span";
MarkupWriter writer = createMarkupWriter();
ComponentResources resources = mockComponentResources();
Format format = new Format() {
private static final long serialVersionUID = -4360045992642727894L;
@Override
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
return toAppendTo;
}
@Override
public Object parseObject(String source, ParsePosition pos) {
return null;
}
};
replay();
Output component = new Output();
component.setup(value, format, true, elementName, resources);
writer.element("root");
assertFalse(component.beginRender(writer));
writer.end();
verify();
assertEquals(writer.toString(), "<root></root>");
}
use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.
the class SelectTest method option_groups.
@Test
public void option_groups() throws Exception {
ValidationTracker tracker = mockValidationTracker();
OptionGroupModel husbands = new OptionGroupModelImpl("Husbands", false, TapestryInternalUtils.toOptionModels("Fred,Barney"));
OptionGroupModel wives = new OptionGroupModelImpl("Wives", true, TapestryInternalUtils.toOptionModels("Wilma,Betty"));
List<OptionGroupModel> groupModels = CollectionFactory.newList(husbands, wives);
Select select = new Select();
train_getInput(tracker, select, null);
replay();
select.setModel(new SelectModelImpl(groupModels, 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_groups.txt"));
verify();
}
use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.
the class SelectTest method just_options.
@Test
public void just_options() throws Exception {
ValidationTracker tracker = mockValidationTracker();
List<OptionModel> options = TapestryInternalUtils.toOptionModels("fred=Fred Flintstone,barney=Barney Rubble");
Select select = new Select();
train_getInput(tracker, select, null);
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();
assertEquals(writer.toString(), read("just_options.txt"));
verify();
}
Aggregations