Search in sources :

Example 1 with WFieldErrorIndicator

use of com.github.bordertech.wcomponents.validation.WFieldErrorIndicator in project wcomponents by BorderTech.

the class WFieldErrorIndicatorRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WContainer root = new WContainer();
    WPanel target = new WPanel();
    WFieldErrorIndicator indicator = new WFieldErrorIndicator(target);
    root.add(indicator);
    root.add(target);
    List<Diagnostic> diags = new ArrayList<>();
    diags.add(new DiagnosticImpl(Diagnostic.ERROR, target, getMaliciousContent()));
    root.showErrorIndicators(diags);
    assertSafeContent(root);
}
Also used : WFieldErrorIndicator(com.github.bordertech.wcomponents.validation.WFieldErrorIndicator) WContainer(com.github.bordertech.wcomponents.WContainer) DiagnosticImpl(com.github.bordertech.wcomponents.validation.DiagnosticImpl) WPanel(com.github.bordertech.wcomponents.WPanel) ArrayList(java.util.ArrayList) Diagnostic(com.github.bordertech.wcomponents.validation.Diagnostic) Test(org.junit.Test)

Example 2 with WFieldErrorIndicator

use of com.github.bordertech.wcomponents.validation.WFieldErrorIndicator in project wcomponents by BorderTech.

the class WFieldErrorIndicatorRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WContainer root = new WContainer();
    WPanel target = new WPanel();
    WFieldErrorIndicator indicator = new WFieldErrorIndicator(target);
    root.add(target);
    root.add(indicator);
    // Simulate Error Message
    setActiveContext(createUIContext());
    List<Diagnostic> diags = new ArrayList<>();
    diags.add(new DiagnosticImpl(Diagnostic.ERROR, target, "Test Error"));
    root.showErrorIndicators(diags);
    // Validate Schema
    assertSchemaMatch(root);
    // Check Attributes
    assertXpathEvaluatesTo(indicator.getId(), "//ui:fieldindicator/@id", root);
    assertXpathEvaluatesTo("error", "//ui:fieldindicator/@type", root);
    assertXpathEvaluatesTo(target.getId(), "//ui:fieldindicator/@for", root);
    // Check Message
    assertXpathEvaluatesTo("Test Error", "//ui:fieldindicator/ui:message", root);
}
Also used : WFieldErrorIndicator(com.github.bordertech.wcomponents.validation.WFieldErrorIndicator) WContainer(com.github.bordertech.wcomponents.WContainer) DiagnosticImpl(com.github.bordertech.wcomponents.validation.DiagnosticImpl) WPanel(com.github.bordertech.wcomponents.WPanel) ArrayList(java.util.ArrayList) Diagnostic(com.github.bordertech.wcomponents.validation.Diagnostic) Test(org.junit.Test)

Example 3 with WFieldErrorIndicator

use of com.github.bordertech.wcomponents.validation.WFieldErrorIndicator in project wcomponents by BorderTech.

the class WFieldErrorIndicatorRenderer_Test method testRendererCorrectlyConfigured.

/**
 * Test the Layout is correctly configured.
 */
@Test
public void testRendererCorrectlyConfigured() {
    WFieldErrorIndicator indicator = new WFieldErrorIndicator(new WTextField());
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(indicator) instanceof WFieldErrorIndicatorRenderer);
}
Also used : WFieldErrorIndicator(com.github.bordertech.wcomponents.validation.WFieldErrorIndicator) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Aggregations

WFieldErrorIndicator (com.github.bordertech.wcomponents.validation.WFieldErrorIndicator)3 Test (org.junit.Test)3 WContainer (com.github.bordertech.wcomponents.WContainer)2 WPanel (com.github.bordertech.wcomponents.WPanel)2 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)2 DiagnosticImpl (com.github.bordertech.wcomponents.validation.DiagnosticImpl)2 ArrayList (java.util.ArrayList)2 WTextField (com.github.bordertech.wcomponents.WTextField)1