1 17 18 package javax.activation; 24 25 import junit.framework.TestCase; 26 27 30 public class MailcapCommandMapTest extends TestCase { 31 private MailcapCommandMap map; 32 33 public void testAdd() { 34 map.addMailcap("foo/bar ;; x-java-view=Foo; x-java-edit=Bar"); 35 CommandInfo info = map.getCommand("foo/bar", "view"); 36 assertEquals("view", info.getCommandName()); 37 assertEquals("Foo", info.getCommandClass()); 38 info = map.getCommand("foo/bar", "edit"); 39 assertEquals("edit", info.getCommandName()); 40 assertEquals("Bar", info.getCommandClass()); 41 } 42 43 public void testExplicitWildcard() { 44 map.addMailcap("foo/bar ;; x-java-view=Bar"); 45 map.addMailcap("foo/* ;; x-java-view=Star"); 46 CommandInfo info = map.getCommand("foo/bar", "view"); 47 assertEquals("view", info.getCommandName()); 48 assertEquals("Bar", info.getCommandClass()); 49 info = map.getCommand("foo/foo", "view"); 50 assertEquals("view", info.getCommandName()); 51 assertEquals("Star", info.getCommandClass()); 52 info = map.getCommand("foo/*", "view"); 53 assertEquals("view", info.getCommandName()); 54 assertEquals("Star", info.getCommandClass()); 55 info = map.getCommand("foo", "view"); 56 assertEquals("view", info.getCommandName()); 57 assertEquals("Star", info.getCommandClass()); 58 } 59 60 public void testImplicitWildcard() { 61 map.addMailcap("foo/bar ;; x-java-view=Bar"); 62 map.addMailcap("foo ;; x-java-view=Star"); 63 CommandInfo info = map.getCommand("foo/bar", "view"); 64 assertEquals("view", info.getCommandName()); 65 assertEquals("Bar", info.getCommandClass()); 66 info = map.getCommand("foo/foo", "view"); 67 assertEquals("view", info.getCommandName()); 68 assertEquals("Star", info.getCommandClass()); 69 info = map.getCommand("foo", "view"); 70 assertEquals("view", info.getCommandName()); 71 assertEquals("Star", info.getCommandClass()); 72 } 73 74 public void testParameterizedMimeType() { 75 map.addMailcap("foo/bar ;; x-java-view=Bar"); 76 CommandInfo info = map.getCommand("foo/bar ; type=\"text/plain\"", "view"); 77 assertEquals("view", info.getCommandName()); 78 assertEquals("Bar", info.getCommandClass()); 79 } 80 81 protected void setUp() throws Exception { 82 super.setUp(); 83 map = new MailcapCommandMap(); 84 } 85 } 86 | Popular Tags |