use of org.structr.web.entity.html.Div in project structr by structr.
the class DeploymentTest method test40TwoTemplatesWithSameNameInTwoPages.
@Test
public void test40TwoTemplatesWithSameNameInTwoPages() {
// setup
try (final Tx tx = app.tx()) {
// create first page
final Page page1 = Page.createNewPage(securityContext, "test40_1");
final Html html1 = createElement(page1, page1, "html");
final Head head1 = createElement(page1, html1, "head");
createElement(page1, head1, "title", "test40_1");
final Body body1 = createElement(page1, html1, "body");
final Div div1 = createElement(page1, body1, "div");
// create first template and give it a name
final Template template1 = createTemplate(page1, div1, "template source - öäüÖÄÜß'\"'`");
final PropertyMap template1Properties = new PropertyMap();
template1Properties.put(Template.name, "Test40Template");
template1.setProperties(template1.getSecurityContext(), template1Properties);
// create second page
final Page page2 = Page.createNewPage(securityContext, "test40_2");
final Html html2 = createElement(page2, page2, "html");
final Head head2 = createElement(page2, html2, "head");
createElement(page2, head2, "title", "test40_2");
final Body body2 = createElement(page2, html2, "body");
final Div div2 = createElement(page2, body2, "div");
// create second template and give it the same name as the first one
final Template template2 = createTemplate(page2, div2, "template source 2 - öäüÖÄÜß'\"'`");
final PropertyMap template2Properties = new PropertyMap();
template2Properties.put(Template.name, "Test40Template");
template2.setProperties(template2.getSecurityContext(), template2Properties);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Div in project structr by structr.
the class UiScriptingTest method testIncludeWithRepeaterInJavaScript.
@Test
public void testIncludeWithRepeaterInJavaScript() {
try (final Tx tx = app.tx()) {
final Page page = Page.createSimplePage(securityContext, "test");
final Div div = (Div) page.getElementsByTagName("div").item(0);
final Content content = (Content) div.getFirstChild();
// setup scripting repeater
content.setProperty(StructrApp.key(Content.class, "content"), "${{ var arr = []; for (var i=0; i<10; i++) { arr.push({name: 'test' + i}); } Structr.include('item', arr, 'test'); }}");
content.setProperty(StructrApp.key(Content.class, "contentType"), "text/html");
// setup shared component with name "table" to include
final ShadowDocument shadowDoc = CreateComponentCommand.getOrCreateHiddenDocument();
final Div item = (Div) shadowDoc.createElement("div");
final Content txt = (Content) shadowDoc.createTextNode("${test.name}");
item.setProperty(StructrApp.key(Table.class, "name"), "item");
item.appendChild(txt);
// create admin user
createTestNode(User.class, new NodeAttribute<>(StructrApp.key(User.class, "name"), "admin"), new NodeAttribute<>(StructrApp.key(User.class, "password"), "admin"), new NodeAttribute<>(StructrApp.key(User.class, "isAdmin"), true));
tx.success();
} catch (FrameworkException fex) {
fex.printStackTrace();
fail("Unexpected exception.");
}
RestAssured.basePath = "/";
// test successful basic auth
RestAssured.given().headers("X-User", "admin", "X-Password", "admin").filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(200)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(400)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(401)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(403)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(404)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(422)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(500)).expect().statusCode(200).body("html.head.title", Matchers.equalTo("Test")).body("html.body.h1", Matchers.equalTo("Test")).body("html.body.div.div[0]", Matchers.equalTo("test0")).body("html.body.div.div[1]", Matchers.equalTo("test1")).body("html.body.div.div[2]", Matchers.equalTo("test2")).body("html.body.div.div[3]", Matchers.equalTo("test3")).body("html.body.div.div[4]", Matchers.equalTo("test4")).body("html.body.div.div[5]", Matchers.equalTo("test5")).body("html.body.div.div[6]", Matchers.equalTo("test6")).body("html.body.div.div[7]", Matchers.equalTo("test7")).body("html.body.div.div[8]", Matchers.equalTo("test8")).body("html.body.div.div[9]", Matchers.equalTo("test9")).when().get("/html/test");
}
use of org.structr.web.entity.html.Div in project structr by structr.
the class UiScriptingTest method testFunctionQueryWithJavaScriptAndRepeater.
@Test
public void testFunctionQueryWithJavaScriptAndRepeater() {
try (final Tx tx = app.tx()) {
final Page page = Page.createSimplePage(securityContext, "test");
final Div div = (Div) page.getElementsByTagName("div").item(0);
final Content content = (Content) div.getFirstChild();
// setup repeater
content.setProperty(StructrApp.key(DOMNode.class, "functionQuery"), "{ var arr = []; for (var i=0; i<10; i++) { arr.push({ name: 'test' + i }); }; return arr; }");
content.setProperty(StructrApp.key(DOMNode.class, "dataKey"), "test");
content.setProperty(StructrApp.key(Content.class, "content"), "${test.name}");
// create admin user
createTestNode(User.class, new NodeAttribute<>(StructrApp.key(User.class, "name"), "admin"), new NodeAttribute<>(StructrApp.key(User.class, "password"), "admin"), new NodeAttribute<>(StructrApp.key(User.class, "isAdmin"), true));
tx.success();
} catch (FrameworkException fex) {
fex.printStackTrace();
fail("Unexpected exception.");
}
RestAssured.basePath = "/";
// test successful basic auth
RestAssured.given().headers("X-User", "admin", "X-Password", "admin").filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(200)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(400)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(401)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(403)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(404)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(422)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(500)).expect().statusCode(200).body("html.head.title", Matchers.equalTo("Test")).body("html.body.h1", Matchers.equalTo("Test")).body("html.body.div", Matchers.equalTo("test0test1test2test3test4test5test6test7test8test9")).when().get("/html/test");
}
Aggregations