use of org.structr.common.error.FrameworkException in project structr by structr.
the class DeploymentTest method test18NonNamedNonSharedTemplateWithChildren.
@Test
public void test18NonNamedNonSharedTemplateWithChildren() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test18");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test18");
final Body body = createElement(page, html, "body");
final Template template = createTemplate(page, body, "${render(children)}");
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.common.error.FrameworkException 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.common.error.FrameworkException in project structr by structr.
the class DeploymentTest method test28MailTemplates.
@Test
public void test28MailTemplates() {
// setup
try (final Tx tx = app.tx()) {
app.create(MailTemplate.class, new NodeAttribute<>(StructrApp.key(MailTemplate.class, "name"), "template1"), new NodeAttribute<>(StructrApp.key(MailTemplate.class, "locale"), "de_DE"), new NodeAttribute<>(StructrApp.key(MailTemplate.class, "text"), "text1"), new NodeAttribute<>(StructrApp.key(MailTemplate.class, "visibleToPublicUsers"), true));
app.create(MailTemplate.class, new NodeAttribute<>(StructrApp.key(MailTemplate.class, "name"), "template2"), new NodeAttribute<>(StructrApp.key(MailTemplate.class, "locale"), "en"), new NodeAttribute<>(StructrApp.key(MailTemplate.class, "text"), "text2"), new NodeAttribute<>(StructrApp.key(MailTemplate.class, "visibleToAuthenticatedUsers"), true));
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
// test
doImportExportRoundtrip(true);
// check
try (final Tx tx = app.tx()) {
final MailTemplate template1 = app.nodeQuery(MailTemplate.class).and(MailTemplate.name, "template1").getFirst();
final MailTemplate template2 = app.nodeQuery(MailTemplate.class).and(MailTemplate.name, "template2").getFirst();
Assert.assertNotNull("Invalid deployment result", template1);
Assert.assertNotNull("Invalid deployment result", template2);
Assert.assertEquals("Invalid MailTemplate deployment result", "template1", template1.getProperty(StructrApp.key(MailTemplate.class, "name")));
Assert.assertEquals("Invalid MailTemplate deployment result", "de_DE", template1.getProperty(StructrApp.key(MailTemplate.class, "locale")));
Assert.assertEquals("Invalid MailTemplate deployment result", "text1", template1.getProperty(StructrApp.key(MailTemplate.class, "text")));
Assert.assertEquals("Invalid MailTemplate deployment result", true, template1.getProperty(StructrApp.key(MailTemplate.class, "visibleToPublicUsers")));
Assert.assertEquals("Invalid MailTemplate deployment result", false, template1.getProperty(StructrApp.key(MailTemplate.class, "visibleToAuthenticatedUsers")));
Assert.assertEquals("Invalid MailTemplate deployment result", "template2", template2.getProperty(StructrApp.key(MailTemplate.class, "name")));
Assert.assertEquals("Invalid MailTemplate deployment result", "en", template2.getProperty(StructrApp.key(MailTemplate.class, "locale")));
Assert.assertEquals("Invalid MailTemplate deployment result", "text2", template2.getProperty(StructrApp.key(MailTemplate.class, "text")));
Assert.assertEquals("Invalid MailTemplate deployment result", false, template2.getProperty(StructrApp.key(MailTemplate.class, "visibleToPublicUsers")));
Assert.assertEquals("Invalid MailTemplate deployment result", true, template2.getProperty(StructrApp.key(MailTemplate.class, "visibleToAuthenticatedUsers")));
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
}
use of org.structr.common.error.FrameworkException in project structr by structr.
the class DeploymentTest method test37SharedComponentTemplate.
@Test
public void test37SharedComponentTemplate() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createSimplePage(securityContext, "page1");
final Div div = (Div) page.getElementsByTagName("div").item(0);
try {
final DOMNode newNode = (DOMNode) page.createTextNode("#template");
newNode.unlockSystemPropertiesOnce();
newNode.setProperties(newNode.getSecurityContext(), new PropertyMap(NodeInterface.type, Template.class.getSimpleName()));
// append template
div.appendChild(newNode);
// create component from div
createComponent(div);
} catch (FrameworkException fex) {
fex.printStackTrace();
fail("Unexpected exception.");
}
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
compare(calculateHash(), true);
}
use of org.structr.common.error.FrameworkException in project structr by structr.
the class DeploymentTest method test35WidgetWithSharedComponentCreation.
@Test
public void test35WidgetWithSharedComponentCreation() {
// setup
try (final Tx tx = app.tx()) {
final Page testPage = Page.createNewPage(securityContext, "WidgetTestPage");
final Html html = createElement(testPage, testPage, "html");
final Head head = createElement(testPage, html, "head");
final Body body = createElement(testPage, html, "body");
final Div div = createElement(testPage, body, "div");
final Div div2 = createElement(testPage, body, "div");
div.setProperty(AbstractNode.name, "WidgetTestPage-Div");
div2.setProperty(AbstractNode.name, "WidgetTestPage-Div2");
Widget widgetToImport = app.create(Widget.class, new NodeAttribute<>(StructrApp.key(Widget.class, "name"), "TestWidget"), new NodeAttribute<>(StructrApp.key(Widget.class, "source"), "<structr:component src=\"TestComponent\">\n" + " <div data-structr-meta-name=\"TestComponent\">\n" + " Test123\n" + " </div>\n" + "</structr:component>"), new NodeAttribute<>(StructrApp.key(Widget.class, "configuration"), ""), new NodeAttribute<>(StructrApp.key(Widget.class, "visibleToPublicUsers"), true), new NodeAttribute<>(StructrApp.key(Widget.class, "visibleToAuthenticatedUsers"), true));
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("widgetHostBaseUrl", "https://widgets.structr.org/structr/rest/widgets");
paramMap.put("parentId", widgetToImport.getProperty(new StartNode<>("owner", PrincipalOwnsNode.class)));
paramMap.put("source", widgetToImport.getProperty(new StringProperty("source")));
paramMap.put("processDeploymentInfo", false);
Widget.expandWidget(securityContext, testPage, div, baseUri, paramMap, false);
Widget.expandWidget(securityContext, testPage, div, baseUri, paramMap, false);
makePublic(testPage, html, head, body, div, div2);
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
// test
try (final Tx tx = app.tx()) {
Div div = app.nodeQuery(Div.class).andName("WidgetTestPage-Div").getFirst();
assertEquals(2, div.treeGetChildCount());
Object obj = null;
for (DOMNode n : div.getAllChildNodes()) {
obj = n;
break;
}
assertTrue(Div.class.isAssignableFrom(obj.getClass()));
Div clonedNode = (Div) obj;
assertEquals(0, clonedNode.getChildNodes().getLength());
assertEquals(3, app.nodeQuery(Div.class).andName("TestComponent").getResult().size());
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
}
Aggregations