CachingContentStore handles "spoof://" content URLs (ACE-4516:DataLoad file spoofing fails with S3 connector)

- Any store can now be used with the spoofed data load by wrapping it in the CachingContentStore (see S3 Connector)
 - Will work with S3 Connector against Alfresco 5.1


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@115382 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2015-10-27 18:28:04 +00:00
parent 846ea639b0
commit b6aa21f5f0
3 changed files with 74 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
@@ -40,6 +41,7 @@ import org.alfresco.repo.content.ContentContext;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.content.caching.quota.QuotaManagerStrategy;
import org.alfresco.repo.content.caching.quota.UnlimitedQuotaStrategy;
import org.alfresco.repo.content.filestore.SpoofedTextContentReader;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentStreamListener;
@@ -371,6 +373,41 @@ public class CachingContentStoreTest
verify(bsWriter).setMimetype("not/real/mimetype");
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests for spoofed content follow...
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test
public void spoofedGetReader()
{
cachingStore = new CachingContentStore(backingStore, cache, true);
String url = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 0L, 1024L);
ContentReader reader = cachingStore.getReader(url);
assertTrue(reader.exists());
assertEquals(1024, reader.getSize());
verify(backingStore, never()).getReader(anyString());
}
@Test
public void spoofedDelete()
{
cachingStore = new CachingContentStore(backingStore, cache, true);
String url = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 0L, 1024L);
boolean deleted = cachingStore.delete(url);
assertFalse(deleted);
verify(backingStore, never()).delete(anyString());
}
@Test
public void spoofedExists()
{
cachingStore = new CachingContentStore(backingStore, cache, true);
String url = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 0L, 1024L);
boolean exists = cachingStore.exists(url);
assertTrue(exists);
verify(backingStore, never()).exists(anyString());
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests for delegated methods follow...
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////