KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > state > util > StateIdParserTest


1 package org.sapia.soto.state.util;
2
3 import junit.framework.TestCase;
4
5
6 /**
7  * @author Yanick Duchesne
8  *
9  * <dl>
10  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
11  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
12  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
13  * </dl>
14  */

15 public class StateIdParserTest extends TestCase {
16   public StateIdParserTest(String JavaDoc 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