KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > archive > util > MimetypeUtilsTest


1 /* MimetypeUtilsTest
2  *
3  * $Id: MimetypeUtilsTest.java,v 1.1 2004/09/23 02:15:19 stack-sf Exp $
4  *
5  * Created on Sep 22, 2004
6  *
7  * Copyright (C) 2004 Internet Archive.
8  *
9  * This file is part of the Heritrix web crawler (crawler.archive.org).
10  *
11  * Heritrix is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser Public License as published by
13  * the Free Software Foundation; either version 2.1 of the License, or
14  * any later version.
15  *
16  * Heritrix 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
19  * GNU Lesser Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser Public License
22  * along with Heritrix; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  */

25 package org.archive.util;
26
27 import junit.framework.TestCase;
28
29 /**
30  * @author stack
31  * @version $Date: 2004/09/23 02:15:19 $, $Revision: 1.1 $
32  */

33 public class MimetypeUtilsTest extends TestCase {
34
35     public void testStraightTruncate() {
36         assertTrue("Straight broken",
37             MimetypeUtils.truncate("text/html").equals("text/html"));
38     }
39     
40     public void testWhitespaceTruncate() {
41         assertTrue("Null broken",
42             MimetypeUtils.truncate(null).equals("no-type"));
43         assertTrue("Empty broken",
44                 MimetypeUtils.truncate("").equals("no-type"));
45         assertTrue("Tab broken",
46                 MimetypeUtils.truncate(" ").equals("no-type"));
47         assertTrue("Multispace broken",
48                 MimetypeUtils.truncate(" ").equals("no-type"));
49         assertTrue("NL broken",
50                 MimetypeUtils.truncate("\n").equals("no-type"));
51     }
52     
53     public void testCommaTruncate() {
54         assertTrue("Comma broken",
55             MimetypeUtils.truncate("text/html,text/html").equals("text/html"));
56         assertTrue("Comma space broken",
57             MimetypeUtils.truncate("text/html, text/html").
58                 equals("text/html"));
59         assertTrue("Charset broken",
60             MimetypeUtils.truncate("text/html;charset=iso9958-1").
61                 equals("text/html"));
62         assertTrue("Charset space broken",
63             MimetypeUtils.truncate("text/html; charset=iso9958-1").
64                 equals("text/html"));
65         assertTrue("dbl text/html space charset broken", MimetypeUtils.
66             truncate("text/html, text/html; charset=iso9958-1").
67                 equals("text/html"));
68     }
69 }
70
Popular Tags