01: /* MimetypeUtilsTest
02: *
03: * $Id: MimetypeUtilsTest.java 2556 2004-09-23 02:15:19Z stack-sf $
04: *
05: * Created on Sep 22, 2004
06: *
07: * Copyright (C) 2004 Internet Archive.
08: *
09: * 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 +0000 (Thu, 23 Sep 2004) $, $Revision: 2556 $
32: */
33: public class MimetypeUtilsTest extends TestCase {
34:
35: public void testStraightTruncate() {
36: assertTrue("Straight broken", MimetypeUtils.truncate(
37: "text/html").equals("text/html"));
38: }
39:
40: public void testWhitespaceTruncate() {
41: assertTrue("Null broken", MimetypeUtils.truncate(null).equals(
42: "no-type"));
43: assertTrue("Empty broken", MimetypeUtils.truncate("").equals(
44: "no-type"));
45: assertTrue("Tab broken", MimetypeUtils.truncate(" ").equals(
46: "no-type"));
47: assertTrue("Multispace broken", MimetypeUtils.truncate(" ")
48: .equals("no-type"));
49: assertTrue("NL broken", MimetypeUtils.truncate("\n").equals(
50: "no-type"));
51: }
52:
53: public void testCommaTruncate() {
54: assertTrue("Comma broken", MimetypeUtils.truncate(
55: "text/html,text/html").equals("text/html"));
56: assertTrue("Comma space broken", MimetypeUtils.truncate(
57: "text/html, text/html").equals("text/html"));
58: assertTrue("Charset broken", MimetypeUtils.truncate(
59: "text/html;charset=iso9958-1").equals("text/html"));
60: assertTrue("Charset space broken", MimetypeUtils.truncate(
61: "text/html; charset=iso9958-1").equals("text/html"));
62: assertTrue("dbl text/html space charset broken", MimetypeUtils
63: .truncate("text/html, text/html; charset=iso9958-1")
64: .equals("text/html"));
65: }
66: }
|