1 17 package org.alfresco.repo.content.transform; 18 19 import java.io.File ; 20 import java.io.InputStream ; 21 22 import org.alfresco.repo.content.MimetypeMap; 23 import org.alfresco.repo.content.filestore.FileContentWriter; 24 import org.alfresco.service.cmr.repository.ContentReader; 25 import org.alfresco.util.TempFileProvider; 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 34 public class PoiHssfContentTransformerTest extends AbstractContentTransformerTest 35 { 36 private static final Log logger = LogFactory.getLog(PoiHssfContentTransformerTest.class); 37 38 private ContentTransformer transformer; 39 40 public void onSetUpInTransaction() throws Exception 41 { 42 transformer = new PoiHssfContentTransformer(); 43 } 44 45 48 protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) 49 { 50 return transformer; 51 } 52 53 public void testReliability() throws Exception 54 { 55 double reliability = 0.0; 56 reliability = transformer.getReliability(MimetypeMap.MIMETYPE_TEXT_PLAIN, MimetypeMap.MIMETYPE_EXCEL); 57 assertEquals("Mimetype should not be supported", 0.0, reliability); 58 reliability = transformer.getReliability(MimetypeMap.MIMETYPE_EXCEL, MimetypeMap.MIMETYPE_TEXT_PLAIN); 59 assertEquals("Mimetype should be supported", 1.0, reliability); 60 } 61 62 65 public void xtestBugFixAR114() throws Exception 66 { 67 File tempFile = TempFileProvider.createTempFile( 68 getClass().getSimpleName() + "_" + getName() + "_", 69 ".xls"); 70 FileContentWriter writer = new FileContentWriter(tempFile); 71 writer.setMimetype(MimetypeMap.MIMETYPE_EXCEL); 72 InputStream is = getClass().getClassLoader().getResourceAsStream("Plan270904b.xls"); 74 assertNotNull("Test resource not found: Plan270904b.xls"); 75 writer.putContent(is); 76 77 ContentReader reader = writer.getReader(); 79 80 tempFile = TempFileProvider.createTempFile( 82 getClass().getSimpleName() + "_" + getName() + "_", 83 ".txt"); 84 writer = new FileContentWriter(tempFile); 85 writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); 86 87 transformer.transform(reader, writer); 89 } 90 } 91 | Popular Tags |