/** * @param label the column label */ public AbstractTableColumn(final String label) { this(null, label, new WText(), null); }
/** * Creates a decorated label with a WText as the body content, containing the given text. * * @param text the label's text, using {@link MessageFormat} syntax. * @param args optional arguments for the message format string. */ public WDecoratedLabel(final String text, final Serializable... args) { this(null, new WText(text, args), null); }
/** * Creates a BoxComponent with the specified text. * * @param text the text to display in the box. */ BoxComponent(final String text) { super(WPanel.Type.BOX); add(new WText(text)); } }
/** * Creates a new WMenuItem with the specified text. * * @param text the menu item's text. */ public WMenuItem(final String text) { this(new WDecoratedLabel()); label.setBody(new WText(text)); }
@Test public void testRendererCorrectlyConfigured() { WText text = new WText(); Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(text) instanceof WTextRenderer); }
/** * @param content the test content */ public TestComp(final String content) { WText text = new WText(content); text.setEncodeText(false); add(text); } }
@Test public void testXssEscaping() throws IOException, SAXException, XpathException { WCollapsible collapsible = new WCollapsible(new WText("dummy"), getMaliciousContent(), WCollapsible.CollapsibleMode.CLIENT); assertSafeContent(collapsible); }
@Test public void testNoSanitizeOnOutput() { String input = "<form>content</form>"; WText text = new WText(input); text.setEncodeText(false); Assert.assertEquals("Expect output to not be sanitized", input, text.getText()); }
@Test(expected = SystemException.class) public void testRenderToHtmlWithPlainText() { String msg = "Test error message"; WText text = new WText(msg); // Text will fail as it is not valid XML String output = WebUtilities.renderWithTransformToHTML(new MockRequest(), text, false); Assert.assertEquals("Invalid html output returned", msg, output); }
@Test public void testDoRenderDynamicCollapse() throws IOException, SAXException, XpathException { WCollapsible collapsible = new WCollapsible(new WText(COLLAPSIBLE_CONTENT), COLLAPSIBLE_HEADING, WCollapsible.CollapsibleMode.DYNAMIC); assertSchemaMatch(collapsible); assertXpathEvaluatesTo("dynamic", "//ui:collapsible/@mode", collapsible); assertRenderContentCorrectly(collapsible, false, true); }
@Test public void testMarginAccessors() { WCollapsible collapsible = new WCollapsible(new WText(""), "", WCollapsible.CollapsibleMode.CLIENT); assertAccessorsCorrect(collapsible, "margin", null, new Margin(1), new Margin(2)); }
@Test public void testXssEscaping() throws IOException, SAXException, XpathException { WFigure figure = new WFigure(new WText(getMaliciousContent()), getMaliciousContent()); assertSafeContent(figure); }
@Test public void testConstructor2() { WText wText = new WText("sample text"); WButton trigger = new WButton("trigger"); WDialog dialog = new WDialog(wText, trigger); Assert.assertEquals("Content should be set", wText, dialog.getContent()); Assert.assertEquals("Trigger should be set", trigger, dialog.getTrigger()); Assert.assertTrue("Has trigger should be true", dialog.hasLegacyTriggerButton()); }
/** * Creates a new tabset with all the tab types. * * @return a new tabset with content. */ private static WTabSet createTabSet() { WTabSet tabSet = new WTabSet(); for (WTabSet.TabMode mode : WTabSet.TabMode.values()) { tabSet.addTab(new WText(mode + " content"), mode + " tab", mode); } return tabSet; }
@Test public void testRenderToHtmlWithXML() { WText text = new WText(TransformXMLTestHelper.TEST_XML); text.setEncodeText(false); // Dont use PageShell as it wraps the XML with ui:root and test xslt does not pass the other tags String output = WebUtilities.renderWithTransformToHTML(new MockRequest(), text, false); Assert.assertEquals("Invalid html output with XML", TransformXMLTestHelper.EXPECTED, output); } @Test
@Test public void testGetGroupName() { WCollapsible collapsible = new WCollapsible(new WText(""), ""); Assert.assertEquals("Incorrect group name", collapsible.getId(), collapsible.getGroupName()); CollapsibleGroup group = new CollapsibleGroup(); collapsible.setGroup(group); Assert. assertEquals("Incorrect group name", group.getGroupName(), collapsible. getGroupName()); }
@Test public void testGetTabLabel() { final String labelText = "this is a label"; WContainer component = new WContainer(); component.add(new WText("this is some text")); WDecoratedLabel label = new WDecoratedLabel(labelText); WTab tab = new WTab(component, label, WTabSet.TabMode.CLIENT); Assert.assertEquals("should get decorated label set in constructor", label, tab. getTabLabel()); }
/** * @return a simple WList for use in this test. */ private static WList createSampleWList() { WText nameRenderer = new WText(); nameRenderer.setBeanProperty("name"); WList list = new WList(WList.Type.STACKED); list.setSeparator(WList.Separator.DOT); list.setRenderBorder(false); list.setRepeatedComponent(nameRenderer); return list; }
/** * @param template the template to setup */ private void setupTemplate(final WTemplate template) { template.setIdName(TEST_ID); template.addTaggedComponent("child1", new WText(CHILD_TEXT)); template.addParameter("mytest", PARAMETER_TEXT); template.setBean(new TestBean(FIRST_NAME, LAST_NAME)); }