KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > controller > form > test > FormURLToolsTest


1 /*
2  * Copyright (c) 2003-2004, Inversoft, All Rights Reserved
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.controller.form.test;
8
9
10 import junit.framework.TestCase;
11
12 import com.inversoft.verge.mvc.controller.form.FormURLTools;
13
14
15 /**
16  * <p>
17  * This class tests the form URL tools.
18  * </p>
19  *
20  * @author Brian Pontarelli
21  */

22 public class FormURLToolsTest extends TestCase {
23
24     /**
25      * Constructs a new <code>FormURLToolsTest</code>.
26      */

27     public FormURLToolsTest(String JavaDoc name) {
28         super(name);
29     }
30
31
32     /**
33      * Tests the generation of the URL.
34      */

35     public void testGenerateURL() {
36         assertEquals("/mvc/form/f.form/a.action", FormURLTools.generateURL("form", "action"));
37         assertEquals("/mvc/form/f.formName/a.actionName", FormURLTools.generateURL("formName", "actionName"));
38         assertEquals("/mvc/form/a.actionName", FormURLTools.generateURL(null, "actionName"));
39         assertEquals("/mvc/form/f.formName", FormURLTools.generateURL("formName", null));
40         assertEquals("/mvc/form", FormURLTools.generateURL(null, null));
41     }
42
43     /**
44      * Tests the generation of the submit parameter
45      */

46     public void testSubmitParameter() {
47         String JavaDoc expected = "submitName" + FormURLTools.MAIN_DELIMITER + "actionName";
48         String JavaDoc actual = FormURLTools.generateSubmitParameter("submitName", "actionName");
49         assertEquals(expected, actual);
50
51         try {
52             FormURLTools.generateSubmitParameter(null, "foo");
53             fail("Should have failed");
54         } catch (IllegalArgumentException JavaDoc iae) {
55             // Expected
56
}
57
58         try {
59             FormURLTools.generateSubmitParameter("foo", null);
60             fail("Should have failed");
61         } catch (IllegalArgumentException JavaDoc iae) {
62             // Expected
63
}
64     }
65 }
Popular Tags