01: /*
02: * Copyright 2003-2005 Michael Franken, Zilverline.
03: *
04: * The contents of this file, or the files included with this file, are subject to
05: * the current version of ZILVERLINE Collaborative Source License for the
06: * Zilverline Search Engine (the "License"); You may not use this file except in
07: * compliance with the License.
08: *
09: * You may obtain a copy of the License at
10: *
11: * http://www.zilverline.org.
12: *
13: * See the License for the rights, obligations and
14: * limitations governing use of the contents of the file.
15: *
16: * The Original and Upgraded Code is the Zilverline Search Engine. The developer of
17: * the Original and Upgraded Code is Michael Franken. Michael Franken owns the
18: * copyrights in the portions it created. All Rights Reserved.
19: *
20: */
21:
22: package org.zilverline.extractors;
23:
24: import java.io.File;
25: import java.io.FileInputStream;
26: import java.io.FileNotFoundException;
27: import java.io.InputStream;
28:
29: import junit.framework.TestCase;
30:
31: import org.apache.commons.logging.Log;
32: import org.apache.commons.logging.LogFactory;
33:
34: import org.zilverline.core.ParsedFileInfo;
35:
36: /**
37: * TestFileInfoExtractor.
38: *
39: * @author Michael Franken
40: */
41: public class TestFileInfoExtractor extends TestCase {
42: /** logger for Commons logging. */
43: private static Log log = LogFactory
44: .getLog(TestFileInfoExtractor.class);
45:
46: public void testGetContent() {
47: FileInfoExtractor tex = new FileInfoExtractor();
48: File file = new File("test\\data\\test.xls");
49: ParsedFileInfo pfi = tex.extractInfo(file);
50: assertNotNull(pfi);
51: assertEquals("FILE", pfi.getType());
52: assertEquals("test", pfi.getTitle());
53: assertNotNull(pfi.getFile());
54: assertTrue(pfi.getSize() > 0);
55: assertTrue("".equals(pfi.getSummary()));
56: assertTrue(pfi.getReader() == null);
57: }
58:
59: public void testGetContentAsInputStream() {
60: try {
61: FileInfoExtractor tex = new FileInfoExtractor();
62: InputStream is = new FileInputStream("test\\data\\test.xls");
63: String txt = tex.getContent(is);
64: assertTrue("".equals(txt));
65: } catch (FileNotFoundException e) {
66: fail(e.getMessage());
67: }
68: }
69: }
|