@Test public void testRendererCorrectlyConfigured() { WTextArea textArea = new WTextArea(); Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(textArea) instanceof WTextAreaRenderer); }
/** * Creates a SuccessComponent. */ public SuccessComponent() { add(new WMessageBox(WMessageBox.SUCCESS, "All is valid!")); beanDetails = new WTextArea(); beanDetails.setRows(15); beanDetails.setColumns(60); beanDetails.setReadOnly(true); add(beanDetails); }
/** * Test the Layout is correctly configured. */ @Test public void testRendererCorrectlyConfigured() { WField field = new WFieldLayout().addField("test1", new WTextArea()); Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(field) instanceof WFieldRenderer); }
/** * Test Not condition. */ @Test public void testNotCondition() { builder.not(new ExpressionBuilder().equals(new WTextArea(), "1")); Assert.assertEquals("Incorrect condition", "NOT (WTextArea=\"1\")", builder.build(). toString()); }
@Test public void testTwoArgAndCondition() { builder.equals(new WTextField(), "1").and().equals(new WTextArea(), "2"); Assert .assertEquals("Incorrect condition", "(WTextField=\"1\" and WTextArea=\"2\")", builder.build().toString()); }
@Test public void testTwoArgOrCondition() { builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2"); Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or WTextArea=\"2\")", builder. build().toString()); }
@Test public void testReadOnly() throws IOException, SAXException, XpathException { WTextArea field = new WTextArea(); field.setReadOnly(true); assertSchemaMatch(field); assertXpathEvaluatesTo("true", "//ui:textarea/@readOnly", field); }
@Test public void testThreeArgAndCondition() { builder.equals(new WTextField(), "1").and().equals(new WTextArea(), "2").and().equals( new WDropdown(), "3"); Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" and WTextArea=\"2\" and WDropdown=\"3\")", builder.build().toString()); }
/** * Tests for correct operator precedence when there is an AND on the right-hand side of the OR: a || b * {@literal &}{@literal &} c. */ @Test public void testAndOperatorPrecedenceRHS() { builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2").and().equals( new WDropdown(), "3"); Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or (WTextArea=\"2\" and WDropdown=\"3\"))", builder.build().toString()); }
@Test public void testThreeArgOrCondition() { builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2").or().equals( new WDropdown(), "3"); Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or WTextArea=\"2\" or WDropdown=\"3\")", builder .build().toString()); }
@Test public void testSetFullAddressAutocompleteWithNullType() { WTextArea textArea = new WTextArea(); textArea.setFullStreetAddressAutocomplete(null); Assert.assertEquals(Multiline.STREET_ADDRESS.getValue(), textArea.getAutocomplete()); }
@Test public void testSetFullAddressAutocomplete() { WTextArea textArea = new WTextArea(); textArea.setFullStreetAddressAutocomplete(); Assert.assertEquals(Multiline.STREET_ADDRESS.getValue(), textArea.getAutocomplete()); }
/** * Tests for correct operator precedence when there is an AND on the left-hand side of the OR: a * {@literal &}{@literal &} b || c. */ @Test public void testAndOperatorPrecedenceLHS() { builder.equals(new WTextField(), "1").and().equals(new WTextArea(), "2").or().equals( new WDropdown(), "3"); Assert.assertEquals("Incorrect condition", "((WTextField=\"1\" and WTextArea=\"2\") or WDropdown=\"3\")", builder.build().toString()); }
@Test public void testSetAutocomplete() { WTextArea textArea = new WTextArea(); for (Multiline value : Multiline.values()) { textArea.setAutocomplete(value); Assert.assertEquals(value.getValue(), textArea.getAutocomplete()); } }
/** * Creates a field layout with a couple of fields. * * @return a new field layout with content. */ private WFieldLayout createFieldLayout() { WFieldLayout fieldLayout = new WFieldLayout(); fieldLayout.addField("Field 1", new WTextField()); fieldLayout.addField("Field 2", new WTextArea()).getLabel().setHint("hint"); return fieldLayout; }
@Test public void testSanitizeOnOutput() { WTextArea textArea = new WTextArea(); textArea.setData("<form>content</form>"); textArea.setSanitizeOnOutput(true); // do not setRichText until after setData otherwise content will be sanitized on setData textArea.setRichTextArea(true); Assert.assertEquals("Expect output to be sanitized", "content", textArea.getText()); }
@Test public void testNoSanitizeOnOutput() { String input = "<form>content</form>"; WTextArea textArea = new WTextArea(); textArea.setData(input); textArea.setSanitizeOnOutput(false); // do not setRichText until after setData otherwise content will be sanitized on setData textArea.setRichTextArea(true); Assert.assertEquals("Expect output to not be sanitized", input, textArea.getText()); }
@Test public void testSetAutocompleteNullValue() { WTextArea textArea = new WTextArea(); textArea.setAutocomplete(Multiline.STREET_ADDRESS); Assert.assertNotNull(textArea.getAutocomplete()); textArea.setAutocomplete((Multiline) null); Assert.assertNull(textArea.getAutocomplete()); }
@Test public void testSetFullStreetAddressAutocompleteWithType() { WTextArea textArea = new WTextArea(); String expected; for (AddressType value : AddressType.values()) { expected = AutocompleteUtil.getCombinedAutocomplete(value.getValue(), Multiline.STREET_ADDRESS.getValue()); textArea.setFullStreetAddressAutocomplete(value); Assert.assertEquals(expected, textArea.getAutocomplete()); } }
@Test public void testXssEscaping() throws IOException, SAXException, XpathException { WTextArea textArea = new WTextArea(); textArea.setText(getMaliciousContent()); assertSafeContent(textArea); textArea.setToolTip(getMaliciousAttribute("ui:textarea")); assertSafeContent(textArea); textArea.setAccessibleText(getMaliciousAttribute("ui:textarea")); assertSafeContent(textArea); } }