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
19
20 package org.apache.shale.examples.test.core.systest;
21
22 import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
23 import com.gargoylesoftware.htmlunit.html.HtmlElement;
24 import com.gargoylesoftware.htmlunit.html.HtmlHiddenInput;
25 import com.gargoylesoftware.htmlunit.html.HtmlPage;
26 import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
27 import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
28 import junit.framework.Test;
29 import junit.framework.TestSuite;
30 import org.apache.shale.test.cargo.CargoTestSetup;
31 import org.apache.shale.test.htmlunit.AbstractHtmlUnitTestCase;
32
33 /***
34 * <p>Integration tests for the Shale Core Library.</p>
35 */
36 public class IntegrationTestCase extends AbstractHtmlUnitTestCase {
37
38
39
40
41
42 /***
43 * <p>Construct a new instance of this test case.</p>
44 *
45 * @param name Name of the new test case
46 */
47 public IntegrationTestCase(String name) {
48
49 super(name);
50
51 }
52
53
54
55
56
57 /***
58 * <p>Set up the instance variables required for this test case.</p>
59 */
60 protected void setUp() throws Exception {
61
62 super.setUp();
63 page("/");
64
65 }
66
67
68 /***
69 * <p>Return the set of tests included in this test suite.</p>
70 */
71 public static Test suite() {
72
73 return new CargoTestSetup(new TestSuite(IntegrationTestCase.class));
74
75 }
76
77
78 /***
79 * <p>Tear down instance variables required by this test case.</p>
80 */
81 protected void tearDown() throws Exception {
82
83 super.tearDown();
84
85 }
86
87
88
89
90
91
92
93 public void testMenu() throws Exception {
94
95 assertEquals("Shale Test App (Core Library)", title());
96
97 }
98
99
100
101
102
103 public void testTokenInvalid() throws Exception {
104
105 HtmlTextInput input;
106 HtmlSubmitInput submit;
107 page("/token1.faces");
108
109
110 assertEquals("Token Processor Test (Page 1)", title());
111 input = (HtmlTextInput) element("form:input");
112 assertNotNull(input);
113
114 submit = (HtmlSubmitInput) element("form:submit");
115 assertNotNull(submit);
116 submit(submit);
117
118
119 assertEquals("Token Processor Test (Page 1)", title());
120 input = (HtmlTextInput) element("form:input");
121 assertNotNull(input);
122
123 submit = (HtmlSubmitInput) element("form:submit");
124 assertNotNull(submit);
125 submit(submit);
126
127
128 assertEquals("Token Processor Test (Page 1)", title());
129 input = (HtmlTextInput) element("form:input");
130 assertNotNull(input);
131 input.setValueAttribute("abc");
132 submit = (HtmlSubmitInput) element("form:submit");
133 assertNotNull(submit);
134 submit(submit);
135
136
137 assertEquals("Token Processor Test (Page 2)", title());
138 input = (HtmlTextInput) element("form:input");
139 assertNotNull(input);
140 input.setValueAttribute("abcdef");
141 submit = (HtmlSubmitInput) element("form:submit");
142 assertNotNull(submit);
143 submit(submit);
144
145
146 assertEquals("Token Processor Test (Page 2)", title());
147 input = (HtmlTextInput) element("form:input");
148 assertNotNull(input);
149 input.setValueAttribute("abcdef");
150 submit = (HtmlSubmitInput) element("form:submit");
151 assertNotNull(submit);
152 submit(submit);
153
154
155 assertEquals("Token Processor Test (Page 2)", title());
156 input = (HtmlTextInput) element("form:input");
157 assertNotNull(input);
158 input.setValueAttribute("abcd");
159 submit = (HtmlSubmitInput) element("form:submit");
160 assertNotNull(submit);
161 submit(submit);
162
163
164 assertEquals("Shale Test App (Core Library)", title());
165
166 }
167
168
169
170 public void testTokenValid() throws Exception {
171
172 HtmlTextInput input;
173 HtmlSubmitInput submit;
174 page("/token1.faces");
175
176
177 assertEquals("Token Processor Test (Page 1)", title());
178 input = (HtmlTextInput) element("form:input");
179 assertNotNull(input);
180 input.setValueAttribute("abc");
181 submit = (HtmlSubmitInput) element("form:submit");
182 assertNotNull(submit);
183 submit(submit);
184
185
186 assertEquals("Token Processor Test (Page 2)", title());
187 assertNotNull(input);
188 input.setValueAttribute("abc");
189 submit = (HtmlSubmitInput) element("form:submit");
190 assertNotNull(submit);
191 submit(submit);
192
193
194 assertEquals("Shale Test App (Core Library)", title());
195
196 }
197
198
199
200 public void testTokenResubmit() throws Exception {
201
202 HtmlHiddenInput hidden;
203 HtmlTextInput input;
204 HtmlSubmitInput submit;
205 page("/token1.faces");
206
207
208 assertEquals("Token Processor Test (Page 1)", title());
209 input = (HtmlTextInput) element("form:input");
210 assertNotNull(input);
211 input.setValueAttribute("abc");
212 hidden = (HtmlHiddenInput) element("form:token");
213 assertNotNull(hidden);
214 submit = (HtmlSubmitInput) element("form:submit");
215 assertNotNull(submit);
216 HtmlPage page = page();
217 submit(submit);
218
219
220 assertEquals("Token Processor Test (Page 2)", title());
221
222
223 reset(page);
224 assertEquals("Token Processor Test (Page 1)", title());
225 hidden = (HtmlHiddenInput) element("form:token");
226 assertNotNull(hidden);
227 submit = (HtmlSubmitInput) element("form:submit");
228 assertNotNull(submit);
229 submit(submit);
230
231
232 assertEquals("Token Processor Test (Page 1)", title());
233
234 }
235
236
237 }