From: Jeff M. <cus...@us...> - 2002-11-20 19:09:03
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv32623/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockHttpServletResponse.java Log Message: Changed old fail calls to be notImplemented Added support to setContentLength Index: MockHttpServletResponse.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockHttpServletResponse.java 23 Feb 2002 18:50:35 -0000 1.1 +++ MockHttpServletResponse.java 20 Nov 2002 19:08:58 -0000 1.2 @@ -1,138 +1,177 @@ package com.mockobjects.servlet; -import java.io.*; -import javax.servlet.*; -import javax.servlet.http.*; -import junit.framework.Assert; import com.mockobjects.*; -public class MockHttpServletResponse extends MockObject implements HttpServletResponse, Verifiable { - private ExpectationList myContentTypes = new ExpectationList("MockHttpServletResponse.setContentType"); - private ExpectationList myHeaders = new ExpectationList("MockHttpServletResponse.setHeader"); - private ExpectationCounter mySetStatusCalls = new ExpectationCounter("MockHttpServletResponse.setStatus"); - private ExpectationList myRedirects = new ExpectationList("MockHttpServletResponse.sendRedirect"); - private ServletOutputStream myOutputStream = new MockServletOutputStream(); - private ExpectationValue myErrorCode = new ExpectationValue("MockHttpServletResponse.sendError"); - private ExpectationValue myErrorMessage = new ExpectationValue("MockHttpServletResponse.sendError"); +import javax.servlet.ServletOutputStream; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Locale; + +public class MockHttpServletResponse extends MockObject + implements HttpServletResponse { + + private final ExpectationList myContentTypes = + new ExpectationList("MockHttpServletResponse.setContentType"); + private final ExpectationList myHeaders = + new ExpectationList("MockHttpServletResponse.setHeader"); + private final ExpectationCounter mySetStatusCalls = + new ExpectationCounter("MockHttpServletResponse.setStatus"); + private final ExpectationList myRedirects = + new ExpectationList("MockHttpServletResponse.sendRedirect"); + private MockServletOutputStream myOutputStream = + new MockServletOutputStream(); + private final ExpectationValue myErrorCode = + new ExpectationValue("MockHttpServletResponse.sendError"); + private final ExpectationValue myErrorMessage = + new ExpectationValue("MockHttpServletResponse.sendError"); + private final ExpectationValue length = new ExpectationValue("MockHttpServletResponse.length"); /** - * MockHttpServletResponse constructor comment. + * Not Implemented */ - public MockHttpServletResponse() { - super(); - } - - public void addCookie(javax.servlet.http.Cookie arg1) { - fail("Not implemented"); + public void addCookie(Cookie arg1) { + notImplemented(); } /** - * addDateHeader method comment. + * Not Implemented */ - public void addDateHeader(java.lang.String arg1, long arg2) { + public void addDateHeader(String arg1, long arg2) { + notImplemented(); } /** - * addHeader method comment. + * Not Implemented */ - public void addHeader(java.lang.String arg1, java.lang.String arg2) { + public void addHeader(String arg1, String arg2) { + notImplemented(); } /** - * addIntHeader method comment. + * Not Implemented */ - public void addIntHeader(java.lang.String arg1, int arg2) { + public void addIntHeader(String arg1, int arg2) { + notImplemented(); } + /** + * Not Implemented + */ public boolean containsHeader(String arg1) { - fail("Not implemented"); + notImplemented(); return false; } + /** + * Not Implemented + */ public String encodeRedirectUrl(String arg1) { - fail("Not implemented"); + notImplemented(); return null; } + /** + * Not Implemented + */ public String encodeRedirectURL(String arg1) { - fail("Not implemented"); + notImplemented(); return null; } + /** + * Not Implemented + */ public String encodeUrl(String arg1) { - fail("Not implemented"); + notImplemented(); return null; } + /** + * Not Implemented + */ public String encodeURL(String arg1) { - fail("Not implemented"); + notImplemented(); return null; } /** - * flushBuffer method comment. + * Not Implemented */ public void flushBuffer() throws java.io.IOException { + notImplemented(); } /** - * getBufferSize method comment. + * Not Implemented */ public int getBufferSize() { + notImplemented(); return 0; } + /** + * Not Implemented + */ public String getCharacterEncoding() { - fail("Not implemented"); + notImplemented(); return null; } /** - * getLocale method comment. + * Not Implemented */ - public java.util.Locale getLocale() { + public Locale getLocale() { + notImplemented(); return null; } - public javax.servlet.ServletOutputStream getOutputStream() - throws java.io.IOException { + public ServletOutputStream getOutputStream() + throws IOException { return myOutputStream; } public String getOutputStreamContents() { - return ((MockServletOutputStream) myOutputStream).getContents(); + return myOutputStream.getContents(); } - public java.io.PrintWriter getWriter() throws java.io.IOException { + public PrintWriter getWriter() throws IOException { return new PrintWriter(myOutputStream, true); } /** - * isCommitted method comment. + * Not Implemented */ public boolean isCommitted() { + notImplemented(); return false; } /** - * reset method comment. + * Not Implemented */ public void reset() { + notImplemented(); } - public void resetBuffer(){ + /** + * Not Implemented + */ + public void resetBuffer() { + notImplemented(); } - public void setExpectedError(int anErrorCode){ + public void setExpectedError(int anErrorCode) { myErrorCode.setExpected(anErrorCode); } - public void setExpectedError(int anErrorCode, String anErrorMessage){ + public void setExpectedError(int anErrorCode, String anErrorMessage) { setExpectedError(anErrorCode); myErrorMessage.setExpected(anErrorMessage); } - public void setExpectedErrorNothing(){ + public void setExpectedErrorNothing() { myErrorCode.setExpectNothing(); myErrorMessage.setExpectNothing(); } @@ -142,7 +181,7 @@ } public void sendError(int anErrorCode, String anErrorMessage) - throws IOException { + throws IOException { sendError(anErrorCode); myErrorMessage.setActual(anErrorMessage); } @@ -152,21 +191,29 @@ } /** - * setBufferSize method comment. + * Not Implemented */ public void setBufferSize(int arg1) { + notImplemented(); + } + + public void setContentLength(int length) { + this.length.setActual(length); } - public void setContentLength(int arg1) { - fail("Not implemented"); + public void setExpectedContentLength(int length){ + this.length.setExpected(length); } public void setContentType(String contentType) { myContentTypes.addActual(contentType); } + /** + * Not Implemented + */ public void setDateHeader(String arg1, long arg2) { - fail("Not implemented"); + notImplemented(); } public void setExpectedContentType(String contentType) { @@ -189,25 +236,32 @@ myHeaders.addActual(new MapEntry(key, value)); } + /** + * Not Implemented + */ public void setIntHeader(String arg1, int arg2) { - Assert.fail("Not implemented"); + notImplemented(); } /** - * setLocale method comment. + * Not Implemented */ - public void setLocale(java.util.Locale arg1) { + public void setLocale(Locale arg1) { + notImplemented(); } public void setStatus(int status) { mySetStatusCalls.inc(); } + /** + * Not Implemented + */ public void setStatus(int arg1, String arg2) { - Assert.fail("Not implemented"); + notImplemented(); } - public void setupOutputStream(ServletOutputStream anOutputStream) { + public void setupOutputStream(MockServletOutputStream anOutputStream) { myOutputStream = anOutputStream; } } |