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 java.io.IOException;
22
23 import javax.faces.component.EditableValueHolder;
24
25 import org.apache.myfaces.trinidad.component.UIXComponent;
26
27 /**
28 * Base class for unit tests for UIXEditableValue components.
29 *
30 */
31 abstract public class UIXEditableValueTestCase extends UIComponentTestCase
32 {
33 /**
34 * Creates a UIXEditableValueTestCase.
35 *
36 * @param testName the unit test name
37 */
38 public UIXEditableValueTestCase(
39 String testName)
40 {
41 super(testName);
42 }
43
44 @SuppressWarnings("cast")
45 public void testInterfaces()
46 {
47 UIXEditableValue component = createEditableValue();
48 assertTrue(component instanceof EditableValueHolder);
49 }
50
51 /**
52 * Tests the initial values for the component attributes.
53 */
54 public void testInitialAttributeValues()
55 {
56 UIXEditableValue component = createEditableValue();
57 assertEquals(false, component.isTransient());
58 assertEquals(true, component.isValid());
59 assertEquals(true, component.isRendered());
60 assertEquals(null, component.getValue());
61 assertEquals(null, component.getLocalValue());
62 assertEquals(null, component.getSubmittedValue());
63 assertEquals(false, component.isLocalValueSet());
64 }
65
66 /**
67 * Tests that the constants stored on the component class definition
68 * are identical to the instances retrieved dynamically from the component
69 * storage type.
70 */
71 public void testTypeKeyInstances()
72 {
73 UIXEditableValue component = createEditableValue();
74 assertSame(component.getFacesBean().getType().findKey("value"),
75 UIXEditableValue.VALUE_KEY);
76 }
77
78 /**
79 * Tests the transparency of component attributes.
80 *
81 * @todo remaining attributes
82 */
83 public void testAttributeTransparency()
84 {
85
86
87 }
88
89 /**
90 * Tests the apply-request-values lifecycle phase.
91 */
92 public void testApplyRequestValues()
93 {
94 doTestApplyRequestValues(createEditableValue());
95
96 UIXEditableValue component = createEditableValue();
97 component.setRendered(false);
98 doTestApplyRequestValues(component);
99 }
100
101 /**
102 * Tests the process-validations lifecycle phase.
103 */
104 public void testProcessValidations()
105 {
106 doTestProcessValidations(createEditableValue());
107 }
108
109 /**
110 * Tests the update-model-values lifecycle phase.
111 */
112 public void testUpdateModelValues()
113 {
114 doTestUpdateModelValues(createEditableValue());
115 }
116
117 /**
118 * Tests the invoke-application lifecycle phase.
119 */
120 public void testInvokeApplication()
121 {
122 UIXEditableValue component = createEditableValue();
123
124 doTestInvokeApplication(component, null);
125 }
126
127 /**
128 * Tests the render-response lifecycle phase.
129 *
130 * @throws IOException when test fails
131 */
132 public void testRenderResponse() throws IOException
133 {
134 doTestRenderResponse(createEditableValue());
135 }
136
137 protected final UIXComponent createComponent()
138 {
139 return createEditableValue();
140 }
141
142 abstract protected UIXEditableValue createEditableValue();
143 }