KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > controller > actionflow > test > ActionFlowControllerHandlerTest


1 /*
2  * Copyright (c) 2003, Inversoft
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.actionflow.test;
8
9
10 import java.util.HashMap JavaDoc;
11 import java.util.Map JavaDoc;
12
13 import com.inversoft.junit.WebTestCase;
14 import com.inversoft.verge.mvc.MVCException;
15 import com.inversoft.verge.mvc.MVCRegistry;
16 import com.inversoft.verge.mvc.MVCRequest;
17 import com.inversoft.verge.mvc.controller.ControllerMVCInfo;
18 import com.inversoft.verge.mvc.controller.actionflow.ActionFlowControllerHandler;
19 import com.inversoft.verge.mvc.controller.actionflow.ActionFlowURLTools;
20
21
22 /**
23  * <p>
24  * This class is a test for the form controller handler
25  * </p>
26  *
27  * @author Brian Pontarelli
28  * @since 2.0
29  * @version 2.0
30  */

31 public class ActionFlowControllerHandlerTest extends WebTestCase {
32
33     /**
34      * Constructor for ActionFlowControllerHandlerTest.
35      *
36      * @param name The
37      */

38     public ActionFlowControllerHandlerTest(String JavaDoc name) {
39         super(name);
40         setLocal(true);
41     }
42
43
44     /**
45      * Tests the preHandling
46      */

47     public void testSetupMVCRequest() {
48
49         MVCRequest mvcRequest = new MVCRequest(request, response);
50         Map JavaDoc map = new HashMap JavaDoc();
51         map.put(ActionFlowURLTools.MODEL_ENABLED_PARAM, "false");
52         map.put(ActionFlowURLTools.VALIDATION_ENABLED_PARAM, "false");
53
54         // Call the handler
55
ActionFlowControllerHandler handler = new ActionFlowControllerHandler();
56         MVCRegistry.register("actionFlow", handler);
57         try {
58             ControllerMVCInfo info = new ControllerMVCInfo(
59                 "/actionFlow/n.namespace/e.entry");
60             mvcRequest.setControllerInfo(info);
61
62             // Add the submit parameter
63
getRequest().setParameter(ActionFlowURLTools.SUBMIT_PARAMETER,
64                 ActionFlowURLTools.generateSubmitParameter("subName", "action",
65                     null, map));
66             getRequest().setParameter("subName", "value");
67
68             // Execute
69
handler.preExecute(mvcRequest);
70         } catch (MVCException mvce) {
71             fail(mvce.toString());
72         }
73         
74         assertFalse(mvcRequest.isModelEnabled());
75         assertFalse(mvcRequest.isValidationEnabled());
76     }
77 }
Popular Tags