Search in sources :

Example 21 with MemoryStore

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

the class SolrBaseTest method setUp.

@Before
public void setUp() throws Exception {
    store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    provider = new TestUtils();
    server = provider.getSolrServer();
    configuration = provider.getConfiguration();
    hook = new EditorHook(new IndexUpdateProvider(new SolrIndexEditorProvider(provider, provider)));
    Oak oak = new Oak().with(new InitialContent()).with(new OpenSecurityProvider()).with(// synchronous
    new SolrIndexInitializer(false)).with(new SolrQueryIndexProvider(provider, provider)).with(new NodeStateSolrServersObserver()).with(new SolrIndexEditorProvider(provider, provider));
    repository = oak.createContentRepository();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) SolrQueryIndexProvider(org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider) NodeStateSolrServersObserver(org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Oak(org.apache.jackrabbit.oak.Oak) SolrIndexInitializer(org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) SolrIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider) Before(org.junit.Before)

Example 22 with MemoryStore

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

the class RecordTest method testBinaryPropertyFromExternalSegmentStore.

@Test
public void testBinaryPropertyFromExternalSegmentStore() throws IOException, CommitFailedException {
    byte[] data = new byte[Segment.MEDIUM_LIMIT + 1];
    random.nextBytes(data);
    SegmentNodeStore extStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    NodeBuilder extRootBuilder = extStore.getRoot().builder();
    Blob extBlob = extRootBuilder.createBlob(new ByteArrayInputStream(data));
    extRootBuilder.setProperty("binary", extBlob, BINARY);
    extStore.merge(extRootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    PropertyState extPropertyState = extStore.getRoot().getProperty("binary");
    NodeBuilder builder = EMPTY_NODE.builder();
    builder.setProperty(extPropertyState);
    NodeState state = writer.writeNode(builder.getNodeState());
    try {
        InputStream is = state.getProperty("binary").getValue(BINARY).getNewStream();
        is.read();
        is.close();
    } catch (SegmentNotFoundException e) {
        fail("OAK-4307 SegmentWriter saves references to external blobs");
    }
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) Blob(org.apache.jackrabbit.oak.api.Blob) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 23 with MemoryStore

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

the class MutableSegmentReferencesTest method referencesShouldBeGreaterThanZero.

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

Example 24 with MemoryStore

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

the class InitializerTest method testInitializerSegment.

@Test
public void testInitializerSegment() throws CommitFailedException, IOException {
    NodeStore store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    NodeBuilder builder = store.getRoot().builder();
    new InitialContent().initialize(builder);
    SecurityProviderImpl provider = new SecurityProviderImpl(ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME, ConfigurationParameters.of(ImmutableMap.of("anonymousId", "anonymous", "adminId", "admin", "usersPath", "/home/users", "groupsPath", "/home/groups", "defaultDepth", "1")))));
    provider.getConfiguration(UserConfiguration.class).getWorkspaceInitializer().initialize(builder, "default");
    builder.getNodeState();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) SecurityProviderImpl(org.apache.jackrabbit.oak.security.SecurityProviderImpl) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 25 with MemoryStore

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

the class MutableSegmentReferencesTest method shouldAddNewSegmentReference.

@Test
public void shouldAddNewSegmentReference() throws Exception {
    MemoryStore store = new MemoryStore();
    SegmentId id = store.getSegmentIdProvider().newDataSegmentId();
    MutableSegmentReferences table = new MutableSegmentReferences();
    int reference = table.addOrReference(id);
    assertEquals(id, table.getSegmentId(reference));
}
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