From: Jeff M. <cus...@us...> - 2002-08-28 18:27:14
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory usw-pr-cvs1:/tmp/cvs-serv19014/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockHttpSession.java Log Message: Added remove attribute support Index: MockHttpSession.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpSession.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockHttpSession.java 27 Aug 2002 14:13:22 -0000 1.2 +++ MockHttpSession.java 28 Aug 2002 18:27:11 -0000 1.3 @@ -1,28 +1,26 @@ package com.mockobjects.servlet; -import java.util.Enumeration; -import java.util.HashMap; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpSession; -import javax.servlet.http.HttpSessionContext; - -import org.omg.CORBA.PUBLIC_MEMBER; - import com.mockobjects.ExpectationSet; import com.mockobjects.MapEntry; import com.mockobjects.MockObject; import com.mockobjects.Verifiable; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpSessionContext; +import java.util.Enumeration; +import java.util.HashMap; + public class MockHttpSession extends MockObject implements HttpSession, Verifiable { private ExpectationSet myAttributes = new ExpectationSet("session attributes"); - private HashMap attributes = new HashMap(); + private ExpectationSet myRemovedAttributes = new ExpectationSet("removed session attributes"); + private HashMap myAttributeValues = new HashMap(); private Enumeration attributeNames; private ServletContext servletContext; - public Object getAttribute(String arg1) { - return attributes.get(arg1); + public Object getAttribute(String anAttributeName) { + return myAttributeValues.get(anAttributeName); } public void setupGetAttributeNames(Enumeration attributeNames) { @@ -58,11 +56,11 @@ return null; } - public void setupServletContext(ServletContext servletContext){ + public void setupServletContext(ServletContext servletContext) { this.servletContext = servletContext; } - public ServletContext getServletContext(){ + public ServletContext getServletContext() { return servletContext; } @@ -89,8 +87,12 @@ notImplemented(); } - public void removeAttribute(String arg1) { - notImplemented(); + public void setExpectedRemoveAttribute(String anAttributeName){ + myRemovedAttributes.addExpected(anAttributeName); + } + + public void removeAttribute(String anAttributeName) { + myRemovedAttributes.addActual(anAttributeName); } public void removeValue(String arg1) { @@ -98,7 +100,7 @@ } public void setAttribute(String aKey, Object aValue) { - attributes.put(aKey, aValue); + myAttributeValues.put(aKey, aValue); myAttributes.addActual(new MapEntry(aKey, aValue)); } |