use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testRemoveDescendantFirst.
/**
* Ordinary remove test.
*/
@Test
public void testRemoveDescendantFirst() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.moveTo(4L);
wtx.remove();
wtx.commit();
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
assertEquals(0, rtx.getNodeKey());
assertTrue(rtx.moveToFirstChild().hasMoved());
assertEquals(1, rtx.getNodeKey());
assertEquals(5, rtx.getFirstChildKey());
assertEquals(4, rtx.getChildCount());
assertEquals(8, rtx.getDescendantCount());
assertTrue(rtx.moveToFirstChild().hasMoved());
assertEquals(5, rtx.getNodeKey());
assertEquals(Fixed.NULL_NODE_KEY.getStandardProperty(), rtx.getLeftSiblingKey());
assertTrue(rtx.moveToRightSibling().hasMoved());
assertEquals(8, rtx.getNodeKey());
assertEquals(5, rtx.getLeftSiblingKey());
assertTrue(rtx.moveToRightSibling().hasMoved());
assertEquals(9, rtx.getNodeKey());
assertTrue(rtx.moveToRightSibling().hasMoved());
assertEquals(13, rtx.getNodeKey());
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testSubtreeInsertAsFirstChildSecond.
@Test
public void testSubtreeInsertAsFirstChildSecond() throws SirixException, IOException, XMLStreamException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(11);
wtx.insertSubtreeAsFirstChild(XMLShredder.createStringReader(DocumentCreater.XML_WITHOUT_XMLDECL));
testSubtreeInsertAsFirstChildSecond(wtx);
wtx.commit();
wtx.moveTo(14);
testSubtreeInsertAsFirstChildSecond(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
rtx.moveTo(14);
testSubtreeInsertAsFirstChildSecond(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testSecondCopySubtreeAsFirstChild.
@Test
public void testSecondCopySubtreeAsFirstChild() throws SirixException {
// Test for more than one node.
XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.close();
XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
rtx.moveTo(5);
wtx = holder.getResourceManager().beginNodeWriteTrx();
wtx.moveTo(9);
wtx.copySubtreeAsFirstChild(rtx);
testSecondCopySubtreeAsFirstChild(wtx);
wtx.commit();
wtx.close();
rtx = holder.getResourceManager().beginNodeReadTrx();
testSecondCopySubtreeAsFirstChild(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testNodeTransactionIsolation.
@Test
public void testNodeTransactionIsolation() throws SirixException {
XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
wtx.insertElementAsFirstChild(new QNm(""));
testNodeTransactionIsolation(wtx);
wtx.commit();
testNodeTransactionIsolation(wtx);
XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testNodeTransactionIsolation(rtx);
wtx.moveToFirstChild();
wtx.insertElementAsFirstChild(new QNm(""));
testNodeTransactionIsolation(rtx);
wtx.commit();
testNodeTransactionIsolation(rtx);
rtx.close();
wtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testRemoveDescendant.
/**
* Test for text concatenation.
*/
@Test
public void testRemoveDescendant() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(0L);
// assertEquals(10L, wtx.getDescendantCount());
wtx.commit();
assertEquals(10L, wtx.getDescendantCount());
wtx.moveTo(5L);
wtx.remove();
testRemoveDescendant(wtx);
wtx.commit();
testRemoveDescendant(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testRemoveDescendant(rtx);
rtx.close();
}
Aggregations