use of org.structr.web.entity.html.Title in project structr by structr.
the class CustomHtmlAttributeTest method testCustomHtmlAttribute.
@Test
public void testCustomHtmlAttribute() {
try (final Tx tx = app.tx()) {
// create a page
final Page newPage = Page.createNewPage(securityContext, "customAttributeTestPage");
final Html html = createElement(newPage, newPage, "html");
final Head head = createElement(newPage, html, "head");
final Title title = createElement(newPage, head, "title", "Test Page for custom html attributes");
final Body body = createElement(newPage, html, "body");
final Div div1 = createElement(newPage, body, "div", "DIV with old-style data attribute");
div1.setProperty(new GenericProperty<String>("data-test-attribute-old-style"), "old-style data attribute");
final Div div2 = createElement(newPage, body, "div", "DIV with new-style custom html attribute");
div2.setProperty(new GenericProperty<String>("_custom_html_test-attribute-new-style"), "new-style custom attribute");
final Div div3 = createElement(newPage, body, "div", "DIV with data-attribute as new-style custom html attribute");
div3.setProperty(new GenericProperty<String>("_custom_html_data-test-attribute-new-style"), "new-style custom data-attribute");
final RenderContext renderContext = new RenderContext(securityContext);
newPage.render(renderContext, 0);
final String renderedHtml = StringUtils.join(renderContext.getBuffer().getQueue(), "");
final String expectedHtml = "<!DOCTYPE html>\n" + "<html>\n" + " <head>\n" + " <title>Test Page for custom html attributes</title>\n" + " </head>\n" + " <body>\n" + " <div data-test-attribute-old-style=\"old-style data attribute\">DIV with old-style data attribute</div>\n" + " <div test-attribute-new-style=\"new-style custom attribute\">DIV with new-style custom html attribute</div>\n" + " <div data-test-attribute-new-style=\"new-style custom data-attribute\">DIV with data-attribute as new-style custom html attribute</div>\n" + " </body>\n" + "</html>";
Assert.assertEquals(expectedHtml, renderedHtml);
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
}
}
Aggregations