1 25 package org.archive.util; 26 27 import junit.framework.TestCase; 28 29 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 |