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.usecases.systest;
19
20 import com.gargoylesoftware.htmlunit.html.HtmlElement;
21 import com.gargoylesoftware.htmlunit.html.HtmlForm;
22 import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Locale;
26
27 import junit.framework.Test;
28 import junit.framework.TestSuite;
29 import org.apache.shale.test.cargo.CargoTestSetup;
30
31 /***
32 * <p>Test case for view controller lifecycle callbacks testing.</p>
33 */
34 public class ViewControllerTestCase extends AbstractTestCase {
35
36
37
38
39
40
41 public ViewControllerTestCase(String name) {
42 super(name);
43 }
44
45
46
47
48
49
50 protected void setUp() throws Exception {
51
52 super.setUp();
53 page("/view/test.faces");
54
55 }
56
57
58 public static Test suite() {
59
60 return new CargoTestSetup(new TestSuite(ViewControllerTestCase.class));
61
62 }
63
64
65
66 protected void tearDown() throws Exception {
67
68 super.tearDown();
69
70 }
71
72
73
74
75
76 /***
77 * <p>Validate pristine instance of the test page.</p>
78 */
79 public void testPristine() throws Exception {
80
81 HtmlForm form = null;
82 HtmlElement text = null;
83 HtmlSubmitInput submit = null;
84
85
86 assertEquals("View Controller Test", title());
87 form = (HtmlForm) element("form");
88 assertNotNull(form);
89 text = element("form:text");
90 assertNotNull(text);
91 submit = (HtmlSubmitInput) element("form:submit");
92 assertNotNull(submit);
93
94
95
96
97
98 assertEquals("init/false/prerender/false/", text.asText());
99
100 }
101
102
103 /***
104 * <p>Submit the page and validate the results.</p>
105 */
106 public void testSubmit() throws Exception {
107
108
109 assertEquals("View Controller Test", title());
110
111
112 HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");
113 submit(submit);
114
115
116 assertEquals("View Controller Test", title());
117 HtmlElement text = element("form:text");
118 assertNotNull(text);
119 assertEquals("init/true/preprocess/true/submit/true/prerender/true/", text.asText());
120
121 }
122
123
124 }