Search in sources :

Example 36 with XdmNodeReadTrx

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

the class UpdateTest method testFirstMoveSubtreeToRightSibling.

@Test
public void testFirstMoveSubtreeToRightSibling() throws SirixException {
    final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    wtx.moveToDocumentRoot();
    for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
        System.out.println(nodeKey + ": " + wtx.getDeweyID());
    }
    wtx.moveTo(7);
    wtx.moveSubtreeToRightSibling(6);
    testFirstMoveSubtreeToRightSibling(wtx);
    wtx.moveToDocumentRoot();
    for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
        System.out.println(nodeKey + ": " + wtx.getDeweyID());
    }
    wtx.commit();
    wtx.moveToDocumentRoot();
    for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
        System.out.println(nodeKey + ": " + wtx.getDeweyID());
    }
    testFirstMoveSubtreeToRightSibling(wtx);
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    testFirstMoveSubtreeToRightSibling(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.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.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)

Example 37 with XdmNodeReadTrx

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

the class XdmResourceManagerTest method testIdempotentClose.

@Test
public void testIdempotentClose() {
    final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
    DocumentCreater.create(wtx);
    wtx.commit();
    wtx.close();
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    assertEquals(false, rtx.moveTo(14L).hasMoved());
    rtx.close();
    rtx.close();
    holder.getResourceManager().close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 38 with XdmNodeReadTrx

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

the class AncestorAxisTest method testAxisConventions.

@Test
public void testAxisConventions() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    rtx.moveTo(12L);
    AbsAxisTest.testIAxisConventions(new AncestorAxis(rtx), new long[] { 9L, 1L });
    rtx.moveTo(4L);
    AbsAxisTest.testIAxisConventions(new AncestorAxis(rtx), new long[] { 1L });
    rtx.moveTo(5L);
    AbsAxisTest.testIAxisConventions(new AncestorAxis(rtx), new long[] { 1L });
    rtx.moveTo(1L);
    AbsAxisTest.testIAxisConventions(new AncestorAxis(rtx), new long[] {});
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 39 with XdmNodeReadTrx

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

the class AncestorAxisTest method testAxisConventionsIncludingSelf.

@Test
public void testAxisConventionsIncludingSelf() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    rtx.moveTo(11L);
    AbsAxisTest.testIAxisConventions(new AncestorAxis(rtx, IncludeSelf.YES), new long[] { 11L, 9L, 1L });
    rtx.moveTo(5L);
    AbsAxisTest.testIAxisConventions(new AncestorAxis(rtx, IncludeSelf.YES), new long[] { 5L, 1L });
    rtx.moveTo(4L);
    AbsAxisTest.testIAxisConventions(new AncestorAxis(rtx, IncludeSelf.YES), new long[] { 4L, 1L });
    rtx.moveTo(1L);
    AbsAxisTest.testIAxisConventions(new AncestorAxis(rtx, IncludeSelf.YES), new long[] { 1L });
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 40 with XdmNodeReadTrx

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

the class AttributeAxisTest method testIterate.

@Test
public void testIterate() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    rtx.moveToDocumentRoot();
    AbsAxisTest.testIAxisConventions(new AttributeAxis(rtx), new long[] {});
    rtx.moveTo(1L);
    AbsAxisTest.testIAxisConventions(new AttributeAxis(rtx), new long[] { 3L });
    rtx.moveTo(9L);
    AbsAxisTest.testIAxisConventions(new AttributeAxis(rtx), new long[] { 10L });
    rtx.moveTo(12L);
    AbsAxisTest.testIAxisConventions(new AttributeAxis(rtx), new long[] {});
    rtx.moveTo(2L);
    AbsAxisTest.testIAxisConventions(new AttributeAxis(rtx), new long[] {});
}
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