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" });
}
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"));
}
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")));
}
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));
}
Aggregations