1 15 16 package com.sun.facelets.mock; 17 18 import java.util.Enumeration ; 19 import java.util.Hashtable ; 20 21 import javax.servlet.ServletContext ; 22 import javax.servlet.http.HttpSession ; 23 import javax.servlet.http.HttpSessionContext ; 24 25 30 public class MockHttpSession implements HttpSession { 31 32 private final Hashtable attributes = new Hashtable (); 33 private final long creationTime; 34 private String id; 35 private long lastAccessedTime; 36 private final ServletContext servletContext; 37 private int maxInactiveInterval = 20; 38 39 public MockHttpSession(ServletContext servletContext) { 40 this.servletContext = servletContext; 41 this.creationTime = System.currentTimeMillis(); 42 this.id = "" + this.creationTime; 43 this.lastAccessedTime = this.creationTime; 44 } 45 46 public long getCreationTime() { 47 return this.creationTime; 48 } 49 50 public String getId() { 51 return this.id; 52 } 53 54 public long getLastAccessedTime() { 55 return this.lastAccessedTime; 56 } 57 58 public ServletContext getServletContext() { 59 return this.servletContext; 60 } 61 62 public void setMaxInactiveInterval(int interval) { 63 this.maxInactiveInterval = interval; 64 } 65 66 public int getMaxInactiveInterval() { 67 return this.maxInactiveInterval; 68 } 69 70 public HttpSessionContext getSessionContext() { 71 throw new UnsupportedOperationException (); 72 } 73 74 public Object getAttribute(String name) { 75 return this.attributes.get(name); 76 } 77 78 public Object getValue(String name) { 79 throw new UnsupportedOperationException (); 80 } 81 82 public Enumeration getAttributeNames() { 83 return this.attributes.keys(); 84 } 85 86 public String [] getValueNames() { 87 throw new UnsupportedOperationException (); 88 } 89 90 public void setAttribute(String name, Object value) { 91 this.attributes.put(name, value); 92 } 93 94 public void putValue(String arg0, Object arg1) { 95 throw new UnsupportedOperationException (); 96 97 } 98 99 public void removeAttribute(String name) { 100 this.attributes.remove(name); 101 } 102 103 public void removeValue(String arg0) { 104 throw new UnsupportedOperationException (); 105 } 106 107 public void invalidate() { 108 109 } 110 111 public boolean isNew() { 112 return false; 113 } 114 115 } 116 | Popular Tags |