Search in sources :

Example 6 with FileContentReader

use of org.alfresco.repo.content.filestore.FileContentReader in project records-management by Alfresco.

the class EagerContentStoreCleanerUnitTest method contentRequiresCleaning.

/**
 * Given that the content requires cleansing
 * When the content is deleted from the store
 * Then the content is cleansed first
 */
@Test
public void contentRequiresCleaning() {
    String contentURL = AlfMock.generateText();
    Set<Object> mockedSet = new HashSet<Object>(Arrays.asList(contentURL));
    when(mockedTransactionalResourceHelper.getSet(EagerContentStoreCleaner.KEY_POST_COMMIT_CLEANSING_URLS)).thenReturn(mockedSet);
    FileContentReader mockedReader = mock(FileContentReader.class);
    when(mockedReader.exists()).thenReturn(true);
    File mockedFile = mock(File.class);
    when(mockedReader.getFile()).thenReturn(mockedFile);
    ContentStore mockedContentStore = mock(ContentStore.class);
    when(mockedContentStore.getReader(contentURL)).thenReturn(mockedReader);
    eagerContentStoreCleaner.deleteFromStore(contentURL, mockedContentStore);
    verify(mockedContentCleanser).cleanse(mockedFile);
}
Also used : FileContentReader(org.alfresco.repo.content.filestore.FileContentReader) File(java.io.File) HashSet(java.util.HashSet) ContentStore(org.alfresco.repo.content.ContentStore) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Aggregations

FileContentReader (org.alfresco.repo.content.filestore.FileContentReader)6 File (java.io.File)3 ContentReader (org.alfresco.service.cmr.repository.ContentReader)3 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 QName (org.alfresco.service.namespace.QName)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 ExternalContext (javax.faces.context.ExternalContext)1 FacesContext (javax.faces.context.FacesContext)1 ResponseWriter (javax.faces.context.ResponseWriter)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)1 ContentStore (org.alfresco.repo.content.ContentStore)1 ServiceRegistry (org.alfresco.service.ServiceRegistry)1 FileInfo (org.alfresco.service.cmr.model.FileInfo)1 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)1