|
From: Jeff M. <cus...@us...> - 2003-02-25 17:41:40
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet
In directory sc8-pr-cvs1:/tmp/cvs-serv1210/src/j2ee/1.3/com/mockobjects/servlet
Modified Files:
MockHttpServletRequest.java
Log Message:
Changed MockHttpServletRequest to make use of ReturnValue
Index: MockHttpServletRequest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12
+++ MockHttpServletRequest.java 25 Feb 2003 17:41:30 -0000 1.13
@@ -18,24 +18,25 @@
* @version $Revision$
*/
public class MockHttpServletRequest extends MockObject
-
implements HttpServletRequest {
+
private Dictionary myParameters = new Hashtable();
private Dictionary myHeaders = new Hashtable();
- private HttpSession myHttpSession;
- private String myContentTypeToReturn;
- private String myContextPath;
- private String myPathInfo;
- private String myRemoteAddress;
- private final ReturnValue myRequestURI = new ReturnValue("request URI");
+ private final ReturnValue myHttpSession = new ReturnValue("session");
+ private final ReturnValue myContentTypeToReturn = new ReturnValue("content type");
+ private final ReturnValue myContextPath = new ReturnValue("context path");
+ private final ReturnValue myPathInfo = new ReturnValue("path info");
+ private final ReturnValue myRemoteAddress = new ReturnValue("remote address");
+ private final ReturnValue myRequestURI = new ReturnValue("request uri");
private final ReturnValue method = new ReturnValue("method");
private final ReturnValue protocol = new ReturnValue("protocol");
- private ServletInputStream myInputStream;
- private Principal myUserPrincipal;
+ private final ReturnValue inputStream = new ReturnValue("input stream");
+ private final ReturnValue myUserPrincipal = new ReturnValue("user principal");
private Vector myAttributesNames;
- private String queryString;
- private String scheme;
- private String serverName;
+ 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");
@@ -76,15 +77,16 @@
}
public int getContentLength() {
+ notImplemented();
return 0;
}
public String getContentType() {
- return myContentTypeToReturn;
+ return (String)myContentTypeToReturn.getValue();
}
public void setupGetContentType(String aContentType) {
- myContentTypeToReturn = aContentType;
+ myContentTypeToReturn.setValue(aContentType);
}
public void setExpectedContentType(String aContentType) {
@@ -96,11 +98,11 @@
}
public String getContextPath() {
- return myContextPath;
+ return (String)myContextPath.getValue();
}
public void setupGetContextPath(String contextPath) {
- myContextPath = contextPath;
+ myContextPath.setValue(contextPath);
}
public Cookie[] getCookies() {
@@ -109,6 +111,7 @@
}
public long getDateHeader(String arg1) {
+ notImplemented();
return 0;
}
@@ -126,16 +129,17 @@
return null;
}
- public void setupGetInputStream(ServletInputStream anInputStream) {
- this.myInputStream = anInputStream;
+ public void setupGetInputStream(ServletInputStream inputStream) {
+ this.inputStream.setValue(inputStream);
}
public ServletInputStream getInputStream()
- throws java.io.IOException {
- return myInputStream;
+ throws IOException {
+ return (ServletInputStream)inputStream.getValue();
}
public int getIntHeader(String arg1) {
+ notImplemented();
return 0;
}
@@ -174,7 +178,7 @@
}
public String getPathInfo() {
- return myPathInfo;
+ return (String)myPathInfo.getValue();
}
public String getPathTranslated() {
@@ -191,12 +195,15 @@
}
public String getQueryString() {
- return queryString;
+ return (String)queryString.getValue();
}
- public BufferedReader getReader() throws IOException {
- notImplemented();
- return null;
+ public BufferedReader getReader() {
+ return (BufferedReader)reader.getValue();
+ }
+
+ public void setupGetReader(BufferedReader reader) throws IOException {
+ this.reader.setValue(reader);
}
public String getRealPath(String arg1) {
@@ -205,11 +212,11 @@
}
public void setupGetRemoteAddr(String remoteAddress) {
- this.myRemoteAddress = remoteAddress;
+ this.myRemoteAddress.setValue(remoteAddress);
}
public String getRemoteAddr() {
- return myRemoteAddress;
+ return (String)myRemoteAddress.getValue();
}
public String getRemoteHost() {
@@ -242,14 +249,15 @@
}
public String getScheme() {
- return scheme;
+ return (String)scheme.getValue();
}
public String getServerName() {
- return serverName;
+ return (String)serverName.getValue();
}
public int getServerPort() {
+ notImplemented();
return 0;
}
@@ -262,11 +270,11 @@
}
public HttpSession getSession() {
- return myHttpSession;
+ return (HttpSession)myHttpSession.getValue();
}
public void setSession(HttpSession httpSession) {
- this.myHttpSession = httpSession;
+ this.myHttpSession.setValue(httpSession);
}
public HttpSession getSession(boolean arg1) {
@@ -275,34 +283,40 @@
}
public void setupGetUserPrincipal(Principal userPrincipal) {
- this.myUserPrincipal = userPrincipal;
+ this.myUserPrincipal.setValue(userPrincipal);
}
public Principal getUserPrincipal() {
- return myUserPrincipal;
+ return (Principal)myUserPrincipal.getValue();
}
public boolean isRequestedSessionIdFromCookie() {
+ notImplemented();
return false;
}
public boolean isRequestedSessionIdFromUrl() {
+ notImplemented();
return false;
}
public boolean isRequestedSessionIdFromURL() {
+ notImplemented();
return false;
}
public boolean isRequestedSessionIdValid() {
+ notImplemented();
return false;
}
public boolean isSecure() {
+ notImplemented();
return false;
}
public boolean isUserInRole(java.lang.String arg1) {
+ notImplemented();
return false;
}
@@ -350,29 +364,32 @@
}
public void setupPathInfo(String pathInfo) {
- myPathInfo = pathInfo;
+ myPathInfo.setValue(pathInfo);
}
public void setupQueryString(String aQueryString) {
- queryString = aQueryString;
+ queryString.setValue(aQueryString);
}
public void setupScheme(String aScheme) {
- scheme = aScheme;
+ scheme.setValue(aScheme);
}
public void setupServerName(String aServerName) {
- serverName = aServerName;
+ serverName.setValue(aServerName);
}
public StringBuffer getRequestURL() {
+ notImplemented();
return null;
}
public void setCharacterEncoding(String s) {
+ notImplemented();
}
public Map getParameterMap() {
+ notImplemented();
return null;
}
}
|