use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.
the class AzureDataStoreTest method testListBlobs.
@Test
public void testListBlobs() throws DataStoreException, IOException {
final Set<DataIdentifier> identifiers = Sets.newHashSet();
final Set<String> testStrings = Sets.newHashSet("test1", "test2", "test3");
for (String s : testStrings) {
identifiers.add(ds.addRecord(new ByteArrayInputStream(s.getBytes())).getIdentifier());
}
Iterator<DataIdentifier> iter = ds.getAllIdentifiers();
while (iter.hasNext()) {
DataIdentifier identifier = iter.next();
assertTrue(identifiers.contains(identifier));
ds.deleteRecord(identifier);
}
}
use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.
the class AzureDataStoreTest method testBackendWriteRecordFileNotFoundThrowsException.
@Test
public void testBackendWriteRecordFileNotFoundThrowsException() throws IOException, NoSuchAlgorithmException {
File testFile = folder.newFile();
copyInputStreamToFile(randomStream(0, 10), testFile);
DataIdentifier identifier = new DataIdentifier(getIdForInputStream(new FileInputStream(testFile)));
assertTrue(testFile.delete());
try {
backend.write(identifier, testFile);
fail();
} catch (DataStoreException e) {
assertTrue(e.getCause() instanceof FileNotFoundException);
}
}
use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.
the class AzureDataStoreTest method testBackendWriteRecordNullIdentifierThrowsNullPointerException.
@Test
public void testBackendWriteRecordNullIdentifierThrowsNullPointerException() throws IOException, DataStoreException {
DataIdentifier identifier = null;
File testFile = folder.newFile();
copyInputStreamToFile(randomStream(0, 10), testFile);
try {
backend.write(identifier, testFile);
fail();
} catch (NullPointerException e) {
assertEquals("identifier", e.getMessage());
}
}
use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.
the class CachingDataStoreTest method reference.
@Test
public void reference() throws Exception {
LOG.info("Starting reference");
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
// Record still in staging
DataRecord rec = dataStore.addRecord(fin);
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNotNull(rec);
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
//start & finish
taskLatch.countDown();
callbackLatch.countDown();
waitFinish();
// Now record in download cache
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNotNull(rec);
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
LOG.info("Finished reference");
}
use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.
the class CachingDataStoreTest method syncAddGetDelete.
/**
* Add, get, delete with synchronous option.
* @throws Exception
*/
@Test
public void syncAddGetDelete() throws Exception {
LOG.info("Starting syncAddGetDelete");
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
DataRecord rec = dataStore.addRecord(fin, new BlobOptions().setUpload(SYNCHRONOUS));
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
assertEquals(1, Iterators.size(dataStore.getAllIdentifiers()));
dataStore.deleteRecord(new DataIdentifier(id));
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNull(rec);
LOG.info("Finished syncAddGetDelete");
}
Aggregations