1 7 package com.inversoft.verge.mvc.controller.actionflow.test; 8 9 10 import java.util.HashMap ; 11 import java.util.Map ; 12 13 import junit.framework.TestCase; 14 15 import com.inversoft.verge.mvc.controller.actionflow.ActionFlowURLTools; 16 17 18 25 public class ActionFlowURLToolsTest extends TestCase { 26 27 30 public ActionFlowURLToolsTest(String name) { 31 super(name); 32 } 33 34 35 38 public void testGenerateURL() { 39 assertEquals("/mvc/actionflow/n.namespace/f.form/a.action/e.entry", 40 ActionFlowURLTools.generateURL("namespace", "form", "action", "entry")); 41 assertEquals("/mvc/actionflow/n.namespace/f.formName/a.actionName", 42 ActionFlowURLTools.generateURL("namespace", "formName", "actionName", null)); 43 assertEquals("/mvc/actionflow/n.namespace/f.form", 44 ActionFlowURLTools.generateURL("namespace", "form", null, null)); 45 assertEquals("/mvc/actionflow/n.namespace/a.action", 46 ActionFlowURLTools.generateURL("namespace", null, "action", null)); 47 assertEquals("/mvc/actionflow/n.namespace/e.entry", 48 ActionFlowURLTools.generateURL("namespace", null, null, "entry")); 49 50 try { 51 ActionFlowURLTools.generateURL(null, "foo", "bar", "john"); 52 fail("Should have failed"); 53 } catch (IllegalArgumentException iae) { 54 } 56 } 57 58 61 public void testSubmitParameter() { 62 String expected = "submitName" + ActionFlowURLTools.MAIN_DELIMITER + 63 "actionName"; 64 String actual = ActionFlowURLTools.generateSubmitParameter("submitName", 65 "actionName", null, null); 66 assertEquals(expected, actual); 67 68 expected = "submitName" + ActionFlowURLTools.MAIN_DELIMITER + 69 "actionName" + ActionFlowURLTools.MAIN_DELIMITER + "en=entryName"; 70 actual = ActionFlowURLTools.generateSubmitParameter("submitName", 71 "actionName", "entryName", null); 72 assertEquals(expected, actual); 73 74 Map params = new HashMap (); 75 params.put("param1", "value1"); 76 params.put("param2", "value2"); 77 expected = "submitName" + ActionFlowURLTools.MAIN_DELIMITER + 78 "actionName" + ActionFlowURLTools.MAIN_DELIMITER + "param2=value2" + 79 ActionFlowURLTools.SUB_DELIMITER + "param1=value1"; 80 actual = ActionFlowURLTools.generateSubmitParameter("submitName", 81 "actionName", null, params); 82 assertEquals(expected, actual); 83 84 params.clear(); 85 params.put("param1", "value1"); 86 params.put("param2", "value2"); 87 expected = "submitName" + ActionFlowURLTools.MAIN_DELIMITER + 88 "actionName" + ActionFlowURLTools.MAIN_DELIMITER + "en=entryName" + 89 ActionFlowURLTools.MAIN_DELIMITER + "param2=value2" + 90 ActionFlowURLTools.SUB_DELIMITER + "param1=value1"; 91 actual = ActionFlowURLTools.generateSubmitParameter("submitName", 92 "actionName", "entryName", params); 93 assertEquals(expected, actual); 94 } 95 } | Popular Tags |