1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package jakarta.faces.component;
20
21 import java.lang.reflect.Method;
22 import java.util.ArrayList;
23 import java.util.Collection;
24
25 import jakarta.faces.context.FacesContext;
26
27 import org.apache.myfaces.Assert;
28 import org.apache.myfaces.TestRunner;
29 import org.apache.myfaces.test.base.junit4.AbstractJsfTestCase;
30 import org.easymock.classextension.EasyMock;
31 import org.easymock.classextension.IMocksControl;
32 import org.junit.Test;
33
34
35
36
37 public class UIComponentEncodeAllTest extends AbstractJsfTestCase
38 {
39 protected IMocksControl _mocksControl;
40 private UIComponent _testimpl;
41
42
43
44 public void setUp() throws Exception
45 {
46 super.setUp();
47 _mocksControl = EasyMock.createNiceControl();
48
49 Collection<Method> mockedMethods = new ArrayList<Method>();
50 Class<UIComponent> clazz = UIComponent.class;
51 mockedMethods.add(clazz.getDeclaredMethod("pushComponentToEL", new Class[] { FacesContext.class, UIComponent.class }));
52 mockedMethods.add(clazz.getDeclaredMethod("isRendered", (Class<?>[])null));
53 mockedMethods.add(clazz.getDeclaredMethod("popComponentFromEL", new Class[] { FacesContext.class }));
54 mockedMethods.add(clazz.getDeclaredMethod("encodeBegin", new Class[] { FacesContext.class }));
55 mockedMethods.add(clazz.getDeclaredMethod("getRendersChildren", (Class<?>[])null));
56 mockedMethods.add(clazz.getDeclaredMethod("encodeChildren", new Class[] { FacesContext.class }));
57 mockedMethods.add(clazz.getDeclaredMethod("getChildren", (Class<?>[])null));
58 mockedMethods.add(clazz.getDeclaredMethod("getChildCount", (Class<?>[])null));
59 mockedMethods.add(clazz.getDeclaredMethod("encodeEnd", new Class[] { FacesContext.class }));
60
61 _testimpl = _mocksControl.createMock(clazz, mockedMethods.toArray(new Method[mockedMethods.size()]));
62 _mocksControl.checkOrder(true);
63 }
64
65 @Test
66 public void testEncodeAllNullContext() throws Exception
67 {
68 Assert.assertException(NullPointerException.class, new TestRunner()
69 {
70 public void run() throws Throwable
71 {
72 _testimpl.encodeAll(null);
73 }
74 });
75 }
76
77 @Test
78 public void testEncodeAllNotRendered() throws Exception
79 {
80
81
82
83
84
85
86 }
87
88 @Test
89 public void testEncodeAllRenderesChildren() throws Exception
90 {
91
92
93
94
95
96
97
98
99
100
101 }
102
103 @Test
104 public void testEncodeAllNotRenderesChildren() throws Exception
105 {
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 }
124 }