1 31 32 package org.opencms.search.extractors; 33 34 import java.io.InputStream ; 35 import java.util.Map ; 36 37 import junit.framework.TestCase; 38 39 42 public class TestMsExcelExtraction extends TestCase { 43 44 49 public TestMsExcelExtraction(String arg0) { 50 51 super(arg0); 52 } 53 54 59 public void testBasicExcelExtration() throws Exception { 60 61 InputStream in = getClass().getClassLoader().getResourceAsStream("org/opencms/search/extractors/test1.xls"); 63 64 I_CmsExtractionResult extractionResult = CmsExtractorMsExcel.getExtractor().extractText(in); 66 String result = extractionResult.getContent(); 67 68 System.out.println("---------------------------------------------------------------"); 69 System.out.println("Extracted from MS Excel:"); 70 System.out.println(result); 71 72 assertTrue(result.indexOf("Alkacon Software") > -1); 73 assertTrue(result.indexOf("The OpenCms experts") > -1); 74 assertTrue(result.indexOf("Some content here.") > -1); 75 assertTrue(result.indexOf("Some content there.") > -1); 76 assertTrue(result.indexOf("Some content on a second sheet.") > -1); 77 assertTrue(result.indexOf("Some content on the third sheet.") > -1); 78 assertTrue(result.indexOf("\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df\u20ac") > -1); 79 80 Map meta = extractionResult.getMetaInfo(); 81 assertEquals("Alkacon Software - The OpenCms experts", meta.get(I_CmsExtractionResult.META_TITLE)); 82 assertEquals("This is the subject", meta.get(I_CmsExtractionResult.META_SUBJECT)); 83 assertEquals("Alexander Kandzior", meta.get(I_CmsExtractionResult.META_AUTHOR)); 84 assertEquals("Alkacon Software", meta.get(I_CmsExtractionResult.META_COMPANY)); 85 assertEquals("This is the comment", meta.get(I_CmsExtractionResult.META_COMMENTS)); 86 assertEquals("Key1, Key2", meta.get(I_CmsExtractionResult.META_KEYWORDS)); 87 } 88 } | Popular Tags |