1   
2   /*
3    * SmartCrawler
4    *
5    * $Id: MimeTypeTranslatorTest.java,v 1.2 2005/07/14 13:42:29 vincool Exp $
6    * Copyright 2005 Davide Pozza
7    *
8    * This program is free software; you can redistribute it
9    * and/or modify it under the terms of the GNU General Public
10   * License as published by the Free Software Foundation;
11   * either version 2 of the License, or (at your option) any
12   * later version.
13   *
14   * This program is distributed in the hope that it will be
15   * useful, but WITHOUT ANY WARRANTY; without even the implied
16   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17   * PURPOSE. See the GNU General Public License for more
18   * details.
19   *
20   * You should have received a copy of the GNU General Public
21   * License along with this program; if not, write to the Free
22   * Software Foundation, Inc., 59 Temple Place, Suite 330,
23   * Boston, MA 02111-1307 USA
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 }