From: Jeff M. <cus...@us...> - 2003-04-10 10:39:16
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv26633/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockHttpServletRequest.java Log Message: Change servlet paramaters to use ReturnObjectBag Index: MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- MockHttpServletRequest.java 18 Mar 2003 14:28:43 -0000 1.14 +++ MockHttpServletRequest.java 10 Apr 2003 10:39:12 -0000 1.15 @@ -20,8 +20,8 @@ public class MockHttpServletRequest extends MockObject implements HttpServletRequest { - private Dictionary myParameters = new Hashtable(); - private Dictionary myHeaders = new Hashtable(); + private final ReturnObjectBag myParameters = new ReturnObjectBag("parameters"); + private final ReturnObjectBag myHeaders = new ReturnObjectBag("headers"); private final ReturnValue myHttpSession = new ReturnValue("session"); private final ReturnValue myContentTypeToReturn = new ReturnValue("content type"); private final ReturnValue myContextPath = new ReturnValue("context path"); @@ -32,19 +32,21 @@ private final ReturnValue protocol = new ReturnValue("protocol"); private final ReturnValue inputStream = new ReturnValue("input stream"); private final ReturnValue myUserPrincipal = new ReturnValue("user principal"); - private Vector myAttributesNames; + private final ReturnValue myAttributesNames = new ReturnValue("attribute names"); private final ReturnValue queryString = new ReturnValue("query string"); private final ReturnValue scheme = new ReturnValue("scheme"); private final ReturnValue serverName = new ReturnValue("server name"); private final ReturnValue reader = new ReturnValue("reader"); - - private ExpectationSet mySetAttributes = new ExpectationSet("HttpServletRequest.setAttribute"); - private ExpectationSet myRemoveAttributes = new ExpectationSet("HttpServletRequest.removeAttribute"); - private ReturnObjectList myAttributesToReturn = new ReturnObjectList("attributes"); - private ExpectationValue myContentType = new ExpectationValue("content type"); - private ExpectationList myGetAttributeNames = new ExpectationList("get attribute names"); + private final ExpectationSet mySetAttributes = new ExpectationSet("HttpServletRequest.setAttribute"); + private final ExpectationSet myRemoveAttributes = new ExpectationSet("HttpServletRequest.removeAttribute"); + private final ReturnObjectList myAttributesToReturn = new ReturnObjectList("attributes"); + private final ExpectationValue myContentType = new ExpectationValue("content type"); + private final ExpectationList myGetAttributeNames = new ExpectationList("get attribute names"); private final ReturnValue servletPath = new ReturnValue("servlet path"); private final ReturnValue parameterMap = new ReturnValue("parameter map"); + private final ReturnValue myParameterNames = new ReturnValue("parameter names"); + private final ReturnValue requestDispatcher = new ReturnValue("request dispatcher"); + private final ExpectationValue requestDispatcherURI = new ExpectationValue("request dispatcher uri"); public void setupGetAttribute(Object anAttributeToReturn) { myAttributesToReturn.addObjectToReturn(anAttributeToReturn); @@ -59,12 +61,12 @@ return myAttributesToReturn.nextReturnObject(); } - public void setupGetAttrubuteNames(Vector attributeNames) { - myAttributesNames = attributeNames; + public void setupGetAttrubuteNames(Enumeration attributeNames) { + myAttributesNames.setValue(attributeNames); } public Enumeration getAttributeNames() { - return myAttributesNames.elements(); + return (Enumeration) myAttributesNames.getValue(); } public String getAuthType() { @@ -116,8 +118,8 @@ return 0; } - public String getHeader(String arg1) { - return (String) myHeaders.get(arg1); + public String getHeader(String key) { + return (String) myHeaders.getNextReturnObject(key); } public Enumeration getHeaderNames() { @@ -170,12 +172,16 @@ return values[0]; } + public void setupGetParameterNames(Enumeration names) { + this.myParameterNames.setValue(names); + } + public Enumeration getParameterNames() { - return myParameters.keys(); + return (Enumeration) myParameterNames.getValue(); } public String[] getParameterValues(String key) { - return (String[]) myParameters.get(key); + return (String[]) myParameters.getNextReturnObject(key); } public String getPathInfo() { @@ -230,10 +236,17 @@ return null; } - public RequestDispatcher getRequestDispatcher( - String arg1) { - notImplemented(); - return null; + public void setupGetRequestDispatcher(RequestDispatcher requestDispatcher){ + this.requestDispatcher.setValue(requestDispatcher); + } + + public RequestDispatcher getRequestDispatcher(String uri) { + this.requestDispatcherURI.setActual(uri); + return (RequestDispatcher)requestDispatcher.getValue(); + } + + public void setExpectedRequestDispatcherURI(String uri){ + this.requestDispatcherURI.setExpected(uri); } public String getRequestedSessionId() { @@ -340,28 +353,16 @@ new MapEntry(attributeName, attributeValue)); } - public void setNoActualParameters() { - setupNoParameters(); - } - public void setupAddParameter(String paramName, String[] values) { - myParameters.put(paramName, values); + myParameters.putObjectToReturn(paramName, values); } public void setupAddParameter(String paramName, String value) { setupAddParameter(paramName, new String[]{value}); } - public void setupNoParameters() { - myParameters = new Hashtable(); - } - public void setupAddHeader(String headerName, String value) { - myHeaders.put(headerName, value); - } - - public void setupNoHeaders() { - myHeaders = new Hashtable(); + myHeaders.putObjectToReturn(headerName, value); } public void setupPathInfo(String pathInfo) { |