KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > portlet > TestPortletWebSession


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.portlet;
16
17 import java.util.List JavaDoc;
18
19 import javax.portlet.PortletSession;
20
21 import org.apache.tapestry.portlet.PortletWebSession;
22 import org.apache.tapestry.web.WebSession;
23 import org.easymock.MockControl;
24
25 /**
26  * Tests for {@link org.apache.tapestry.portlet.PortletWebSession}.
27  *
28  * @author Howard M. Lewis Ship
29  * @since 4.0
30  */

31 public class TestPortletWebSession extends BasePortletWebTestCase
32 {
33
34     public void testGetAttributeNames()
35     {
36         MockControl control = newControl(PortletSession.class);
37         PortletSession session = (PortletSession) control.getMock();
38
39         session.getAttributeNames();
40         control.setReturnValue(newEnumeration());
41
42         replayControls();
43
44         WebSession ws = new PortletWebSession(session);
45
46         List JavaDoc l = ws.getAttributeNames();
47
48         checkList(l);
49
50         verifyControls();
51     }
52
53     public void testGetAttribute()
54     {
55         Object JavaDoc attribute = new Object JavaDoc();
56
57         MockControl control = newControl(PortletSession.class);
58         PortletSession session = (PortletSession) control.getMock();
59
60         session.getAttribute("attr");
61         control.setReturnValue(attribute);
62
63         replayControls();
64
65         WebSession ws = new PortletWebSession(session);
66
67         assertSame(attribute, ws.getAttribute("attr"));
68
69         verifyControls();
70     }
71
72     public void testSetAttribute()
73     {
74         Object JavaDoc attribute = new Object JavaDoc();
75
76         MockControl control = newControl(PortletSession.class);
77         PortletSession session = (PortletSession) control.getMock();
78
79         session.setAttribute("name", attribute);
80
81         replayControls();
82
83         WebSession ws = new PortletWebSession(session);
84
85         ws.setAttribute("name", attribute);
86
87         verifyControls();
88     }
89
90
91     public void testGetId()
92     {
93         MockControl control = newControl(PortletSession.class);
94         PortletSession session = (PortletSession) control.getMock();
95
96         session.getId();
97         control.setReturnValue("abc");
98
99         replayControls();
100
101         WebSession ws = new PortletWebSession(session);
102
103         assertEquals("abc", ws.getId());
104
105         verifyControls();
106     }
107 }
Popular Tags