1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.smartcrawler.extractor;
28
29 import junit.framework.*;
30
31 /***
32 * The engine thread which is started by the {@link org.smartcrawler.Crawler}
33 *
34 * @author <a href="mailto:pozzad@alice.it">Davide Pozza</a>
35 * @version <tt>$Revision: 1.2 $</tt>
36 */
37 public class MimeTypeTranslatorTest extends TestCase {
38
39 /***
40 *
41 * @param testName
42 */
43 public MimeTypeTranslatorTest(String testName) {
44 super(testName);
45 }
46
47 /***
48 *
49 * @throws java.lang.Exception
50 */
51 protected void setUp() throws Exception {
52 }
53
54 /***
55 *
56 * @throws java.lang.Exception
57 */
58 protected void tearDown() throws Exception {
59 }
60
61 /***
62 *
63 * @return
64 */
65 public static Test suite() {
66 TestSuite suite = new TestSuite(MimeTypeTranslatorTest.class);
67
68 return suite;
69 }
70
71 /***
72 * Test of getMimeType method, of class org.smartcrawler.extractor.MimeTypeTranslator.
73 */
74 public void testGetMimeType() {
75 System.out.println("testGetMimeType");
76 String mime = null;
77 try {
78 mime = MimeTypeTranslator.getMimeType("htm");
79 } catch (Exception e) {
80 fail(e.getMessage());
81 }
82 String expected = "text/html";
83
84 String actual = mime;
85 System.out.println("exp=" + expected);
86 System.out.println("act=" + actual);
87 assertEquals("MimeTypeTranslator.getMimeType(\"htm\")", expected, actual);
88 }
89
90 /***
91 * Test of getFileExtension method, of class org.smartcrawler.extractor.MimeTypeTranslator.
92 */
93 public void testGetFileExtension() {
94 System.out.println("testGetFileExtension");
95 String ext = null;
96 try {
97 ext = MimeTypeTranslator.getFileExtension("text/html; charset=ISO-8859-1");
98 } catch (Exception e) {
99 fail(e.getMessage());
100 }
101 String expected = "html";
102
103 String actual = ext;
104 System.out.println("exp=" + expected);
105 System.out.println("act=" + actual);
106 assertEquals("MimeTypeTranslator.getFileExtension(\"text/html; charset=ISO-8859-1\")", expected, actual);
107 }
108
109 }