Search in sources :

Example 61 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.

the class SegmentParserTest method fixtures.

@Parameterized.Parameters(name = "{1}")
public static Collection<Object[]> fixtures() throws Exception {
    BlobStore shortIdBlobStore = mock(BlobStore.class);
    when(shortIdBlobStore.writeBlob(any())).thenReturn("shortId");
    BlobStore longIdBlobStore = mock(BlobStore.class);
    when(longIdBlobStore.writeBlob(any())).thenReturn(Strings.repeat("shortId", 1000));
    return newArrayList(new Object[] { null, "No BlobStore" }, new Object[] { shortIdBlobStore, "Short Id BlobStore" }, new Object[] { longIdBlobStore, "Long Id BlobStore" });
}
Also used : BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore)

Example 62 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.

the class DefaultStandbyBlobReaderTest method shouldReturnNegativeLengthIfBlobIsUnreadable.

@Test
public void shouldReturnNegativeLengthIfBlobIsUnreadable() throws Exception {
    BlobStore s = mock(BlobStore.class);
    when(s.getBlobLength("id")).thenReturn(-1L);
    DefaultStandbyBlobReader r = new DefaultStandbyBlobReader(s);
    assertEquals(-1L, r.getBlobLength("id"));
}
Also used : BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) Test(org.junit.Test)

Example 63 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.

the class DefaultStandbyBlobReaderTest method shouldReturnBlobContent.

@Test
public void shouldReturnBlobContent() throws Exception {
    BlobStore s = mock(BlobStore.class);
    when(s.getInputStream("id")).thenReturn(new ByteArrayInputStream(new byte[] { 1, 2, 3 }));
    when(s.getBlobLength("id")).thenReturn(3L);
    DefaultStandbyBlobReader r = new DefaultStandbyBlobReader(s);
    assertEquals(3, r.getBlobLength("id"));
    assertArrayEquals(new byte[] { 1, 2, 3 }, IOUtils.toByteArray(r.readBlob("id")));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) Test(org.junit.Test)

Example 64 with BlobStore

use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-filevault by apache.

the class IntegrationTestBase method initRepository.

/**
 * @param isOak {@code true} in case IT should run against Oak, otherwise runs again JR2
 * @param useFileStore only evaluated for Oak. Optionally uses a dedicated BlobStore with Oak
 * @throws RepositoryException
 * @throws IOException
 * @throws InvalidFileStoreVersionException
 */
public static void initRepository(boolean isOak, boolean useFileStore) throws RepositoryException, IOException, InvalidFileStoreVersionException {
    if (isOak) {
        Jcr jcr;
        if (useFileStore) {
            BlobStore blobStore = createBlobStore();
            DIR_OAK_FILE_STORE.mkdirs();
            fileStore = FileStoreBuilder.fileStoreBuilder(DIR_OAK_FILE_STORE).withBlobStore(blobStore).build();
            SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
            jcr = new Jcr(nodeStore);
        } else {
            // in-memory repo
            jcr = new Jcr();
        }
        repository = jcr.with(createSecurityProvider()).withAtomicCounter().createRepository();
        // setup default read ACL for everyone
        Session admin = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
        AccessControlUtils.addAccessControlEntry(admin, "/", EveryonePrincipal.getInstance(), new String[] { "jcr:read" }, true);
        admin.save();
        admin.logout();
    } else {
        try (InputStream in = IntegrationTestBase.class.getResourceAsStream("repository.xml")) {
            RepositoryConfig cfg = RepositoryConfig.create(in, DIR_JR2_REPO_HOME.getPath());
            repository = RepositoryImpl.create(cfg);
        }
    }
    log.info("repository created: {} {}", repository.getDescriptor(Repository.REP_NAME_DESC), repository.getDescriptor(Repository.REP_VERSION_DESC));
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) SimpleCredentials(javax.jcr.SimpleCredentials) InputStream(java.io.InputStream) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Aggregations

BlobStore (org.apache.jackrabbit.oak.spi.blob.BlobStore)64 Test (org.junit.Test)32 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)19 File (java.io.File)17 GarbageCollectableBlobStore (org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore)16 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)12 IOException (java.io.IOException)11 DataStoreUtils.getBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreUtils.getBlobStore)11 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DataStore (org.apache.jackrabbit.core.data.DataStore)5 InputStream (java.io.InputStream)4 Parameters (junitparams.Parameters)4 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)4 MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)4 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 Before (org.junit.Before)4 Closer (com.google.common.io.Closer)3 ArrayList (java.util.ArrayList)3 RepositoryException (javax.jcr.RepositoryException)3 BlobAccessProvider (org.apache.jackrabbit.oak.api.blob.BlobAccessProvider)3