use of org.structr.web.entity.dom.Content in project structr by structr.
the class DeploymentTest method test31RoundtripWithEmptyContentElements.
@Test
public void test31RoundtripWithEmptyContentElements() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test31");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test31");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Div div2 = createElement(page, div1, "div", "");
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");
final Content c1 = createContent(page, td11, "");
final Td td12 = createElement(page, tr1, "td", "content12");
final P p1 = createElement(page, td12, "p", "");
final Ul ul = createElement(page, p1, "ul");
final Li li = createElement(page, ul, "li", "");
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", "");
final Option option2 = createElement(page, select, "option", "value2");
final Content c2 = createContent(page, div2, "");
final Table table2 = createElement(page, div2, "table");
// include visibility flags
page.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
c1.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
c2.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
// modify visibility to produce two consecutive deployment instruction comments
td12.setProperty(AbstractNode.visibleToPublicUsers, true);
table2.setProperty(AbstractNode.visibleToPublicUsers, true);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
compare(calculateHash(), true);
}
use of org.structr.web.entity.dom.Content in project structr by structr.
the class DeploymentTest method test21ExportGrants.
@Test
public void test21ExportGrants() {
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, "test21");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test21");
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");
// create grants
page.grant(Permission.read, user2);
div1.grant(Permission.read, user2);
content.grant(Permission.read, user2);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true, false);
}
use of org.structr.web.entity.dom.Content in project structr by structr.
the class DeploymentTest method test26Escaping.
@Test
public void test26Escaping() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test25");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test25");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Content content1 = createContent(page, div1, "<div><script>var test = '<h3>Title</h3>';</script></div>");
content1.setProperty(StructrApp.key(Content.class, "contentType"), "text/html");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
compare(calculateHash(), true);
}
use of org.structr.web.entity.dom.Content in project structr by structr.
the class DeploymentTest method test03ContentTypes.
@Test
public void test03ContentTypes() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test03");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test03");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Script script = createElement(page, div1, "script");
final Content content = createContent(page, script, "$(function () {\n\n" + "$('a[data-toggle=\"tab\"]').on('click', function (e) {\n\n" + "var id = $(e.target).attr(\"href\").substr(1) // activated tab\n" + "window.location.hash = id;\n" + "});\n\n" + "});");
// workaround for strange importer behaviour
script.setProperty(StructrApp.key(Script.class, "_html_type"), "text/javascript");
content.setProperty(StructrApp.key(Content.class, "contentType"), "text/javascript");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.web.entity.dom.Content 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);
}
Aggregations