1 package com.mockobjects.servlet; 2 3 import com.mockobjects.*; 4 5 import javax.servlet.ServletContext ; 6 import javax.servlet.http.HttpSession ; 7 import javax.servlet.http.HttpSessionContext ; 8 import java.util.Enumeration ; 9 10 public class MockHttpSession extends MockObject implements HttpSession , Verifiable { 11 private ExpectationSet myAttributes = new ExpectationSet("session attributes"); 12 private ExpectationSet myRemovedAttributes = new ExpectationSet("removed session attributes"); 13 private ReturnObjectBag myAttributeValues = new ReturnObjectBag("attributes"); 14 private Enumeration attributeNames; 15 16 private ServletContext servletContext; 17 18 public Object getAttribute(String anAttributeName) { 19 return myAttributeValues.getNextReturnObject(anAttributeName); 20 } 21 22 public void setupGetAttributeNames(Enumeration attributeNames) { 23 this.attributeNames = attributeNames; 24 } 25 26 public Enumeration getAttributeNames() { 27 return attributeNames; 28 } 29 30 public long getCreationTime() { 31 notImplemented(); 32 return 0; 33 } 34 35 public String getId() { 36 notImplemented(); 37 return null; 38 } 39 40 public long getLastAccessedTime() { 41 notImplemented(); 42 return 0; 43 } 44 45 public int getMaxInactiveInterval() { 46 notImplemented(); 47 return 0; 48 } 49 50 public HttpSessionContext getSessionContext() { 51 notImplemented(); 52 return null; 53 } 54 55 public void setupServletContext(ServletContext servletContext) { 56 this.servletContext = servletContext; 57 } 58 59 public ServletContext getServletContext() { 60 return servletContext; 61 } 62 63 public Object getValue(String arg1) { 64 notImplemented(); 65 return null; 66 } 67 68 public String [] getValueNames() { 69 notImplemented(); 70 return null; 71 } 72 73 public void invalidate() { 74 notImplemented(); 75 } 76 77 public boolean isNew() { 78 notImplemented(); 79 return false; 80 } 81 82 public void putValue(String arg1, Object arg2) { 83 notImplemented(); 84 } 85 86 public void setExpectedRemoveAttribute(String anAttributeName){ 87 myRemovedAttributes.addExpected(anAttributeName); 88 } 89 90 public void removeAttribute(String anAttributeName) { 91 myRemovedAttributes.addActual(anAttributeName); 92 } 93 94 public void removeValue(String arg1) { 95 notImplemented(); 96 } 97 98 public void setupGetAttribute(String key, Object value){ 99 myAttributeValues.putObjectToReturn(key, value); 100 } 101 102 public void setAttribute(String aKey, Object aValue) { 103 myAttributes.addActual(new MapEntry(aKey, aValue)); 104 } 105 106 public void setExpectedAttribute(String aKey, Object aValue) { 107 myAttributes.addExpected(new MapEntry(aKey, aValue)); 108 } 109 110 public void setMaxInactiveInterval(int arg1) { 111 notImplemented(); 112 } 113 } 114 | Popular Tags |