KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > test > TestModelHandler


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.model.test;
8
9
10 import java.util.Map JavaDoc;
11
12 import javax.servlet.http.HttpServletRequest JavaDoc;
13
14 import com.inversoft.verge.mvc.MVCException;
15 import com.inversoft.verge.mvc.MVCRequest;
16 import com.inversoft.verge.mvc.model.ModelHandler;
17 import com.inversoft.verge.mvc.model.ModelResolution;
18
19
20 /**
21  * test class
22  */

23 public class TestModelHandler implements ModelHandler {
24     
25     public boolean calledDefinition = false;
26     public boolean calledParams = false;
27     public boolean calledModel = false;
28     public boolean calledNullValue = false;
29     
30
31     /**
32      */

33     public Object JavaDoc getValue(MVCRequest mvcRequest, String JavaDoc definition,
34             ModelResolution model, Map JavaDoc extraParams)
35     throws MVCException {
36         return null;
37     }
38
39     /**
40      */

41     public void setValue(MVCRequest mvcRequest, String JavaDoc definition,
42             ModelResolution model, Object JavaDoc value, Map JavaDoc extraParams)
43     throws MVCException {
44         HttpServletRequest JavaDoc request = mvcRequest.getRequest();
45         if (request.getParameter("handlerTestDefinition") != null) {
46             calledDefinition = true;
47             if (definition == null || !definition.equals("test")) {
48                 throw new MVCException("Handler - definition test failed");
49             }
50         } else if (request.getParameter("handlerTestParams") != null) {
51             calledParams = true;
52             if (extraParams == null || !extraParams.get("param").equals("test")) {
53                 throw new MVCException("Handler - params test failed");
54             }
55         } else if (request.getParameter("handlerTestModel") != null) {
56             calledModel = true;
57             if (model != TestModelResolver.MODEL) {
58                 throw new MVCException("Handler - Model test failed");
59             }
60         } else if (value == null) {
61             calledNullValue = true;
62         }
63     }
64 }
65
66
67
Popular Tags