Search in sources :

Example 16 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class UpdateTest method testRemoveDescendantFirst.

/**
 * Ordinary remove test.
 */
@Test
public void testRemoveDescendantFirst() throws SirixException {
    final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    wtx.commit();
    wtx.moveTo(4L);
    wtx.remove();
    wtx.commit();
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    assertEquals(0, rtx.getNodeKey());
    assertTrue(rtx.moveToFirstChild().hasMoved());
    assertEquals(1, rtx.getNodeKey());
    assertEquals(5, rtx.getFirstChildKey());
    assertEquals(4, rtx.getChildCount());
    assertEquals(8, rtx.getDescendantCount());
    assertTrue(rtx.moveToFirstChild().hasMoved());
    assertEquals(5, rtx.getNodeKey());
    assertEquals(Fixed.NULL_NODE_KEY.getStandardProperty(), rtx.getLeftSiblingKey());
    assertTrue(rtx.moveToRightSibling().hasMoved());
    assertEquals(8, rtx.getNodeKey());
    assertEquals(5, rtx.getLeftSiblingKey());
    assertTrue(rtx.moveToRightSibling().hasMoved());
    assertEquals(9, rtx.getNodeKey());
    assertTrue(rtx.moveToRightSibling().hasMoved());
    assertEquals(13, rtx.getNodeKey());
    rtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 17 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class UpdateTest method testSubtreeInsertAsFirstChildSecond.

@Test
public void testSubtreeInsertAsFirstChildSecond() throws SirixException, IOException, XMLStreamException {
    final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    wtx.moveTo(11);
    wtx.insertSubtreeAsFirstChild(XMLShredder.createStringReader(DocumentCreater.XML_WITHOUT_XMLDECL));
    testSubtreeInsertAsFirstChildSecond(wtx);
    wtx.commit();
    wtx.moveTo(14);
    testSubtreeInsertAsFirstChildSecond(wtx);
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    rtx.moveTo(14);
    testSubtreeInsertAsFirstChildSecond(rtx);
    rtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 18 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class UpdateTest method testSecondCopySubtreeAsFirstChild.

@Test
public void testSecondCopySubtreeAsFirstChild() 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.copySubtreeAsFirstChild(rtx);
    testSecondCopySubtreeAsFirstChild(wtx);
    wtx.commit();
    wtx.close();
    rtx = holder.getResourceManager().beginNodeReadTrx();
    testSecondCopySubtreeAsFirstChild(rtx);
    rtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 19 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class UpdateTest method testNodeTransactionIsolation.

@Test
public void testNodeTransactionIsolation() throws SirixException {
    XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    wtx.insertElementAsFirstChild(new QNm(""));
    testNodeTransactionIsolation(wtx);
    wtx.commit();
    testNodeTransactionIsolation(wtx);
    XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    testNodeTransactionIsolation(rtx);
    wtx.moveToFirstChild();
    wtx.insertElementAsFirstChild(new QNm(""));
    testNodeTransactionIsolation(rtx);
    wtx.commit();
    testNodeTransactionIsolation(rtx);
    rtx.close();
    wtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) QNm(org.brackit.xquery.atomic.QNm) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 20 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class UpdateTest method testRemoveDescendant.

/**
 * Test for text concatenation.
 */
@Test
public void testRemoveDescendant() throws SirixException {
    final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    wtx.moveTo(0L);
    // assertEquals(10L, wtx.getDescendantCount());
    wtx.commit();
    assertEquals(10L, wtx.getDescendantCount());
    wtx.moveTo(5L);
    wtx.remove();
    testRemoveDescendant(wtx);
    wtx.commit();
    testRemoveDescendant(wtx);
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    testRemoveDescendant(rtx);
    rtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) 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