1 15 package org.apache.tapestry.test.mock; 16 17 import javax.servlet.ServletContext ; 18 import javax.servlet.http.HttpSession ; 19 import javax.servlet.http.HttpSessionBindingEvent ; 20 import javax.servlet.http.HttpSessionBindingListener ; 21 import javax.servlet.http.HttpSessionContext ; 22 23 30 31 public class MockSession extends AttributeHolder implements HttpSession 32 { 33 private MockContext _context; 34 private String _id; 35 36 public MockSession(MockContext context, String id) 37 { 38 _context = context; 39 _id = id; 40 } 41 42 public long getCreationTime() 43 { 44 return 0; 45 } 46 47 public String getId() 48 { 49 return _id; 50 } 51 52 public long getLastAccessedTime() 53 { 54 return 0; 55 } 56 57 public ServletContext getServletContext() 58 { 59 return _context; 60 } 61 62 public void setMaxInactiveInterval(int arg0) 63 { 64 } 65 66 public int getMaxInactiveInterval() 67 { 68 return 0; 69 } 70 71 public HttpSessionContext getSessionContext() 72 { 73 return null; 74 } 75 76 public Object getValue(String name) 77 { 78 return getAttribute(name); 79 } 80 81 public String [] getValueNames() 82 { 83 return getAttributeNamesArray(); 84 } 85 86 public void putValue(String name, Object value) 87 { 88 setAttribute(name, value); 89 } 90 91 public void removeValue(String name) 92 { 93 removeAttribute(name); 94 } 95 96 public void invalidate() 97 { 98 } 99 100 public boolean isNew() 101 { 102 return false; 103 } 104 105 public void setAttribute(String name, Object value) 106 { 107 super.setAttribute(name, value); 108 109 if (value instanceof HttpSessionBindingListener ) 110 { 111 HttpSessionBindingListener listener = (HttpSessionBindingListener ) value; 112 HttpSessionBindingEvent event = new HttpSessionBindingEvent (this, name); 113 114 listener.valueBound(event); 115 } 116 } 117 118 } 119 | Popular Tags |