2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.view;
19
20 import junit.framework.Test;
21 import junit.framework.TestSuite;
22
23 import org.apache.shale.test.base.AbstractJsfTestCase;
24 import org.apache.shale.view.faces.LifecycleListener;
25
26 /***
27 * <p>Test case for <code>org.apache.shale.view.AbstractSessionBean</code>.</p>
28 */
29 public class AbstractSessionBeanTestCase extends AbstractJsfTestCase {
30
31
32
33
34
35
36 public AbstractSessionBeanTestCase(String name) {
37 super(name);
38 }
39
40
41
42
43
44
45 protected void setUp() throws Exception {
46
47 super.setUp();
48 listener = new SessionAttributeListener();
49 session.addAttributeListener(listener);
50 session.addAttributeListener(new LifecycleListener());
51
52 }
53
54
55
56 public static Test suite() {
57
58 return (new TestSuite(AbstractSessionBeanTestCase.class));
59
60 }
61
62
63
64 protected void tearDown() throws Exception {
65
66 listener = null;
67 SessionAttributeListener.clear();
68 ConcreteSessionBean.clear();
69 super.tearDown();
70
71 }
72
73
74
75
76
77 SessionAttributeListener listener = null;
78
79
80
81
82
83
84
85 public void testPristine() {
86
87 assertEquals("", SessionAttributeListener.record());
88
89 }
90
91
92
93 public void testProcess() {
94
95 assertEquals("", SessionAttributeListener.record());
96 ConcreteSessionBean bean = new ConcreteSessionBean();
97 assertEquals("", ConcreteSessionBean.record());
98
99 session.setAttribute("bean", bean);
100 assertEquals("attributeAdded(bean,ConcreteSessionBean)//",
101 SessionAttributeListener.record());
102 assertEquals("init()//",
103 ConcreteSessionBean.record());
104
105 session.setAttribute("bean", bean);
106 assertEquals("attributeAdded(bean,ConcreteSessionBean)//" +
107 "attributeReplaced(bean,ConcreteSessionBean)//",
108 SessionAttributeListener.record());
109 assertEquals("init()//destroy()//init()//",
110 ConcreteSessionBean.record());
111
112 session.removeAttribute("bean");
113 assertEquals("attributeAdded(bean,ConcreteSessionBean)//" +
114 "attributeReplaced(bean,ConcreteSessionBean)//" +
115 "attributeRemoved(bean,ConcreteSessionBean)//",
116 SessionAttributeListener.record());
117 assertEquals("init()//destroy()//init()//destroy()//",
118 ConcreteSessionBean.record());
119
120 }
121
122
123 }