use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testPageBoundary.
@Test
public void testPageBoundary() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
// Document root.
wtx.insertElementAsFirstChild(new QNm(""));
wtx.insertElementAsFirstChild(new QNm(""));
for (int i = 0; i < 512 << 1 + 1; i++) {
wtx.insertElementAsRightSibling(new QNm(""));
}
testPageBoundary(wtx);
wtx.commit();
testPageBoundary(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testPageBoundary(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testReplaceElementMergeTextNodes.
@Test
public void testReplaceElementMergeTextNodes() throws SirixException, IOException, XMLStreamException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(5);
wtx.replaceNode("foo");
testReplaceElementMergeTextNodes(wtx);
wtx.commit();
testReplaceElementMergeTextNodes(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testReplaceElementMergeTextNodes(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testInsertAsRightSiblingUpdateTextFirst.
/**
* Test update of text value in case two adjacent text nodes would be the result of an insert.
*/
@Test
public void testInsertAsRightSiblingUpdateTextFirst() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.moveTo(4L);
wtx.insertTextAsRightSibling("foo");
wtx.commit();
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
assertTrue(rtx.moveTo(1L).hasMoved());
assertEquals(4L, rtx.getFirstChildKey());
assertEquals(5L, rtx.getChildCount());
assertEquals(9L, rtx.getDescendantCount());
assertTrue(rtx.moveTo(4L).hasMoved());
assertEquals("oops1foo", rtx.getValue());
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testSubtreeInsertAsFirstChildFirst.
@Test
public void testSubtreeInsertAsFirstChildFirst() throws SirixException, IOException, XMLStreamException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(5);
wtx.insertSubtreeAsFirstChild(XMLShredder.createStringReader(DocumentCreater.XML_WITHOUT_XMLDECL));
testSubtreeInsertAsFirstChildFirst(wtx);
wtx.commit();
wtx.moveTo(14);
testSubtreeInsertAsFirstChildFirst(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
rtx.moveTo(14);
testSubtreeInsertAsFirstChildFirst(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testNamePage.
/**
* Test NamePage.
*/
@Test
public void testNamePage() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.moveTo(7);
wtx.remove();
wtx.moveTo(11);
wtx.remove();
wtx.moveTo(5);
wtx.commit();
wtx.close();
XdmNodeReadTrxImpl rtx = (XdmNodeReadTrxImpl) holder.getResourceManager().beginNodeReadTrx(1);
assertEquals(1, rtx.getRevisionNumber());
assertTrue(rtx.moveTo(7).hasMoved());
assertEquals("c", rtx.getName().getLocalName());
assertTrue(rtx.moveTo(11).hasMoved());
assertEquals("c", rtx.getName().getLocalName());
rtx = (XdmNodeReadTrxImpl) holder.getResourceManager().beginNodeReadTrx();
assertEquals(2, rtx.getRevisionNumber());
assertEquals(null, rtx.getPageTransaction().getName(NamePageHash.generateHashForString("c"), Kind.ELEMENT));
assertEquals(0, rtx.getNameCount("blablabla", Kind.ATTRIBUTE));
rtx.moveTo(5);
assertEquals(2, rtx.getNameCount("b", Kind.ELEMENT));
rtx.close();
}
Aggregations