Search in sources :

Example 31 with XdmNodeReadTrx

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

the class UpdateTest method testFirstCopySubtreeAsFirstChild.

@Test
public void testFirstCopySubtreeAsFirstChild() throws SirixException {
    // Test for one node.
    XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    wtx.commit();
    wtx.close();
    XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    rtx.moveTo(4);
    wtx = holder.getResourceManager().beginNodeWriteTrx();
    wtx.moveTo(9);
    wtx.copySubtreeAsFirstChild(rtx);
    testFirstCopySubtreeAsFirstChild(wtx);
    wtx.commit();
    wtx.close();
    rtx = holder.getResourceManager().beginNodeReadTrx();
    testFirstCopySubtreeAsFirstChild(rtx);
    rtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 32 with XdmNodeReadTrx

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

the class UpdateTest method testRemoveDescendantTextConcat2.

/**
 * Test for text concatenation.
 */
@Test
public void testRemoveDescendantTextConcat2() throws SirixException {
    final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    wtx.commit();
    wtx.moveTo(9L);
    wtx.remove();
    wtx.moveTo(5L);
    wtx.remove();
    testRemoveDescendantTextConcat2(wtx);
    wtx.commit();
    testRemoveDescendantTextConcat2(wtx);
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    testRemoveDescendantTextConcat2(rtx);
    rtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 33 with XdmNodeReadTrx

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

the class UpdateTest method testInsert.

@Test
public void testInsert() throws SirixException {
    final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    testInsert(wtx);
    wtx.commit();
    testInsert(wtx);
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    testInsert(rtx);
    rtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 34 with XdmNodeReadTrx

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

the class UpdateTest method testSubtreeInsertAsRightSibling.

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

Example 35 with XdmNodeReadTrx

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

the class UpdateTest method testFirstMoveToFirstChild.

@Test
public void testFirstMoveToFirstChild() throws SirixException {
    final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    wtx.moveTo(7);
    wtx.moveSubtreeToFirstChild(6);
    testFirstMoveToFirstChild(wtx);
    wtx.commit();
    testFirstMoveToFirstChild(wtx);
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    testFirstMoveToFirstChild(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.5")).add(new SirixDeweyID("1.3.5.5.3")).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();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) NonStructuralWrapperAxis(org.sirix.axis.NonStructuralWrapperAxis) SirixDeweyID(org.sirix.node.SirixDeweyID) DescendantAxis(org.sirix.axis.DescendantAxis) 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