1 package org.sapia.soto.state.util; 2 3 import junit.framework.TestCase; 4 5 6 15 public class StateIdParserTest extends TestCase { 16 public StateIdParserTest(String name) { 17 super(name); 18 } 19 20 public void testDefault() { 21 super.assertTrue(StateIdParser.parseStateFrom("", null) == null); 22 super.assertTrue(StateIdParser.parseStateFrom("/", null) == null); 23 } 24 25 public void testParseExtensionNoModule() { 26 StateIdParser.Created c = StateIdParser.parseStateFrom("/foo/bar/state.asp", 27 "asp"); 28 super.assertEquals("foo/bar/state", c.state); 29 super.assertTrue(c.module == null); 30 c = StateIdParser.parseStateFrom("state.asp", "asp"); 31 super.assertEquals("state", c.state); 32 super.assertTrue(c.module == null); 33 } 34 35 public void testParseExtensionWithModule() { 36 StateIdParser.Created c = StateIdParser.parseStateFrom("/foo/bar/module.state.asp", 37 "asp"); 38 super.assertEquals("foo/bar/state", c.state); 39 super.assertEquals("module", c.module); 40 c = StateIdParser.parseStateFrom("module.state.asp", "asp"); 41 super.assertEquals("state", c.state); 42 super.assertEquals("module", c.module); 43 } 44 45 public void testParseNoExtension() { 46 StateIdParser.Created c = StateIdParser.parseStateFrom("/foo/bar/state.asp", 47 null); 48 super.assertEquals("foo/bar/asp", c.state); 49 super.assertEquals("state", c.module); 50 } 51 52 public void testParseNoExtensionWithModule() { 53 StateIdParser.Created c = StateIdParser.parseStateFrom("/foo/bar/module.state", 54 null); 55 super.assertEquals("foo/bar/state", c.state); 56 super.assertEquals("module", c.module); 57 c = StateIdParser.parseStateFrom("module.state", null); 58 super.assertEquals("state", c.state); 59 super.assertEquals("module", c.module); 60 } 61 } 62 | Popular Tags |