use of com.github.bordertech.wcomponents.validation.WFieldWarningIndicator in project wcomponents by BorderTech.
the class WFieldWarningIndicatorRenderer_Test method testRendererCorrectlyConfigured.
/**
* Test the Layout is correctly configured.
*/
@Test
public void testRendererCorrectlyConfigured() {
WFieldWarningIndicator indicator = new WFieldWarningIndicator(new WTextField());
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(indicator) instanceof WFieldWarningIndicatorRenderer);
}
use of com.github.bordertech.wcomponents.validation.WFieldWarningIndicator in project wcomponents by BorderTech.
the class WFieldWarningIndicatorRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WContainer root = new WContainer();
WPanel target = new WPanel();
WFieldWarningIndicator indicator = new WFieldWarningIndicator(target);
root.add(target);
root.add(indicator);
// Simulate Warning Message
setActiveContext(createUIContext());
List<Diagnostic> diags = new ArrayList<>();
diags.add(new DiagnosticImpl(Diagnostic.WARNING, target, "Test Warning"));
root.showWarningIndicators(diags);
// Validate Schema
assertSchemaMatch(root);
// Check Attributes
assertXpathEvaluatesTo(indicator.getId(), "//ui:fieldindicator/@id", root);
assertXpathEvaluatesTo("warn", "//ui:fieldindicator/@type", root);
assertXpathEvaluatesTo(target.getId(), "//ui:fieldindicator/@for", root);
// Check Message
assertXpathEvaluatesTo("Test Warning", "//ui:fieldindicator/ui:message", root);
}
use of com.github.bordertech.wcomponents.validation.WFieldWarningIndicator in project wcomponents by BorderTech.
the class WFieldWarningIndicatorRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WContainer root = new WContainer();
WPanel target = new WPanel();
WFieldWarningIndicator indicator = new WFieldWarningIndicator(target);
root.add(target);
root.add(indicator);
setActiveContext(createUIContext());
List<Diagnostic> diags = new ArrayList<>();
diags.add(new DiagnosticImpl(Diagnostic.WARNING, target, getMaliciousContent()));
root.showWarningIndicators(diags);
assertSafeContent(root);
}
Aggregations