use of org.sirix.api.XdmNodeReadTrx 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.XdmNodeReadTrx 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.XdmNodeReadTrx 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.XdmNodeReadTrx in project sirix by sirixdb.
the class NestedAxisTest method testNestedAxisTest.
@Test
public void testNestedAxisTest() throws SirixException {
final XdmNodeReadTrx rtx = holder.getReader();
// Find descendants starting from nodeKey 0L (root).
rtx.moveToDocumentRoot();
// XPath expression /p:a/b/text()
// Part: /p:a
final Axis childA = new FilterAxis(new ChildAxis(rtx), new NameFilter(rtx, "p:a"));
// Part: /b
final Axis childB = new FilterAxis(new ChildAxis(rtx), new NameFilter(rtx, "b"));
// Part: /text()
final Axis text = new FilterAxis(new ChildAxis(rtx), new TextFilter(rtx));
// Part: /p:a/b/text()
final Axis axis = new NestedAxis(new NestedAxis(childA, childB), text);
AbsAxisTest.testIAxisConventions(axis, new long[] { 6L, 12L });
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class NonStructuralWrapperAxisTest method testAxisConventions.
@Test
public void testAxisConventions() throws SirixException {
final XdmNodeReadTrx rtx = holder.getReader();
AbsAxisTest.testIAxisConventions(new NonStructuralWrapperAxis(new DescendantAxis(rtx)), new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L });
AbsAxisTest.testIAxisConventions(new NonStructuralWrapperAxis(new DescendantAxis(rtx.moveTo(9).get())), new long[] { 10L, 11L, 12L });
}
Aggregations