Search in sources :

Example 86 with XdmNodeReadTrx

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();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 87 with XdmNodeReadTrx

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();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 88 with XdmNodeReadTrx

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();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 89 with XdmNodeReadTrx

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 });
}
Also used : NameFilter(org.sirix.axis.filter.NameFilter) TextFilter(org.sirix.axis.filter.TextFilter) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) FilterAxis(org.sirix.axis.filter.FilterAxis) Axis(org.sirix.api.Axis) FilterAxis(org.sirix.axis.filter.FilterAxis) Test(org.junit.Test)

Example 90 with XdmNodeReadTrx

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 });
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Aggregations

XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)150 Test (org.junit.Test)93 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)48 QNm (org.brackit.xquery.atomic.QNm)20 DescendantAxis (org.sirix.axis.DescendantAxis)17 Iterator (java.util.Iterator)16 ResourceManager (org.sirix.api.ResourceManager)14 Axis (org.sirix.api.Axis)13 DBNode (org.sirix.xquery.node.DBNode)12 QueryException (org.brackit.xquery.QueryException)11 FilterAxis (org.sirix.axis.filter.FilterAxis)11 IndexController (org.sirix.access.IndexController)10 IndexDef (org.sirix.index.IndexDef)10 Item (org.brackit.xquery.xdm.Item)7 Database (org.sirix.api.Database)7 SirixException (org.sirix.exception.SirixException)6 NonStructuralWrapperAxis (org.sirix.axis.NonStructuralWrapperAxis)5 SirixDeweyID (org.sirix.node.SirixDeweyID)5 Path (java.nio.file.Path)4 AbsAxisTest (org.sirix.axis.AbsAxisTest)4