Search in sources :

Example 6 with WMessageBox

use of com.github.bordertech.wcomponents.WMessageBox in project wcomponents by BorderTech.

the class WMessageBoxRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WMessageBox messageBox = new WMessageBox(WMessageBox.SUCCESS);
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(messageBox) instanceof WMessageBoxRenderer);
}
Also used : WMessageBox(com.github.bordertech.wcomponents.WMessageBox) Test(org.junit.Test)

Example 7 with WMessageBox

use of com.github.bordertech.wcomponents.WMessageBox in project wcomponents by BorderTech.

the class WMessageBoxRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WMessageBox messageBox = new WMessageBox(WMessageBox.INFO);
    messageBox.addMessage(getInvalidCharSequence());
    assertSafeContent(messageBox);
    messageBox.addMessage(getMaliciousContent());
    assertSafeContent(messageBox);
}
Also used : WMessageBox(com.github.bordertech.wcomponents.WMessageBox) Test(org.junit.Test)

Example 8 with WMessageBox

use of com.github.bordertech.wcomponents.WMessageBox in project wcomponents by BorderTech.

the class WMessageBoxRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    String message1 = "WMessageBox_Test.testDoPaint.message1";
    String message2 = "WMessageBox_Test.testDoPaint.message2";
    String message3 = "WMessageBox_Test.testDoPaint.message3";
    WMessageBox messageBox = new WMessageBox(WMessageBox.SUCCESS);
    messageBox.addMessage(message1);
    messageBox.addMessage(message2);
    messageBox.addMessage(message3);
    assertSchemaMatch(messageBox);
    assertXpathEvaluatesTo("success", "//ui:messagebox/@type", messageBox);
    assertXpathEvaluatesTo(message1, "normalize-space(//ui:messagebox/ui:message[position()=1])", messageBox);
    assertXpathEvaluatesTo(message2, "normalize-space(//ui:messagebox/ui:message[position()=2])", messageBox);
    assertXpathEvaluatesTo(message3, "normalize-space(//ui:messagebox/ui:message[position()=3])", messageBox);
    messageBox.setType(WMessageBox.INFO);
    assertSchemaMatch(messageBox);
    assertXpathEvaluatesTo("info", "//ui:messagebox/@type", messageBox);
    messageBox.setType(WMessageBox.WARN);
    assertSchemaMatch(messageBox);
    assertXpathEvaluatesTo("warn", "//ui:messagebox/@type", messageBox);
    messageBox.setType(WMessageBox.ERROR);
    assertSchemaMatch(messageBox);
    assertXpathEvaluatesTo("error", "//ui:messagebox/@type", messageBox);
    String title = "WMEssageBoxTitle";
    messageBox.setTitleText(title);
    assertSchemaMatch(messageBox);
    assertXpathEvaluatesTo(title, "//ui:messagebox/@title", messageBox);
}
Also used : WMessageBox(com.github.bordertech.wcomponents.WMessageBox) Test(org.junit.Test)

Example 9 with WMessageBox

use of com.github.bordertech.wcomponents.WMessageBox in project wcomponents by BorderTech.

the class WMessageBoxRenderer_Test method testEncodeText.

@Test
public void testEncodeText() throws IOException, SAXException, XpathException {
    String text = "T1<b>T2</b>T3";
    String encoded = WebUtilities.encode(text);
    WMessageBox messageBox = new WMessageBox(WMessageBox.INFO);
    messageBox.addMessage(text);
    // Encoded (default)
    assertSchemaMatch(messageBox);
    String xml = toXHtml(messageBox);
    Assert.assertTrue("XML should have encoded message", xml.contains(encoded));
    // Not encoded
    messageBox.reset();
    messageBox.addMessage(false, text);
    assertSchemaMatch(messageBox);
    xml = toXHtml(messageBox);
    Assert.assertTrue("XML should have not encoded message", xml.contains(text));
}
Also used : WMessageBox(com.github.bordertech.wcomponents.WMessageBox) Test(org.junit.Test)

Aggregations

WMessageBox (com.github.bordertech.wcomponents.WMessageBox)9 Test (org.junit.Test)5 WHeading (com.github.bordertech.wcomponents.WHeading)3 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)3 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)2 Action (com.github.bordertech.wcomponents.Action)1 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)1 WButton (com.github.bordertech.wcomponents.WButton)1 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)1 WField (com.github.bordertech.wcomponents.WField)1 WLabel (com.github.bordertech.wcomponents.WLabel)1 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)1 WTextField (com.github.bordertech.wcomponents.WTextField)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)1