Search in sources :

Example 86 with WText

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);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WDefinitionList(com.github.bordertech.wcomponents.WDefinitionList) Test(org.junit.Test)

Example 87 with WText

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);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WDefinitionList(com.github.bordertech.wcomponents.WDefinitionList) Test(org.junit.Test)

Example 88 with WText

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);
}
Also used : WField(com.github.bordertech.wcomponents.WField) WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Test(org.junit.Test)

Example 89 with WText

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);
}
Also used : WFigure(com.github.bordertech.wcomponents.WFigure) WText(com.github.bordertech.wcomponents.WText) UIContext(com.github.bordertech.wcomponents.UIContext) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) Test(org.junit.Test)

Example 90 with WText

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);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WHeading(com.github.bordertech.wcomponents.WHeading) WDecoratedLabel(com.github.bordertech.wcomponents.WDecoratedLabel) Test(org.junit.Test)

Aggregations

WText (com.github.bordertech.wcomponents.WText)97 Test (org.junit.Test)63 WPanel (com.github.bordertech.wcomponents.WPanel)17 WCollapsible (com.github.bordertech.wcomponents.WCollapsible)10 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)10 UIContext (com.github.bordertech.wcomponents.UIContext)9 WHeading (com.github.bordertech.wcomponents.WHeading)9 WTabSet (com.github.bordertech.wcomponents.WTabSet)7 DefaultWComponent (com.github.bordertech.wcomponents.DefaultWComponent)6 WList (com.github.bordertech.wcomponents.WList)6 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)6 MockServletConfig (com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig)6 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)5 WComponent (com.github.bordertech.wcomponents.WComponent)5 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)5 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)5 WImage (com.github.bordertech.wcomponents.WImage)5 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)5 MockHttpServletRequest (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest)5