use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testFirstCopySubtreeAsRightSibling.
@Test
public void testFirstCopySubtreeAsRightSibling() 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.copySubtreeAsRightSibling(rtx);
testFirstCopySubtreeAsRightSibling(wtx);
wtx.commit();
wtx.close();
rtx = holder.getResourceManager().beginNodeReadTrx();
testFirstCopySubtreeAsRightSibling(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testInsertChild.
@Test
public void testInsertChild() throws SirixException {
XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
wtx.insertElementAsFirstChild(new QNm("foo"));
wtx.commit();
wtx.close();
XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
assertEquals(1L, rtx.getRevisionNumber());
rtx.close();
// Insert 100 children.
for (int i = 1; i <= 50; i++) {
wtx = holder.getResourceManager().beginNodeWriteTrx();
wtx.moveToDocumentRoot();
wtx.moveToFirstChild();
wtx.insertElementAsFirstChild(new QNm("bar"));
wtx.insertTextAsRightSibling(Integer.toString(i));
wtx.commit();
wtx.close();
rtx = holder.getResourceManager().beginNodeReadTrx();
rtx.moveToDocumentRoot();
rtx.moveToFirstChild();
rtx.moveToFirstChild();
rtx.moveToRightSibling();
assertEquals(Integer.toString(i), rtx.getValue());
assertEquals(i + 1, rtx.getRevisionNumber());
rtx.close();
}
rtx = holder.getResourceManager().beginNodeReadTrx();
rtx.moveToDocumentRoot();
rtx.moveToFirstChild();
rtx.moveToFirstChild();
rtx.moveToRightSibling();
assertEquals("50", rtx.getValue());
assertEquals(51L, rtx.getRevisionNumber());
rtx.close();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testThirdMoveSubtreeToRightSibling.
@Test
public void testThirdMoveSubtreeToRightSibling() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(9);
wtx.moveSubtreeToRightSibling(4);
testThirdMoveSubtreeToRightSibling(wtx);
wtx.commit();
testThirdMoveSubtreeToRightSibling(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testThirdMoveSubtreeToRightSibling(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testInsertAsRightSiblingUpdateTextSecond.
/**
* Test update of text value in case two adjacent text nodes would be the result of an insert.
*/
@Test
public void testInsertAsRightSiblingUpdateTextSecond() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.commit();
wtx.moveTo(5L);
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(8L).hasMoved());
assertEquals("foooops2", rtx.getValue());
rtx.close();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testSecondMoveToFirstChild.
@Test
public void testSecondMoveToFirstChild() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(5);
wtx.moveSubtreeToFirstChild(4);
testSecondMoveToFirstChild(wtx);
wtx.commit();
testSecondMoveToFirstChild(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testSecondMoveToFirstChild(rtx);
rtx.moveToDocumentRoot();
final Builder<SirixDeweyID> builder = ImmutableSet.<SirixDeweyID>builder();
final ImmutableSet<SirixDeweyID> ids = builder.add(new SirixDeweyID("1")).add(new SirixDeweyID("1.3")).add(new SirixDeweyID("1.3.0.3")).add(new SirixDeweyID("1.3.1.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.3")).add(new SirixDeweyID("1.3.5.5")).add(new SirixDeweyID("1.3.7")).add(new SirixDeweyID("1.3.9")).add(new SirixDeweyID("1.3.9.1.3")).add(new SirixDeweyID("1.3.9.3")).add(new SirixDeweyID("1.3.9.5")).add(new SirixDeweyID("1.3.11")).build();
test(ids.iterator(), new NonStructuralWrapperAxis(new DescendantAxis(rtx, IncludeSelf.YES)));
rtx.close();
}
Aggregations