1 18 19 20 package org.apache.struts.mock; 21 22 23 import java.util.Enumeration ; 24 import java.util.HashMap ; 25 import javax.servlet.ServletContext ; 26 import javax.servlet.http.HttpSession ; 27 import javax.servlet.http.HttpSessionContext ; 28 29 30 31 47 48 public class MockHttpSession implements HttpSession { 49 50 51 52 54 55 public MockHttpSession() { 56 super(); 57 } 58 59 60 public MockHttpSession(ServletContext servletContext) { 61 super(); 62 setServletContext(servletContext); 63 } 64 65 66 67 69 70 73 protected HashMap attributes = new HashMap (); 74 75 76 79 protected ServletContext servletContext = null; 80 81 82 84 85 public void setServletContext(ServletContext servletContext) { 86 this.servletContext = servletContext; 87 } 88 89 90 92 93 public Object getAttribute(String name) { 94 return (attributes.get(name)); 95 } 96 97 98 public Enumeration getAttributeNames() { 99 return (new MockEnumeration(attributes.keySet().iterator())); 100 } 101 102 103 public long getCreationTime() { 104 throw new UnsupportedOperationException (); 105 } 106 107 108 public String getId() { 109 throw new UnsupportedOperationException (); 110 } 111 112 113 public long getLastAccessedTime() { 114 throw new UnsupportedOperationException (); 115 } 116 117 118 public int getMaxInactiveInterval() { 119 throw new UnsupportedOperationException (); 120 } 121 122 123 public ServletContext getServletContext() { 124 return (this.servletContext); 125 } 126 127 128 public HttpSessionContext getSessionContext() { 129 throw new UnsupportedOperationException (); 130 } 131 132 133 public Object getValue(String name) { 134 throw new UnsupportedOperationException (); 135 } 136 137 138 public String [] getValueNames() { 139 throw new UnsupportedOperationException (); 140 } 141 142 143 public void invalidate() { 144 throw new UnsupportedOperationException (); 145 } 146 147 148 public boolean isNew() { 149 throw new UnsupportedOperationException (); 150 } 151 152 153 public void putValue(String name, Object value) { 154 throw new UnsupportedOperationException (); 155 } 156 157 158 public void removeAttribute(String name) { 159 attributes.remove(name); 160 } 161 162 163 public void removeValue(String name) { 164 throw new UnsupportedOperationException (); 165 } 166 167 168 public void setAttribute(String name, Object value) { 169 if (value == null) { 170 attributes.remove(name); 171 } else { 172 attributes.put(name, value); 173 } 174 } 175 176 177 public void setMaxInactiveInterval(int interval) { 178 throw new UnsupportedOperationException (); 179 } 180 181 182 } 183 | Popular Tags |