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);
}
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);
}
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);
}
Aggregations