KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > test > mocks > portlet > MockPortletSession


1 /**
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  **/

5 package org.exoplatform.test.mocks.portlet;
6
7 import java.util.* ;
8 import javax.portlet.* ;
9
10 /**
11  * Created by The eXo Platform SARL
12  * Author : Tuan Nguyen
13  * tuan08@users.sourceforge.net
14  * Date: Jul 27, 2003
15  * Time: 2:13:09 AM
16  */

17 public class MockPortletSession implements PortletSession {
18   HashMap attributes_ ;
19   HashMap appAttributes_ ;
20   
21   public MockPortletSession() {
22     super();
23     attributes_ = new HashMap() ;
24     appAttributes_ = new HashMap() ;
25   }
26
27   public Object JavaDoc getAttribute(String JavaDoc name) {
28     return attributes_.get(name) ;
29   }
30
31   public Object JavaDoc getAttribute(String JavaDoc name, int scope) {
32     if (scope == PortletSession.APPLICATION_SCOPE) {
33       return appAttributes_.get(name) ;
34     } else {
35       return attributes_.get(name) ;
36     }
37   }
38
39   public void setAttribute(String JavaDoc name, Object JavaDoc obj) {
40     attributes_.put(name, obj) ;
41   }
42
43   public void setAttribute(String JavaDoc name, Object JavaDoc obj , int scope) {
44     if (scope == PortletSession.APPLICATION_SCOPE) {
45       appAttributes_.put(name, obj) ;
46     } else {
47       attributes_.put(name, obj) ;
48     }
49   }
50
51   public void removeAttribute(String JavaDoc name) {
52     attributes_.remove(name) ;
53   }
54
55   public void removeAttribute(String JavaDoc name, int scope) {
56     if (scope == PortletSession.APPLICATION_SCOPE) {
57       appAttributes_.remove(name) ;
58     } else {
59       attributes_.remove(name) ;
60     }
61   }
62
63   public java.util.Enumeration JavaDoc getAttributeNames() {
64     return null ;
65   }
66
67   public java.util.Enumeration JavaDoc getAttributeNames(int scope) {
68     return null ;
69   }
70
71   public long getCreationTime() {
72     return 0 ;
73   }
74   
75   public java.lang.String JavaDoc getId() {
76     return new String JavaDoc(Integer.toString(this.hashCode())) ;
77   }
78   
79   public long getLastAccessedTime() {
80     return 0 ;
81   }
82
83   public int getMaxInactiveInterval() {
84     return 0 ;
85   }
86
87
88   public void invalidate() {}
89
90
91   public boolean isNew() {
92     return false ;
93   }
94   
95   public void setMaxInactiveInterval(int interval) {
96     
97   }
98
99
100   public PortletContext getPortletContext () {
101     return null ;
102   }
103
104 }
105
Popular Tags