Search in sources :

Example 26 with MemoryStore

use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.

the class MutableSegmentReferencesTest method referencesShouldBeIncrementing.

@Test
public void referencesShouldBeIncrementing() throws Exception {
    MemoryStore store = new MemoryStore();
    SegmentId first = store.getSegmentIdProvider().newDataSegmentId();
    SegmentId second = store.getSegmentIdProvider().newDataSegmentId();
    MutableSegmentReferences table = new MutableSegmentReferences();
    int firstReference = table.addOrReference(first);
    int secondReference = table.addOrReference(second);
    assertEquals(firstReference + 1, secondReference);
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) Test(org.junit.Test)

Example 27 with MemoryStore

use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.

the class MutableSegmentReferencesTest method shouldMaintainSize.

@Test
public void shouldMaintainSize() throws Exception {
    MemoryStore store = new MemoryStore();
    SegmentId id = store.getSegmentIdProvider().newDataSegmentId();
    MutableSegmentReferences table = new MutableSegmentReferences();
    assertEquals(0, table.size());
    table.addOrReference(id);
    assertEquals(1, table.size());
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) Test(org.junit.Test)

Example 28 with MemoryStore

use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.

the class MutableSegmentReferencesTest method shouldIterateInInsertionOrder.

@Test
public void shouldIterateInInsertionOrder() throws Exception {
    MemoryStore store = new MemoryStore();
    SegmentId first = store.getSegmentIdProvider().newDataSegmentId();
    SegmentId second = store.getSegmentIdProvider().newDataSegmentId();
    List<SegmentId> ids = newArrayList(first, second);
    MutableSegmentReferences table = new MutableSegmentReferences();
    table.addOrReference(first);
    table.addOrReference(second);
    assertTrue(elementsEqual(ids, table));
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) Test(org.junit.Test)

Aggregations

MemoryStore (org.apache.jackrabbit.oak.segment.memory.MemoryStore)28 Test (org.junit.Test)15 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)9 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)9 Before (org.junit.Before)7 Oak (org.apache.jackrabbit.oak.Oak)6 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)6 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)4 Session (javax.jcr.Session)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 Callable (java.util.concurrent.Callable)2 Semaphore (java.util.concurrent.Semaphore)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Node (javax.jcr.Node)2 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)2 InitialContent (org.apache.jackrabbit.oak.InitialContent)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1