use of org.structr.web.entity.html.Body in project structr by structr.
the class DeploymentTest method test07SimpleSharedTemplate.
@Test
public void test07SimpleSharedTemplate() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test07");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test07");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Template template = createTemplate(page, div1, "template source - öäüÖÄÜß'\"'`");
createComponent(template);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Body in project structr by structr.
the class DeploymentTest method test30IncreasingIndentationCountInRoundtrip.
@Test
public void test30IncreasingIndentationCountInRoundtrip() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test30");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test30");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Div div2 = createElement(page, div1, "div", "This is a test.");
final Table table1 = createElement(page, div2, "table");
final Thead thead = createElement(page, table1, "thead");
final Tbody tbody = createElement(page, table1, "tbody");
final Tr tr1 = createElement(page, thead, "tr");
final Tr tr2 = createElement(page, tbody, "tr");
final Td td11 = createElement(page, tr1, "td", "content11", "Content before <select>");
final Td td12 = createElement(page, tr1, "td", "content12");
final Td td21 = createElement(page, tr2, "td", "content21");
final Td td22 = createElement(page, tr2, "td", "content22");
final Select select = createElement(page, td11, "select");
final Option option1 = createElement(page, select, "option", "value1");
final Option option2 = createElement(page, select, "option", "value2");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Body in project structr by structr.
the class DeploymentTest method test13EmptyContentElement.
@Test
public void test13EmptyContentElement() {
// setup
try (final Tx tx = app.tx()) {
// create first page
final Page page = Page.createNewPage(securityContext, "test13");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test13");
final Body body = createElement(page, html, "body");
final Script script1 = createElement(page, body, "script", "");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), false);
}
use of org.structr.web.entity.html.Body in project structr by structr.
the class DeploymentTest method test02Visibilities.
@Test
public void test02Visibilities() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test02");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test02");
final Body body = createElement(page, html, "body");
// create a div for admin only
{
final Div div1 = createElement(page, body, "div");
createElement(page, div1, "h1", "private - ${find('User')}");
div1.setProperty(StructrApp.key(DOMNode.class, "showConditions"), "me.isAdmin");
}
// create a private div
{
final Div div1 = createElement(page, body, "div");
createElement(page, div1, "h1", "private - test abcdefghjiklmnopqrstuvwyzöäüßABCDEFGHIJKLMNOPQRSTUVWXYZÖÄÜ?\"'");
div1.setProperty(StructrApp.key(DOMNode.class, "showConditions"), "me.isAdmin");
}
// create a protected div
{
final Div div1 = createElement(page, body, "div");
createElement(page, div1, "h1", "protected - $%&/()=?¼½¬{[]}");
final PropertyMap div1Properties = new PropertyMap();
div1Properties.put(DOMNode.visibleToPublicUsers, false);
div1Properties.put(DOMNode.visibleToAuthenticatedUsers, true);
div1.setProperties(div1.getSecurityContext(), div1Properties);
}
// create a public div
{
final Div div1 = createElement(page, body, "div");
createElement(page, div1, "h1", "public");
final PropertyMap div1Properties = new PropertyMap();
div1Properties.put(DOMNode.visibleToPublicUsers, true);
div1Properties.put(DOMNode.visibleToAuthenticatedUsers, true);
div1.setProperties(div1.getSecurityContext(), div1Properties);
}
// create a public only div
{
final Div div1 = createElement(page, body, "div");
createElement(page, div1, "h1", "public only");
final PropertyMap div1Properties = new PropertyMap();
div1Properties.put(DOMNode.visibleToPublicUsers, true);
div1Properties.put(DOMNode.visibleToAuthenticatedUsers, false);
div1.setProperties(div1.getSecurityContext(), div1Properties);
}
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Body in project structr by structr.
the class DeploymentTest method test22TemplateOwnershipAndGrants.
@Test
public void test22TemplateOwnershipAndGrants() {
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
try (final Tx tx = app.tx()) {
// create first page
final Page page1 = Page.createNewPage(securityContext, "test22_1");
final Html html1 = createElement(page1, page1, "html");
final Head head1 = createElement(page1, html1, "head");
createElement(page1, head1, "title", "test22_1");
final Body body1 = createElement(page1, html1, "body");
final Div div1 = createElement(page1, body1, "div");
createElement(page1, div1, "div", "test1");
createElement(page1, div1, "div", "test1");
final Div component = createComponent(div1);
// create second page
final Page page2 = Page.createNewPage(securityContext, "test22_2");
final Html html2 = createElement(page2, page2, "html");
final Head head2 = createElement(page2, html2, "head");
createElement(page2, head2, "title", "test22_2");
final Body body2 = createElement(page2, html2, "body");
final Div div2 = createElement(page2, body2, "div");
// re-use template from above
final Div cloned = cloneComponent(component, div2);
component.grant(Permission.read, user1);
cloned.grant(Permission.read, user2);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
doImportExportRoundtrip(true, true, new Function() {
@Override
public Object apply(Object t) {
try (final Tx tx = app.tx()) {
createTestNode(User.class, new NodeAttribute<>(AbstractNode.name, "user1"));
createTestNode(User.class, new NodeAttribute<>(AbstractNode.name, "user2"));
tx.success();
} catch (FrameworkException ex) {
fail("Unexpected exception.");
}
return null;
}
});
}
Aggregations