use of org.structr.common.error.FrameworkException in project structr by structr.
the class ContentTest method testDeleteData.
@Test
public void testDeleteData() {
try (final Tx tx = app.tx()) {
Content content = getContentNode();
assertNotNull(content);
// test basic setting of content
content.setData("Dies ist ein Test");
assertEquals("Dies ist ein Test", content.getData());
content.deleteData(5, 4);
assertEquals("Dies ein Test", content.getData());
tx.success();
} catch (FrameworkException fex) {
fail("unexpected exception");
}
}
use of org.structr.common.error.FrameworkException in project structr by structr.
the class ContentTest method testSplitText.
@Test
public void testSplitText() {
try (final Tx tx = app.tx()) {
Document document = getDocument();
Text content = document.createTextNode("Dies ist ein Test");
assertNotNull(content);
Element div = document.createElement("div");
assertNotNull(div);
// add child
div.appendChild(content);
// test basic setting of content
content.setData("Dies ist ein Test");
assertEquals("Dies ist ein Test", content.getData());
// test split method
Content secondPart = (Content) content.splitText(8);
assertNotNull(secondPart);
assertEquals("Dies ist", content.getData());
assertEquals(" ein Test", secondPart.getData());
// check that parent has two children
NodeList children = div.getChildNodes();
assertNotNull(children);
assertEquals(2, children.getLength());
tx.success();
} catch (FrameworkException fex) {
fail("unexpected exception");
}
}
use of org.structr.common.error.FrameworkException in project structr by structr.
the class ContentTest method testSetData.
@Test
public void testSetData() {
try (final Tx tx = app.tx()) {
Content content = getContentNode();
assertNotNull(content);
// test basic setting of content
content.setData("Dies ist ein Test");
assertEquals("Dies ist ein Test", content.getData());
tx.success();
} catch (FrameworkException fex) {
fail("unexpected exception");
}
}
use of org.structr.common.error.FrameworkException in project structr by structr.
the class ContentTest method testInsertData.
@Test
public void testInsertData() {
try (final Tx tx = app.tx()) {
Content content = getContentNode();
assertNotNull(content);
// test basic setting of content
content.setData("Dies ein Test");
assertEquals("Dies ein Test", content.getData());
content.insertData(5, "ist ");
assertEquals("Dies ist ein Test", content.getData());
tx.success();
} catch (FrameworkException fex) {
fail("unexpected exception");
}
}
use of org.structr.common.error.FrameworkException in project structr by structr.
the class DOMElementTest method testAttributeNodeMethods.
@Test
public void testAttributeNodeMethods() {
try (final Tx tx = StructrApp.getInstance(securityContext).tx()) {
Page doc = (Page) getDocument();
DOMElement elem = (DOMElement) doc.createElement("div");
String name1 = "test1";
String name2 = "test2";
String name3 = "test3";
String value1 = "value1";
String value2 = "value2";
String value3 = "value3";
DOMAttribute attr1 = (DOMAttribute) doc.createAttribute(name1);
assertNotNull(attr1);
attr1.setValue(value1);
elem.setAttributeNode(attr1);
assertEquals(elem, attr1.getParentNode());
DOMAttribute attr2 = (DOMAttribute) doc.createAttribute(name2);
assertNotNull(attr2);
attr2.setValue(value2);
elem.setAttributeNode(attr2);
assertEquals(elem, attr2.getParentNode());
DOMAttribute attr3 = (DOMAttribute) doc.createAttribute(name3);
assertNotNull(attr3);
attr3.setValue(value3);
elem.setAttributeNode(attr3);
assertEquals(elem, attr3.getParentNode());
assertEquals(true, elem.hasAttributes());
assertEquals(3, elem.getAttributes().getLength());
assertEquals(value1, elem.getAttribute(name1));
assertEquals(attr1, elem.getAttributeNode(name1));
assertEquals(value2, elem.getAttribute(name2));
assertEquals(attr2, elem.getAttributeNode(name2));
assertEquals(value3, elem.getAttribute(name3));
assertEquals(attr3, elem.getAttributeNode(name3));
// important for xpath: sibling methods
assertEquals(attr2, attr1.getNextSibling());
assertEquals(attr3, attr2.getNextSibling());
assertEquals(attr2, attr3.getPreviousSibling());
assertEquals(attr1, attr2.getPreviousSibling());
tx.success();
} catch (FrameworkException fex) {
fail("unexpected exception");
}
}
Aggregations