1 16 package org.apache.commons.chain.web.servlet; 17 18 19 import org.apache.commons.chain.web.MockEnumeration; 20 21 import javax.servlet.ServletContext ; 22 import javax.servlet.http.HttpSession ; 23 import javax.servlet.http.HttpSessionContext ; 24 import java.util.Enumeration ; 25 import java.util.HashMap ; 26 27 28 29 public class MockHttpSession implements HttpSession { 31 32 33 34 public MockHttpSession() { 35 super(); 36 } 37 38 39 public MockHttpSession(ServletContext servletContext) { 40 super(); 41 setServletContext(servletContext); 42 } 43 44 45 46 protected HashMap attributes = new HashMap (); 47 protected ServletContext servletContext = null; 48 49 50 52 53 public void setServletContext(ServletContext servletContext) { 54 this.servletContext = servletContext; 55 } 56 57 58 60 61 public Object getAttribute(String name) { 62 return (attributes.get(name)); 63 } 64 65 66 public Enumeration getAttributeNames() { 67 return (new MockEnumeration(attributes.keySet().iterator())); 68 } 69 70 71 public long getCreationTime() { 72 throw new UnsupportedOperationException (); 73 } 74 75 76 public String getId() { 77 throw new UnsupportedOperationException (); 78 } 79 80 81 public long getLastAccessedTime() { 82 throw new UnsupportedOperationException (); 83 } 84 85 86 public int getMaxInactiveInterval() { 87 throw new UnsupportedOperationException (); 88 } 89 90 91 public ServletContext getServletContext() { 92 return (this.servletContext); 93 } 94 95 96 public HttpSessionContext getSessionContext() { 97 throw new UnsupportedOperationException (); 98 } 99 100 101 public Object getValue(String name) { 102 throw new UnsupportedOperationException (); 103 } 104 105 106 public String [] getValueNames() { 107 throw new UnsupportedOperationException (); 108 } 109 110 111 public void invalidate() { 112 throw new UnsupportedOperationException (); 113 } 114 115 116 public boolean isNew() { 117 throw new UnsupportedOperationException (); 118 } 119 120 121 public void putValue(String name, Object value) { 122 throw new UnsupportedOperationException (); 123 } 124 125 126 public void removeAttribute(String name) { 127 attributes.remove(name); 128 } 129 130 131 public void removeValue(String name) { 132 throw new UnsupportedOperationException (); 133 } 134 135 136 public void setAttribute(String name, Object value) { 137 if (value == null) { 138 attributes.remove(name); 139 } else { 140 attributes.put(name, value); 141 } 142 } 143 144 145 public void setMaxInactiveInterval(int interval) { 146 throw new UnsupportedOperationException (); 147 } 148 149 150 } 151 | Popular Tags |