KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > search > extractors > TestMsPowerPointExtraction


1 /*
2  * File : $Source: /usr/local/cvs/opencms/test/org/opencms/search/extractors/TestMsPowerPointExtraction.java,v $
3  * Date : $Date: 2005/06/23 11:12:02 $
4  * Version: $Revision: 1.5 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.search.extractors;
33
34 import java.io.InputStream JavaDoc;
35 import java.util.Map JavaDoc;
36
37 import junit.framework.TestCase;
38
39 /**
40  * Tests the text extraction form a Pdf file.<p>
41  */

42 public class TestMsPowerPointExtraction extends TestCase {
43
44     /**
45      * Default JUnit constructor.<p>
46      *
47      * @param arg0 JUnit parameters
48      */

49     public TestMsPowerPointExtraction(String JavaDoc arg0) {
50
51         super(arg0);
52     }
53
54     /**
55      * Tests the basic Pdf extraction.<p>
56      *
57      * @throws Exception if the test fails
58      */

59     public void testBasicPPtExtration() throws Exception JavaDoc {
60
61         // open an input stream for the test file
62
InputStream JavaDoc in = getClass().getClassLoader().getResourceAsStream("org/opencms/search/extractors/test1.ppt");
63
64         // extract the content
65
I_CmsExtractionResult extractionResult = CmsExtractorMsPowerPoint.getExtractor().extractText(in);
66         String JavaDoc result = extractionResult.getContent();
67         
68         System.out.println("---------------------------------------------------------------");
69         System.out.println("Extracted from MS PowerPoint:");
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         // NOTE: Euro symbol conversion fails - possible reason is that extration method class handles only ISO
79
// this is ""
80
assertTrue(result.indexOf("\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df") > -1);
81         
82         Map JavaDoc meta = extractionResult.getMetaInfo();
83         assertEquals("Alkacon Software - The OpenCms experts", meta.get(I_CmsExtractionResult.META_TITLE));
84         assertEquals("This is the subject", meta.get(I_CmsExtractionResult.META_SUBJECT));
85         assertEquals("Alexander Kandzior", meta.get(I_CmsExtractionResult.META_AUTHOR));
86         assertEquals("Alkacon Software", meta.get(I_CmsExtractionResult.META_COMPANY));
87         assertEquals("This is the comment", meta.get(I_CmsExtractionResult.META_COMMENTS));
88         assertEquals("Key1, Key2", meta.get(I_CmsExtractionResult.META_KEYWORDS));
89     }
90 }
Popular Tags