use of org.structr.web.entity.html.Head in project structr by structr.
the class DeploymentTest method test08SharedTemplateInTwoPages.
@Test
public void test08SharedTemplateInTwoPages() {
// setup
try (final Tx tx = app.tx()) {
// create first page
final Page page1 = Page.createNewPage(securityContext, "test08_1");
final Html html1 = createElement(page1, page1, "html");
final Head head1 = createElement(page1, html1, "head");
createElement(page1, head1, "title", "test08_1");
final Body body1 = createElement(page1, html1, "body");
final Div div1 = createElement(page1, body1, "div");
final Template template1 = createTemplate(page1, div1, "template source - öäüÖÄÜß'\"'`");
final Template component = createComponent(template1);
// create second page
final Page page2 = Page.createNewPage(securityContext, "test08_2");
final Html html2 = createElement(page2, page2, "html");
final Head head2 = createElement(page2, html2, "head");
createElement(page2, head2, "title", "test08_2");
final Body body2 = createElement(page2, html2, "body");
final Div div2 = createElement(page2, body2, "div");
// re-use template from above
cloneComponent(component, div2);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Head in project structr by structr.
the class DeploymentTest method test20ExportOwnership.
@Test
public void test20ExportOwnership() {
Principal user1 = null;
Principal user2 = null;
try (final Tx tx = app.tx()) {
user1 = createTestNode(User.class, new NodeAttribute<>(AbstractNode.name, "user1"));
user2 = createTestNode(User.class, new NodeAttribute<>(AbstractNode.name, "user2"));
tx.success();
} catch (FrameworkException ex) {
fail("Unexpected exception.");
}
Assert.assertNotNull("User was not created, test cannot continue", user1);
Assert.assertNotNull("User was not created, test cannot continue", user2);
// setup
final SecurityContext context1 = SecurityContext.getInstance(user1, AccessMode.Backend);
final App app1 = StructrApp.getInstance(context1);
try (final Tx tx = app1.tx()) {
final Page page = Page.createNewPage(context1, "test20");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test20");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Content content = createContent(page, div1, "<b>Test</b>");
content.setProperty(StructrApp.key(Content.class, "contentType"), "text/html");
// set owner to different user
div1.setProperty(AbstractNode.owner, user2);
content.setProperty(AbstractNode.owner, user2);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true, false);
}
use of org.structr.web.entity.html.Head in project structr by structr.
the class DeploymentTest method test17NamedNonSharedTemplateWithChildren.
@Test
public void test17NamedNonSharedTemplateWithChildren() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test17");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test17");
final Body body = createElement(page, html, "body");
final Template template = createTemplate(page, body, "${render(children)}");
template.setProperty(AbstractNode.name, "a-template");
final Template sharedTemplate = createComponent(template);
// remove original template from page
app.delete(template);
createElement(page, sharedTemplate, "div");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true, false);
}
use of org.structr.web.entity.html.Head 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);
}
}
use of org.structr.web.entity.html.Head in project structr by structr.
the class DeploymentTest method test12EmptyContentElementWithContentType.
@Test
public void test12EmptyContentElementWithContentType() {
// setup
try (final Tx tx = app.tx()) {
// create first page
final Page page = Page.createNewPage(securityContext, "test12");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test12");
final Body body = createElement(page, html, "body");
final Script script1 = createElement(page, body, "script");
final Script script2 = createElement(page, body, "script");
script1.setProperty(StructrApp.key(Script.class, "_html_type"), "text/javascript");
createContent(page, script1, "");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
Aggregations