1 17 package org.alfresco.repo.content.filestore; 18 19 import java.io.File ; 20 21 import org.alfresco.repo.content.AbstractContentReadWriteTest; 22 import org.alfresco.repo.content.ContentStore; 23 import org.alfresco.repo.content.MimetypeMap; 24 import org.alfresco.service.cmr.repository.ContentReader; 25 import org.alfresco.util.TempFileProvider; 26 27 34 public class FileContentStoreTest extends AbstractContentReadWriteTest 35 { 36 private FileContentStore store; 37 38 @Override 39 public void setUp() throws Exception 40 { 41 super.setUp(); 42 43 File tempDir = TempFileProvider.getTempDir(); 45 store = new FileContentStore( 46 tempDir.getAbsolutePath() + 47 File.separatorChar + 48 getName()); 49 } 50 51 @Override 52 protected ContentStore getStore() 53 { 54 return store; 55 } 56 57 public void testGetSafeContentReader() throws Exception 58 { 59 String template = "ABC {0}{1}"; 60 String arg0 = "DEF"; 61 String arg1 = "123"; 62 String fakeContent = "ABC DEF123"; 63 64 ContentReader reader = getReader(); 66 assertFalse("No content has been written to the URL yet", reader.exists()); 67 68 File file = store.createNewFile(reader.getContentUrl()); 70 assertTrue("File store did not connect new file", file.exists()); 71 assertTrue("Reader did not detect creation of the underlying file", reader.exists()); 72 73 file.delete(); 75 assertFalse("File not missing", file.exists()); 76 assertFalse("Reader doesn't show missing content", reader.exists()); 77 78 ContentReader safeReader = FileContentReader.getSafeContentReader(reader, template, arg0, arg1); 80 assertTrue("Fake content doesn't exist", safeReader.exists()); 82 assertEquals("Fake content incorrect", fakeContent, safeReader.getContentString()); 83 assertEquals("Fake mimetype incorrect", MimetypeMap.MIMETYPE_TEXT_PLAIN, safeReader.getMimetype()); 84 assertEquals("Fake encoding incorrect", "UTF-8", safeReader.getEncoding()); 85 86 reader = null; 88 safeReader = FileContentReader.getSafeContentReader(reader, template, arg0, arg1); 89 assertTrue("Fake content doesn't exist", safeReader.exists()); 91 assertEquals("Fake content incorrect", fakeContent, safeReader.getContentString()); 92 } 93 } 94 | Popular Tags |