Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory usw-pr-cvs1:/tmp/cvs-serv6563/src/j2ee/1.3/com/mockobjects/servlet Added Files: MockFilterChain.java MockFilterConfig.java MockHttpServletRequest.java MockHttpServletResponse.java MockHttpSession.java Log Message: Reworked build structure for j2ee libraries. --- NEW FILE: MockFilterChain.java --- package com.mockobjects.servlet; import com.mockobjects.*; import javax.servlet.*; import java.io.IOException; public class MockFilterChain extends MockObject implements FilterChain { public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException{ } } --- NEW FILE: MockFilterConfig.java --- package com.mockobjects.servlet; import com.mockobjects.*; import java.util.*; import javax.servlet.*; public class MockFilterConfig extends MockObject implements FilterConfig { private ServletContext servletContext; public String getFilterName(){ return null; } public void setupGetServletContext(ServletContext servletContext){ this.servletContext = servletContext; } public ServletContext getServletContext(){ return servletContext; } public String getInitParameter(String name){ return null; } public Enumeration getInitParameterNames(){ return null; } } --- NEW FILE: MockHttpServletRequest.java --- package com.mockobjects.servlet; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import junit.framework.*; import junit.textui.*; import java.util.*; import java.io.*; import java.net.*; import com.mockobjects.*; /** * @version $Revision: 1.1 $ */ public class MockHttpServletRequest extends MockObject implements HttpServletRequest { private Dictionary myParameters = new Hashtable(); private HttpSession httpSession; private String contentType; private String myPathInfo; private String remoteAddress; private java.security.Principal userPrincipal; private ExpectationSet mySetAttributes = new ExpectationSet(MockHttpServletRequest.class.getName() + ".setAttribute"); public MockHttpServletRequest() { super(); } /** * @deprecated */ public void addActualParameter(String paramName, String[] values) { setupAddParameter(paramName, values); } /** * @deprecated */ public void addActualParameter(String paramName, String value) { setupAddParameter(paramName, value); } public Object getAttribute(String arg1) { return null; } public java.util.Enumeration getAttributeNames() { return null; } public String getAuthType() { return null; } public String getCharacterEncoding() { return null; } public int getContentLength() { return 0; } public String getContentType() { return null; } public void setContentType(String contentType) { this.contentType = contentType; } public java.lang.String getContextPath() { return null; } public javax.servlet.http.Cookie[] getCookies() { return null; } public long getDateHeader(String arg1) { return 0; } public String getHeader(String arg1) { return null; } public java.util.Enumeration getHeaderNames() { return null; } public java.util.Enumeration getHeaders(java.lang.String arg1) { return null; } public javax.servlet.ServletInputStream getInputStream() throws java.io.IOException { return null; } public int getIntHeader(String arg1) { return 0; } public java.util.Locale getLocale() { return null; } public java.util.Enumeration getLocales() { return null; } public String getMethod() { return null; } public String getParameter(String paramName) { String[] values = getParameterValues(paramName); if (values == null) return null; return values[0]; } public java.util.Enumeration getParameterNames() { return myParameters.keys(); } public String[] getParameterValues(String key) { return (String[]) myParameters.get(key); } public String getPathInfo() { return myPathInfo; } public String getPathTranslated() { return null; } public String getProtocol() { return null; } public String getQueryString() { return null; } public java.io.BufferedReader getReader() throws java.io.IOException { return null; } public String getRealPath(String arg1) { return null; } public void setupGetRemoteAddr(String remoteAddress){ this.remoteAddress = remoteAddress; } public String getRemoteAddr() { return remoteAddress; } public String getRemoteHost() { return null; } public String getRemoteUser() { return null; } public javax.servlet.RequestDispatcher getRequestDispatcher( java.lang.String arg1) { return null; } public String getRequestedSessionId() { return null; } public String getRequestURI() { return null; } public String getScheme() { return null; } public String getServerName() { return null; } public int getServerPort() { return 0; } public String getServletPath() { return null; } public HttpSession getSession() { return httpSession; } public void setSession(HttpSession httpSession) { this.httpSession = httpSession; } public HttpSession getSession(boolean arg1) { return null; } public void setupGetUserPrincipal(java.security.Principal userPrincipal){ this.userPrincipal = userPrincipal; } public java.security.Principal getUserPrincipal() { return userPrincipal; } public boolean isRequestedSessionIdFromCookie() { return false; } public boolean isRequestedSessionIdFromUrl() { return false; } public boolean isRequestedSessionIdFromURL() { return false; } public boolean isRequestedSessionIdValid() { return false; } public boolean isSecure() { return false; } public boolean isUserInRole(java.lang.String arg1) { return false; } public void removeAttribute(java.lang.String arg1) { } public void addExpectedSetAttribute(String attributeName, Object attributeValue) { mySetAttributes.addExpected( new MapEntry(attributeName, attributeValue)); } public void setAttribute(String attributeName, Object attributeValue) { mySetAttributes.addActual( new MapEntry(attributeName, attributeValue)); } /** * @deprecated */ public void setNoActualParameters() { setupNoParameters(); } public void setupAddParameter(String paramName, String[] values) { myParameters.put(paramName, values); } public void setupAddParameter(String paramName, String value) { setupAddParameter(paramName, new String[] { value }); } public void setupNoParameters() { myParameters = new Hashtable(); } public void setupPathInfo(String pathInfo) { myPathInfo = pathInfo; } public StringBuffer getRequestURL(){ return null; } public void setCharacterEncoding(String s){ } public Map getParameterMap(){ return null; } } --- NEW FILE: MockHttpServletResponse.java --- 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"); /** * MockHttpServletResponse constructor comment. */ public MockHttpServletResponse() { super(); } public void addCookie(javax.servlet.http.Cookie arg1) { fail("Not implemented"); } /** * addDateHeader method comment. */ public void addDateHeader(java.lang.String arg1, long arg2) { } /** * addHeader method comment. */ public void addHeader(java.lang.String arg1, java.lang.String arg2) { } /** * addIntHeader method comment. */ public void addIntHeader(java.lang.String arg1, int arg2) { } public boolean containsHeader(String arg1) { fail("Not implemented"); return false; } public String encodeRedirectUrl(String arg1) { fail("Not implemented"); return null; } public String encodeRedirectURL(String arg1) { fail("Not implemented"); return null; } public String encodeUrl(String arg1) { fail("Not implemented"); return null; } public String encodeURL(String arg1) { fail("Not implemented"); return null; } /** * flushBuffer method comment. */ public void flushBuffer() throws java.io.IOException { } /** * getBufferSize method comment. */ public int getBufferSize() { return 0; } public String getCharacterEncoding() { fail("Not implemented"); return null; } /** * getLocale method comment. */ public java.util.Locale getLocale() { return null; } public javax.servlet.ServletOutputStream getOutputStream() throws java.io.IOException { return myOutputStream; } public String getOutputStreamContents() { return ((MockServletOutputStream) myOutputStream).getContents(); } public java.io.PrintWriter getWriter() throws java.io.IOException { return new PrintWriter(myOutputStream, true); } /** * isCommitted method comment. */ public boolean isCommitted() { return false; } /** * reset method comment. */ public void reset() { } public void resetBuffer(){ } public void setExpectedError(int anErrorCode){ myErrorCode.setExpected(anErrorCode); } public void setExpectedError(int anErrorCode, String anErrorMessage){ setExpectedError(anErrorCode); myErrorMessage.setExpected(anErrorMessage); } public void setExpectedErrorNothing(){ myErrorCode.setExpectNothing(); myErrorMessage.setExpectNothing(); } public void sendError(int anErrorCode) throws java.io.IOException { myErrorCode.setActual(anErrorCode); } public void sendError(int anErrorCode, String anErrorMessage) throws IOException { sendError(anErrorCode); myErrorMessage.setActual(anErrorMessage); } public void sendRedirect(String aURL) throws java.io.IOException { myRedirects.addActual(aURL); } /** * setBufferSize method comment. */ public void setBufferSize(int arg1) { } public void setContentLength(int arg1) { fail("Not implemented"); } public void setContentType(String contentType) { myContentTypes.addActual(contentType); } public void setDateHeader(String arg1, long arg2) { fail("Not implemented"); } public void setExpectedContentType(String contentType) { myContentTypes.addExpected(contentType); } public void setExpectedHeader(String key, String value) { myHeaders.addExpected(new MapEntry(key, value)); } public void setExpectedRedirect(String aURL) throws IOException { myRedirects.addExpected(aURL); } public void setExpectedSetStatusCalls(int callCount) { mySetStatusCalls.setExpected(callCount); } public void setHeader(String key, String value) { myHeaders.addActual(new MapEntry(key, value)); } public void setIntHeader(String arg1, int arg2) { Assert.fail("Not implemented"); } /** * setLocale method comment. */ public void setLocale(java.util.Locale arg1) { } public void setStatus(int status) { mySetStatusCalls.inc(); } public void setStatus(int arg1, String arg2) { Assert.fail("Not implemented"); } public void setupOutputStream(ServletOutputStream anOutputStream) { myOutputStream = anOutputStream; } } --- NEW FILE: MockHttpSession.java --- package com.mockobjects.servlet; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; import com.mockobjects.*; public class MockHttpSession extends MockObject implements HttpSession, Verifiable { public ExpectationSet myAttributes = new ExpectationSet("session attributes"); public HashMap attributes = new HashMap(); private ServletContext servletContext; public MockHttpSession() { super(); } public Object getAttribute(String arg1) { return attributes.get(arg1); } public Enumeration getAttributeNames() { return null; } public long getCreationTime() { notImplemented(); return 0; } public String getId() { notImplemented(); return null; } public long getLastAccessedTime() { notImplemented(); return 0; } public int getMaxInactiveInterval() { return 0; } public HttpSessionContext getSessionContext() { return null; } public void setupServletContext(ServletContext servletContext){ this.servletContext = servletContext; } public ServletContext getServletContext(){ return servletContext; } public Object getValue(String arg1) { notImplemented(); return null; } public java.lang.String[] getValueNames() { notImplemented(); return null; } public void invalidate() { } public boolean isNew() { return false; } public void putValue(String arg1, Object arg2) { } public void removeAttribute(String arg1) { } public void removeValue(String arg1) { } public void setAttribute(String aKey, Object aValue) { attributes.put(aKey, aValue); myAttributes.addActual(new MapEntry(aKey, aValue)); } public void setExpectedAttribute(String aKey, Object aValue) { myAttributes.addExpected(new MapEntry(aKey, aValue)); } public void setMaxInactiveInterval(int arg1) { } public void verify() { myAttributes.verify(); } } |