use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testSecondMoveSubtreeToRightSibling.
@Test
public void testSecondMoveSubtreeToRightSibling() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(9);
wtx.moveSubtreeToRightSibling(5);
// wtx.moveTo(5);
// wtx.moveSubtreeToRightSibling(4);
testSecondMoveSubtreeToRightSibling(wtx);
wtx.commit();
testSecondMoveSubtreeToRightSibling(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testSecondMoveSubtreeToRightSibling(rtx);
rtx.moveToDocumentRoot();
final Builder<SirixDeweyID> builder = ImmutableSet.<SirixDeweyID>builder();
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.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.5")).add(new SirixDeweyID("1.3.5.7")).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.moveToDocumentRoot();
for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(rtx, IncludeSelf.YES))) {
System.out.println(nodeKey + ": " + rtx.getDeweyID());
}
rtx.close();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testReplaceElement.
@Test
public void testReplaceElement() throws SirixException, IOException, XMLStreamException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(5);
wtx.replaceNode("<d>foobar</d>");
testReplaceElement(wtx);
wtx.commit();
testReplaceElement(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testReplaceElement(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testThirdMoveToFirstChild.
@Test
public void testThirdMoveToFirstChild() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(5);
wtx.moveSubtreeToFirstChild(11);
testThirdMoveToFirstChild(wtx);
wtx.commit();
testThirdMoveToFirstChild(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testThirdMoveToFirstChild(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.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.2.3")).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.5")).add(new SirixDeweyID("1.3.11")).build();
test(ids.iterator(), new NonStructuralWrapperAxis(new DescendantAxis(rtx, IncludeSelf.YES)));
rtx.close();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class UpdateTest method testFourthMoveSubtreeToRightSibling.
@Test
public void testFourthMoveSubtreeToRightSibling() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(8);
wtx.moveSubtreeToRightSibling(4);
testFourthMoveSubtreeToRightSibling(wtx);
wtx.commit();
testFourthMoveSubtreeToRightSibling(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testFourthMoveSubtreeToRightSibling(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeReadTrx 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();
}
Aggregations