Source Code Cross Referenced for MockSession.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » rife 1.6.1 » com.uwyn.rife.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: MockSession.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.test;
009:
010:        import java.util.Collections;
011:        import java.util.Enumeration;
012:        import java.util.HashMap;
013:        import java.util.Map;
014:
015:        import javax.servlet.ServletContext;
016:        import javax.servlet.http.HttpSession;
017:        import javax.servlet.http.HttpSessionContext;
018:
019:        class MockSession implements  HttpSession {
020:            final static public String SESSION_COOKIE_NAME = "JSESSION";
021:
022:            private static int sNextId = 1;
023:
024:            private MockConversation mMockConversation;
025:            private String mId = Integer.toString(sNextId++);
026:            private long mCreationTime = System.currentTimeMillis();
027:            private long mLastAccessTime = System.currentTimeMillis();
028:            private int mMaxInactiveInterval;
029:            private Map<String, Object> mAttributes = new HashMap<String, Object>();
030:            private boolean mIsNew = true;
031:            private boolean mInvalid = false;
032:
033:            MockSession(MockConversation conversation) {
034:                mMockConversation = conversation;
035:            }
036:
037:            public long getCreationTime() {
038:                if (mInvalid)
039:                    throw new IllegalStateException();
040:
041:                return mCreationTime;
042:            }
043:
044:            public String getId() {
045:                if (mInvalid)
046:                    throw new IllegalStateException();
047:
048:                return mId;
049:            }
050:
051:            public long getLastAccessedTime() {
052:                if (mInvalid)
053:                    throw new IllegalStateException();
054:
055:                return mLastAccessTime;
056:            }
057:
058:            public void setMaxInactiveInterval(int interval) {
059:                if (mInvalid)
060:                    throw new IllegalStateException();
061:
062:                mMaxInactiveInterval = interval;
063:            }
064:
065:            public int getMaxInactiveInterval() {
066:                if (mInvalid)
067:                    throw new IllegalStateException();
068:
069:                return mMaxInactiveInterval;
070:            }
071:
072:            public Object getAttribute(String name) {
073:                if (mInvalid)
074:                    throw new IllegalStateException();
075:
076:                return mAttributes.get(name);
077:            }
078:
079:            public Enumeration getAttributeNames() {
080:                if (mInvalid)
081:                    throw new IllegalStateException();
082:
083:                return Collections.enumeration(mAttributes.keySet());
084:            }
085:
086:            public void setAttribute(String name, Object value) {
087:                if (mInvalid)
088:                    throw new IllegalStateException();
089:
090:                mAttributes.put(name, value);
091:            }
092:
093:            public void removeAttribute(String name) {
094:                if (mInvalid)
095:                    throw new IllegalStateException();
096:
097:                mAttributes.remove(name);
098:            }
099:
100:            public void invalidate() {
101:                mMockConversation.removeSession(mId);
102:                mInvalid = true;
103:                mAttributes.clear();
104:                mId = null;
105:            }
106:
107:            public boolean isNew() {
108:                return mIsNew;
109:            }
110:
111:            public Object getValue(String name) {
112:                if (mInvalid)
113:                    throw new IllegalStateException();
114:
115:                return getAttribute(name);
116:            }
117:
118:            public String[] getValueNames() {
119:                if (mInvalid)
120:                    throw new IllegalStateException();
121:
122:                String[] names_array = new String[mAttributes.size()];
123:                mAttributes.keySet().toArray(names_array);
124:                return names_array;
125:            }
126:
127:            public void putValue(String name, Object value) {
128:                if (mInvalid)
129:                    throw new IllegalStateException();
130:
131:                setAttribute(name, value);
132:            }
133:
134:            public void removeValue(String name) {
135:                if (mInvalid)
136:                    throw new IllegalStateException();
137:
138:                removeAttribute(name);
139:            }
140:
141:            public ServletContext getServletContext() {
142:                return null;
143:            }
144:
145:            public HttpSessionContext getSessionContext() {
146:                return null;
147:            }
148:
149:            void access() {
150:                mIsNew = false;
151:                mLastAccessTime = System.currentTimeMillis();
152:            }
153:
154:            boolean isValid() {
155:                return !mInvalid;
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.