KickJava   Java API By Example, From Geeks To Geeks.

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


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.ModelResolution;
17 import com.inversoft.verge.mvc.model.ModelResolver;
18 import com.inversoft.verge.mvc.model.form.FormMetaData;
19
20
21 /**
22  * Test class is used for testing that the DefaultModelParser
23  * works correctly.
24  */

25 public class TestModelResolver implements ModelResolver {
26
27     /**
28      * the test model that is returned from the resolve metho
29      */

30     public static final ModelResolution MODEL = new ModelResolution(new Object JavaDoc(),
31             new FormMetaData("id", ""));
32
33     public boolean calledDefinition = false;
34     public boolean calledParams = false;
35     public boolean calledNull = false;
36     
37     
38     /**
39      */

40     public ModelResolution resolve(MVCRequest mvcRequest, String JavaDoc definition, Map JavaDoc extraParams)
41     throws MVCException {
42         HttpServletRequest JavaDoc request = mvcRequest.getRequest();
43         if (request.getParameter("resolverTestDefinition") != null) {
44             calledDefinition = true;
45             if (definition == null || !definition.equals("test")) {
46                 throw new MVCException("Resolver - definition test failed");
47             }
48         } else if (request.getParameter("resolverTestParams") != null) {
49             calledParams = true;
50             if (extraParams == null || !extraParams.get("param").equals("test")) {
51                 throw new MVCException("Resolver - params test failed");
52             }
53         } else if (request.getParameter("resolverTestNull") != null) {
54             calledNull = true;
55             return null;
56         }
57
58         return MODEL;
59     }
60 }
61
Popular Tags