use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WDefinitionListRenderer_Test method testRenderedFormat.
@Test
public void testRenderedFormat() throws IOException, SAXException, XpathException {
final String term1 = "WDefinitionListRenderer_Test.testRenderedFormat.term1";
final String term2 = "WDefinitionListRenderer_Test.testRenderedFormat.term2";
final String term3 = "WDefinitionListRenderer_Test.testRenderedFormat.term3";
final String text1 = "WDefinitionListRenderer_Test.testRenderedFormat.text1";
final String text2 = "WDefinitionListRenderer_Test.testRenderedFormat.text2";
final String text3 = "WDefinitionListRenderer_Test.testRenderedFormat.text3";
final String text4 = "WDefinitionListRenderer_Test.testRenderedFormat.text3";
WDefinitionList list = new WDefinitionList();
assertSchemaMatch(list);
assertXpathNotExists("//ui:definitionlist/ui:term", list);
assertXpathNotExists("//ui:definitionlist/@type", list);
list.setType(WDefinitionList.Type.STACKED);
list.addTerm(term1, new WText(text1));
assertSchemaMatch(list);
assertXpathEvaluatesTo("stacked", "//ui:definitionlist/@type", list);
assertXpathEvaluatesTo("1", "count(//ui:definitionlist/ui:term)", list);
assertXpathEvaluatesTo(term1, "//ui:definitionlist/ui:term/@text", list);
assertXpathEvaluatesTo("1", "count(//ui:definitionlist/ui:term/ui:data)", list);
assertXpathEvaluatesTo(text1, "normalize-space(//ui:definitionlist/ui:term/ui:data)", list);
list.addTerm(term1, new WText(text2));
list.setType(WDefinitionList.Type.COLUMN);
assertSchemaMatch(list);
assertXpathEvaluatesTo("column", "//ui:definitionlist/@type", list);
assertXpathEvaluatesTo("1", "count(//ui:definitionlist/ui:term)", list);
assertXpathEvaluatesTo(term1, "//ui:definitionlist/ui:term/@text", list);
assertXpathEvaluatesTo("2", "count(//ui:definitionlist/ui:term/ui:data)", list);
assertXpathEvaluatesTo(text1, "normalize-space(//ui:definitionlist/ui:term/ui:data[1])", list);
assertXpathEvaluatesTo(text2, "normalize-space(//ui:definitionlist/ui:term/ui:data[2])", list);
list.addTerm(term2, new WText(text3));
list.setType(WDefinitionList.Type.FLAT);
assertSchemaMatch(list);
assertXpathEvaluatesTo("flat", "//ui:definitionlist/@type", list);
assertXpathEvaluatesTo("2", "count(//ui:definitionlist/ui:term)", list);
assertXpathEvaluatesTo(term1, "//ui:definitionlist/ui:term[1]/@text", list);
assertXpathEvaluatesTo("2", "count(//ui:definitionlist/ui:term[1]/ui:data)", list);
assertXpathEvaluatesTo(text1, "normalize-space(//ui:definitionlist/ui:term[1]/ui:data[1])", list);
assertXpathEvaluatesTo(text2, "normalize-space(//ui:definitionlist/ui:term[1]/ui:data[2])", list);
assertXpathEvaluatesTo(term2, "//ui:definitionlist/ui:term[2]/@text", list);
assertXpathEvaluatesTo("1", "count(//ui:definitionlist/ui:term[2]/ui:data)", list);
assertXpathEvaluatesTo(text3, "normalize-space(//ui:definitionlist/ui:term[2]/ui:data[1])", list);
list.addTerm(term3, new WText(text4));
assertSchemaMatch(list);
assertXpathEvaluatesTo("3", "count(//ui:definitionlist/ui:term)", list);
assertXpathEvaluatesTo(term1, "//ui:definitionlist/ui:term[1]/@text", list);
assertXpathEvaluatesTo("2", "count(//ui:definitionlist/ui:term[1]/ui:data)", list);
assertXpathEvaluatesTo(text1, "normalize-space(//ui:definitionlist/ui:term[1]/ui:data[1])", list);
assertXpathEvaluatesTo(text2, "normalize-space(//ui:definitionlist/ui:term[1]/ui:data[2])", list);
assertXpathEvaluatesTo(term2, "//ui:definitionlist/ui:term[2]/@text", list);
assertXpathEvaluatesTo("1", "count(//ui:definitionlist/ui:term[2]/ui:data)", list);
assertXpathEvaluatesTo(text3, "normalize-space(//ui:definitionlist/ui:term[2]/ui:data[1])", list);
assertXpathEvaluatesTo("1", "count(//ui:definitionlist/ui:term[3]/ui:data)", list);
assertXpathEvaluatesTo(text4, "normalize-space(//ui:definitionlist/ui:term[3]/ui:data[1])", list);
}
use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WDefinitionListRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WDefinitionList list = new WDefinitionList();
list.addTerm(getMaliciousAttribute("ui:term"), new WText("dummy"));
assertSafeContent(list);
}
use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WFieldRenderer_Test method testNoInputField.
@Test
public void testNoInputField() throws IOException, SAXException, XpathException {
// No Input field, so label created by WTextWithColon.
WText text = new WText("text1");
WFieldLayout test = new WFieldLayout();
WField field = test.addField("label1", text);
// Validate Schema
assertSchemaMatch(test);
// Check Attributes
assertXpathEvaluatesTo(field.getId(), "//ui:field/@id", field);
// Check Label
assertXpathEvaluatesTo("label1", "//ui:field/ui:label", field);
// Check Input
assertXpathEvaluatesTo("text1", "//ui:field/ui:input", field);
}
use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WFigureRenderer_Test method testRenderedLazyMode.
@Test
public void testRenderedLazyMode() throws IOException, SAXException, XpathException {
WFigure figure = new WFigure(new WText(FIGURE_CONTENT), FIGURE_HEADING);
figure.setMode(FigureMode.LAZY);
// Content NOT Hidden
assertSchemaMatch(figure);
// If not hidden, then the figure's content should be rendered
assertXpathEvaluatesTo("", "//ui:figure/@type", figure);
assertXpathEvaluatesTo("", "//ui:figure/@hidden", figure);
assertXpathEvaluatesTo("lazy", "//ui:figure/@mode", figure);
assertXpathEvaluatesTo(FIGURE_CONTENT, "//ui:figure/ui:content", figure);
// Content Hidden
// Create User Context with UI component
UIContext uic = createUIContext();
uic.setUI(new DefaultWComponent());
setActiveContext(uic);
setFlag(figure, ComponentModel.HIDE_FLAG, true);
assertSchemaMatch(figure);
// If hidden, then the figure's content should NOT be rendered
assertXpathEvaluatesTo("", "//ui:figure/@type", figure);
assertXpathEvaluatesTo("true", "//ui:figure/@hidden", figure);
assertXpathEvaluatesTo("lazy", "//ui:figure/@mode", figure);
assertXpathEvaluatesTo("", "//ui:figure/ui:content", figure);
}
use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WHeadingRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WHeading heading = new WHeading(WHeading.TITLE, new WDecoratedLabel(new WText("dummy")));
assertSafeContent(heading);
heading.setAccessibleText(getMaliciousAttribute("ui:heading"));
assertSafeContent(heading);
}
Aggregations