1 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 22 public class FormURLToolsTest extends TestCase { 23 24 27 public FormURLToolsTest(String name) { 28 super(name); 29 } 30 31 32 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 46 public void testSubmitParameter() { 47 String expected = "submitName" + FormURLTools.MAIN_DELIMITER + "actionName"; 48 String 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 iae) { 55 } 57 58 try { 59 FormURLTools.generateSubmitParameter("foo", null); 60 fail("Should have failed"); 61 } catch (IllegalArgumentException iae) { 62 } 64 } 65 } | Popular Tags |