1 package br.com.ibnetwork.guara.test.mock; 2 3 import java.util.Calendar; 4 import java.util.Enumeration; 5 import java.util.HashMap; 6 import java.util.Map; 7 8 import javax.servlet.ServletContext; 9 import javax.servlet.http.HttpSession; 10 import javax.servlet.http.HttpSessionContext; 11 12 /*** 13 * @author leandro 14 */ 15 public class MockHttpSession 16 implements HttpSession 17 { 18 private long creationTime; 19 20 private Map attributes = new HashMap(); 21 22 public MockHttpSession() 23 { 24 creationTime = Calendar.getInstance().getTimeInMillis(); 25 } 26 27 public long getCreationTime() 28 { 29 return creationTime; 30 } 31 32 public String getId() 33 { 34 return null; 35 } 36 37 public long getLastAccessedTime() 38 { 39 return 0; 40 } 41 42 public ServletContext getServletContext() 43 { 44 return null; 45 } 46 47 public void setMaxInactiveInterval(int arg0) 48 { 49 } 50 51 public int getMaxInactiveInterval() 52 { 53 return 0; 54 } 55 56 public HttpSessionContext getSessionContext() 57 { 58 return null; 59 } 60 61 public Object getAttribute(String key) 62 { 63 return attributes.get(key); 64 } 65 66 public Enumeration getAttributeNames() 67 { 68 Enumeration e = new SimpleEnumeration(attributes.keySet()); 69 return e; 70 } 71 72 public void setAttribute(String key, Object val) 73 { 74 attributes.put(key,val); 75 } 76 77 public void removeAttribute(String key) 78 { 79 attributes.remove(key); 80 } 81 82 public void invalidate() 83 { 84 attributes.clear(); 85 } 86 87 public boolean isNew() 88 { 89 return false; 90 } 91 92 /*** 93 * @deprecated 94 */ 95 public void putValue(String arg0, Object arg1) 96 { 97 } 98 99 /*** 100 * @deprecated 101 */ 102 public void removeValue(String arg0) 103 { 104 } 105 106 /*** 107 * @deprecated 108 */ 109 public Object getValue(String arg0) 110 { 111 return null; 112 } 113 114 /*** 115 * @deprecated 116 */ 117 public String[] getValueNames() 118 { 119 return null; 120 } 121 }