1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.trinidad.component;
20
21 import javax.faces.context.FacesContext;
22
23 import junit.framework.Test;
24 import junit.framework.TestSuite;
25 import junit.textui.TestRunner;
26
27 import org.apache.myfaces.trinidad.component.UIComponentTestCase;
28 import org.apache.myfaces.trinidad.component.UIXTableTest.DoNotCallBinding;
29 import org.apache.myfaces.trinidad.context.MockRequestContext;
30
31
32
33
34
35 public class UIXTreeTest extends UIComponentTestCase
36 {
37
38
39
40 public UIXTreeTest(
41 String testName)
42 {
43 super(testName);
44 }
45
46
47
48 private MockRequestContext _mafct;
49
50 @Override
51 public void setUp() throws Exception
52 {
53 super.setUp();
54 _mafct = new MockRequestContext();
55 }
56
57 @Override
58 public void tearDown() throws Exception
59 {
60 _mafct.release();
61 _mafct = null;
62 super.tearDown();
63 }
64
65
66 public static Test suite()
67 {
68 return new TestSuite(UIXTreeTest.class);
69 }
70
71
72
73
74
75
76
77
78
79 public void testSaveRestoreStateGetValue()
80 {
81
82 DoNotCallBinding doNotCall = new DoNotCallBinding();
83 doNotCall.doNotCall = true;
84 final Object state;
85 {
86 UIXTree tree = _createTree();
87 tree.setValueBinding("value", doNotCall);
88 state = tree.processSaveState(facesContext);
89 }
90
91 UIXTree tree = _createTree();
92
93
94
95 tree.setValueBinding("value", doNotCall);
96 tree.processRestoreState(facesContext, state);
97
98 assertTrue(tree.getValueBinding("value") instanceof DoNotCallBinding);
99
100 }
101
102 @Override
103 public void setCurrentContext(FacesContext fc)
104 {
105
106 if (fc != null)
107 super.setCurrentContext(fc);
108 }
109
110
111 public static void main(String[] args)
112 {
113 TestRunner.run(UIXTreeTest.class);
114 }
115
116 @Override
117 protected boolean isRendererUsed()
118 {
119
120 return false;
121 }
122
123 private UIXTree _createTree()
124 {
125 UIXTree tree = new UIXTree();
126 return tree;
127 }
128
129 }