Search in sources :

Example 26 with DataIdentifier

use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.

the class AzureDataStoreTest method testBackendReadRecordNullIdentifier.

// Read (Backend)
@Test
public void testBackendReadRecordNullIdentifier() throws DataStoreException {
    DataIdentifier identifier = null;
    try {
        backend.read(identifier);
        fail();
    } catch (NullPointerException e) {
        assert ("identifier".equals(e.getMessage()));
    }
}
Also used : DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) Test(org.junit.Test)

Example 27 with DataIdentifier

use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.

the class AzureDataStoreTest method testBackendDeleteRecordInvalidIdentifier.

@Test
public void testBackendDeleteRecordInvalidIdentifier() throws DataStoreException {
    DataIdentifier identifier = new DataIdentifier("fake");
    // We don't care if the identifier is invalid; this is a noop
    backend.deleteRecord(identifier);
}
Also used : DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) Test(org.junit.Test)

Example 28 with DataIdentifier

use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.

the class AzureDataStoreTest method testBackendWriteRecordNullFileThrowsNullPointerException.

@Test
public void testBackendWriteRecordNullFileThrowsNullPointerException() throws DataStoreException {
    File testFile = null;
    DataIdentifier identifier = new DataIdentifier("fake");
    try {
        backend.write(identifier, testFile);
        fail();
    } catch (NullPointerException e) {
        assertTrue("file".equals(e.getMessage()));
    }
}
Also used : DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) FileUtils.copyInputStreamToFile(org.apache.commons.io.FileUtils.copyInputStreamToFile) File(java.io.File) Test(org.junit.Test)

Example 29 with DataIdentifier

use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.

the class AzureDataStoreTest method testBackendReadRecordInvalidIdentifier.

@Test
public void testBackendReadRecordInvalidIdentifier() {
    DataIdentifier identifier = new DataIdentifier("fake");
    try {
        backend.read(identifier);
        fail();
    } catch (DataStoreException e) {
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) Test(org.junit.Test)

Example 30 with DataIdentifier

use of org.apache.jackrabbit.core.data.DataIdentifier in project jackrabbit-oak by apache.

the class AzureDataStoreTest method testCreateAndReUploadBlob.

@Test
public void testCreateAndReUploadBlob() throws DataStoreException, IOException {
    final DataRecord createdRecord = ds.addRecord(new ByteArrayInputStream(testBuffer));
    DataIdentifier identifier1 = createdRecord.getIdentifier();
    assertTrue(backend.exists(identifier1));
    final DataRecord record1 = ds.getRecord(identifier1);
    validateRecord(record1, new String(testBuffer), createdRecord);
    try {
        Thread.sleep(1001);
    } catch (InterruptedException e) {
    }
    final DataRecord updatedRecord = ds.addRecord(new ByteArrayInputStream(testBuffer));
    DataIdentifier identifier2 = updatedRecord.getIdentifier();
    assertTrue(backend.exists(identifier2));
    assertTrue(identifier1.toString().equals(identifier2.toString()));
    validateRecord(record1, new String(testBuffer), createdRecord);
    ds.deleteRecord(identifier1);
    assertFalse(backend.exists(createdRecord.getIdentifier()));
}
Also used : DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) ByteArrayInputStream(java.io.ByteArrayInputStream) DataRecord(org.apache.jackrabbit.core.data.DataRecord) Hex.encodeHexString(org.apache.commons.codec.binary.Hex.encodeHexString) Test(org.junit.Test)

Aggregations

DataIdentifier (org.apache.jackrabbit.core.data.DataIdentifier)60 Test (org.junit.Test)31 DataRecord (org.apache.jackrabbit.core.data.DataRecord)30 File (java.io.File)22 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)16 Hex.encodeHexString (org.apache.commons.codec.binary.Hex.encodeHexString)13 FileInputStream (java.io.FileInputStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ArrayList (java.util.ArrayList)8 FileUtils.copyInputStreamToFile (org.apache.commons.io.FileUtils.copyInputStreamToFile)5 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)4 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)4 IOException (java.io.IOException)4 URISyntaxException (java.net.URISyntaxException)4 RepositoryException (javax.jcr.RepositoryException)4 Function (com.google.common.base.Function)3 StorageException (com.microsoft.azure.storage.StorageException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 SQLException (java.sql.SQLException)3 HashSet (java.util.HashSet)3