1 7 package com.inversoft.verge.mvc.model.test; 8 9 10 import java.util.Map ; 11 12 import javax.servlet.http.HttpServletRequest ; 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 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 33 public Object getValue(MVCRequest mvcRequest, String definition, 34 ModelResolution model, Map extraParams) 35 throws MVCException { 36 return null; 37 } 38 39 41 public void setValue(MVCRequest mvcRequest, String definition, 42 ModelResolution model, Object value, Map extraParams) 43 throws MVCException { 44 HttpServletRequest 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 |