use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testInsertAsFirstChildUpdateText.
/**
* Test update of text value in case two adjacent text nodes would be the result of an insert.
*/
@Test
public void testInsertAsFirstChildUpdateText() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.moveTo(1L);
wtx.insertTextAsFirstChild("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("foooops1", rtx.getValue());
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testFourthMoveToFirstChild.
@Test(expected = SirixUsageException.class)
public void testFourthMoveToFirstChild() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(4);
wtx.moveSubtreeToFirstChild(11);
wtx.commit();
wtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testFirstCopySubtreeAsFirstChild.
@Test
public void testFirstCopySubtreeAsFirstChild() throws SirixException {
// Test for one node.
XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.close();
XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
rtx.moveTo(4);
wtx = holder.getResourceManager().beginNodeWriteTrx();
wtx.moveTo(9);
wtx.copySubtreeAsFirstChild(rtx);
testFirstCopySubtreeAsFirstChild(wtx);
wtx.commit();
wtx.close();
rtx = holder.getResourceManager().beginNodeReadTrx();
testFirstCopySubtreeAsFirstChild(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testRemoveDescendantTextConcat2.
/**
* Test for text concatenation.
*/
@Test
public void testRemoveDescendantTextConcat2() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.moveTo(9L);
wtx.remove();
wtx.moveTo(5L);
wtx.remove();
testRemoveDescendantTextConcat2(wtx);
wtx.commit();
testRemoveDescendantTextConcat2(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testRemoveDescendantTextConcat2(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testInsert.
@Test
public void testInsert() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
testInsert(wtx);
wtx.commit();
testInsert(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testInsert(rtx);
rtx.close();
}
Aggregations