From: Jeff M. <cus...@us...> - 2002-08-14 14:16:50
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory usw-pr-cvs1:/tmp/cvs-serv16028/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockHttpServletRequest.java Log Message: Added support for getContentType Index: MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MockHttpServletRequest.java 30 Apr 2002 11:51:50 -0000 1.5 +++ MockHttpServletRequest.java 14 Aug 2002 14:16:46 -0000 1.6 @@ -1,9 +1,6 @@ package com.mockobjects.servlet; -import com.mockobjects.ExpectationSet; -import com.mockobjects.MapEntry; -import com.mockobjects.MockObject; -import com.mockobjects.ReturnObjectList; +import com.mockobjects.*; import javax.servlet.ServletInputStream; import javax.servlet.RequestDispatcher; @@ -23,20 +20,21 @@ private Dictionary myParameters = new Hashtable(); private Dictionary myHeaders = new Hashtable(); private HttpSession myHttpSession; - private String myContentType; + private String myContentTypeToReturn; private String myPathInfo; private String myRemoteAddress; private String myRequestURI; private String myMethod; private ServletInputStream myInputStream; private java.security.Principal myUserPrincipal; - private ExpectationSet mySetAttributes = + private final ExpectationSet mySetAttributes = new ExpectationSet(MockHttpServletRequest.class.getName() + ".setAttribute"); - private ExpectationSet myRemoveAttributes = new ExpectationSet( + private final ExpectationSet myRemoveAttributes = new ExpectationSet( MockHttpServletRequest.class.getName() + ".removeAttribute"); - private ReturnObjectList myAttributesToReturn + private final ReturnObjectList myAttributesToReturn = new ReturnObjectList("attributes"); + private final ExpectationValue myContentType = new ExpectationValue("content type"); public void setupGetAttribute(Object anAttributeToReturn) { myAttributesToReturn.addObjectToReturn(anAttributeToReturn); @@ -66,12 +64,19 @@ } public String getContentType() { - notImplemented(); - return null; + return myContentTypeToReturn; + } + + public void setupGetContentType(String aContentType) { + myContentTypeToReturn = aContentType; + } + + public void setExpectedContentType(String aContentType) { + this.myContentType.setExpected(aContentType); } public void setContentType(String contentType) { - this.myContentType = contentType; + this.myContentType.setActual(contentType); } public String getContextPath() { @@ -135,7 +140,7 @@ public String getParameter(String paramName) { String[] values = getParameterValues(paramName); - if(values == null) + if (values == null) return null; return values[0]; |