View Javadoc

1   /*
2    * Copyright 2006-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package edu.samplu.krad.compview;
18  
19  import edu.samplu.common.UpgradedSeleniumITBase;
20  import junit.framework.Assert;
21  import org.junit.Test;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class ContraintsIT extends UpgradedSeleniumITBase {
27  
28      @Override
29      public String getTestUrl() {
30          return "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3";
31      }
32  
33      @Test
34      public void testContraintsIT() throws Exception {
35          selenium.focus("name=field9");
36          selenium.type("name=field9", "1");
37          selenium.fireEvent("name=field9", "blur");
38          Assert.assertTrue(selenium.getAttribute("name=field9@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
39          selenium.focus("name=field9");
40          selenium.type("name=field9", "12345");
41          selenium.fireEvent("name=field9", "blur");
42          Assert.assertTrue(selenium.getAttribute("name=field9@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
43          selenium.focus("name=field10");
44          selenium.type("name=field10", "2");
45          selenium.fireEvent("name=field10", "blur");
46          Assert.assertTrue(selenium.getAttribute("name=field10@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
47          selenium.focus("name=field10");
48          selenium.type("name=field10", "51");
49          selenium.fireEvent("name=field10", "blur");
50          Assert.assertTrue(selenium.getAttribute("name=field10@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
51          selenium.focus("name=field10");
52          selenium.type("name=field10", "25");
53          selenium.fireEvent("name=field10", "blur");
54          Assert.assertTrue(selenium.getAttribute("name=field10@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
55          selenium.focus("name=field6");
56          selenium.type("name=field6", "A");
57          selenium.fireEvent("name=field6", "blur");
58          selenium.fireEvent("name=field7", "blur");
59          Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
60          selenium.type("name=field7", "B");
61          selenium.fireEvent("name=field7", "blur");
62          Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
63          selenium.fireEvent("name=field8", "blur");
64          Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
65          selenium.type("name=field8", "C");
66          selenium.fireEvent("name=field8", "blur");
67          Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
68          selenium.type("name=field6", "");
69          selenium.fireEvent("name=field6", "blur");
70          Assert.assertTrue(selenium.getAttribute("name=field6@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
71          selenium.type("name=field7", "");
72          selenium.fireEvent("name=field7", "blur");
73          Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
74          selenium.type("name=field8", "");
75          selenium.fireEvent("name=field8", "blur");
76          Assert.assertTrue(selenium.getAttribute("name=field6@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
77          Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
78          Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
79          selenium.type("name=field8", "C");
80          selenium.fireEvent("name=field8", "blur");
81          Assert.assertTrue(selenium.getAttribute("name=field6@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
82          Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
83          Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
84          selenium.type("name=field6", "A");
85          selenium.fireEvent("name=field6", "blur");
86          Assert.assertTrue(selenium.getAttribute("name=field6@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
87          Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
88          Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
89          selenium.type("name=field14", "A");
90          selenium.fireEvent("name=field14", "blur");
91          Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
92          selenium.type("name=field11", "A");
93          selenium.fireEvent("name=field11", "blur");
94          Assert.assertTrue(selenium.getAttribute("name=field11@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
95          Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
96          selenium.type("name=field11", "");
97          selenium.fireEvent("name=field11", "blur");
98          Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
99          selenium.type("name=field12", "A");
100         selenium.fireEvent("name=field12", "blur");
101         Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
102         selenium.type("name=field13", "A");
103         selenium.fireEvent("name=field13", "blur");
104         Assert.assertTrue(selenium.getAttribute("name=field13@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
105         Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
106         selenium.type("name=field11", "A");
107         selenium.fireEvent("name=field11", "blur");
108         Assert.assertTrue(selenium.getAttribute("name=field11@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
109         Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
110         selenium.type("name=field18", "A");
111         selenium.fireEvent("name=field18", "blur");
112         Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
113         selenium.type("name=field15", "A");
114         selenium.fireEvent("name=field15", "blur");
115         Assert.assertTrue(selenium.getAttribute("name=field15@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
116         Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
117         selenium.type("name=field15", "");
118         selenium.fireEvent("name=field15", "blur");
119         Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
120         selenium.type("name=field16", "A");
121         selenium.fireEvent("name=field16", "blur");
122         Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
123         selenium.type("name=field17", "A");
124         selenium.fireEvent("name=field17", "blur");
125         Assert.assertTrue(selenium.getAttribute("name=field17@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
126         Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
127         selenium.type("name=field15", "A");
128         selenium.fireEvent("name=field15", "blur");
129         Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
130         selenium.type("name=field23", "A");
131         selenium.fireEvent("name=field23", "blur");
132         Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
133         selenium.type("name=field19", "A");
134         selenium.fireEvent("name=field19", "blur");
135         Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
136         selenium.type("name=field19", "");
137         selenium.fireEvent("name=field19", "blur");
138         selenium.type("name=field20", "B");
139         selenium.fireEvent("name=field20", "blur");
140         Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
141         selenium.type("name=field20", "");
142         selenium.fireEvent("name=field20", "blur");
143         Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
144         selenium.type("name=field21", "C");
145         selenium.fireEvent("name=field21", "blur");
146         Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
147         selenium.type("name=field22", "D");
148         selenium.fireEvent("name=field22", "blur");
149         Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
150         selenium.type("name=field19", "D");
151         selenium.fireEvent("name=field19", "blur");
152         Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
153         selenium.type("name=field20", "D");
154         selenium.fireEvent("name=field20", "blur");
155         Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
156         selenium.check("name=field24 value=case1");
157         selenium.type("name=field25", "");
158         selenium.fireEvent("name=field25", "blur");
159         Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
160         selenium.check("name=field24 value=case4");
161         selenium.fireEvent("name=field24", "blur");
162         for (int second = 0; ; second++) {
163             if (second >= 60) {
164                 Assert.fail("timeout");
165             }
166             try {
167                 if (selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
168                     break;
169                 }
170             } catch (Exception e) {
171             }
172             Thread.sleep(1000);
173         }
174 
175         Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
176         selenium.check("name=field24 value=case1");
177         selenium.fireEvent("name=field24", "blur");
178         selenium.type("name=field25", "$100");
179         selenium.fireEvent("name=field25", "blur");
180         for (int second = 0; ; second++) {
181             if (second >= 60) {
182                 Assert.fail("timeout");
183             }
184             try {
185                 if (selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
186                     break;
187                 }
188             } catch (Exception e) {
189             }
190             Thread.sleep(1000);
191         }
192 
193         Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
194         selenium.check("name=field24 value=case2");
195         selenium.fireEvent("name=field24", "blur");
196         for (int second = 0; ; second++) {
197             if (second >= 60) {
198                 Assert.fail("timeout");
199             }
200             try {
201                 if (selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
202                     break;
203                 }
204             } catch (Exception e) {
205             }
206             Thread.sleep(1000);
207         }
208 
209         Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
210         selenium.type("name=field25", "A100");
211         selenium.fireEvent("name=field25", "blur");
212         Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
213         selenium.check("name=field24 value=case3");
214         selenium.fireEvent("name=field24", "blur");
215         selenium.type("name=field26", "6000");
216         selenium.fireEvent("name=field26", "blur");
217         for (int second = 0; ; second++) {
218             if (second >= 60) {
219                 Assert.fail("timeout");
220             }
221             try {
222                 if (selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
223                     break;
224                 }
225             } catch (Exception e) {
226             }
227             Thread.sleep(1000);
228         }
229 
230         Assert.assertTrue(selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
231         selenium.type("name=field26", "501");
232         selenium.fireEvent("name=field26", "blur");
233         Assert.assertTrue(selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
234         selenium.type("name=field26", "499");
235         selenium.fireEvent("name=field26", "blur");
236         Assert.assertTrue(selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
237         selenium.type("name=field26", "6000");
238         selenium.fireEvent("name=field26", "blur");
239         selenium.check("name=field24 value=case3");
240         selenium.fireEvent("name=field24", "blur");
241         for (int second = 0; ; second++) {
242             if (second >= 60) {
243                 Assert.fail("timeout");
244             }
245             try {
246                 if (selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
247                     break;
248                 }
249             } catch (Exception e) {
250             }
251             Thread.sleep(1000);
252         }
253 
254         Assert.assertTrue(selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
255         selenium.check("name=field24 value=case4");
256         selenium.type("name=field27", "A");
257         selenium.fireEvent("name=field27", "blur");
258         selenium.type("name=field28", "");
259         selenium.fireEvent("name=field28", "blur");
260         for (int second = 0; ; second++) {
261             if (second >= 60) {
262                 Assert.fail("timeout");
263             }
264             try {
265                 if (selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
266                     break;
267                 }
268             } catch (Exception e) {
269             }
270             Thread.sleep(1000);
271         }
272 
273         Assert.assertTrue(selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
274         selenium.check("name=field24 value=case3");
275         selenium.fireEvent("name=field24", "blur");
276         for (int second = 0; ; second++) {
277             if (second >= 60) {
278                 Assert.fail("timeout");
279             }
280             try {
281                 if (selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
282                     break;
283                 }
284             } catch (Exception e) {
285             }
286             Thread.sleep(1000);
287         }
288 
289         Assert.assertTrue(selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
290         selenium.type("name=field28", "B");
291         selenium.fireEvent("name=field28", "blur");
292         selenium.check("name=field24 value=case4");
293         selenium.fireEvent("name=field24", "blur");
294         for (int second = 0; ; second++) {
295             if (second >= 60) {
296                 Assert.fail("timeout");
297             }
298             try {
299                 if (selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
300                     break;
301                 }
302             } catch (Exception e) {
303             }
304             Thread.sleep(1000);
305         }
306 
307         Assert.assertTrue(selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
308         selenium.type("name=field31", "B");
309         selenium.type("name=field32", "B");
310         selenium.fireEvent("name=field33", "blur");
311         Assert.assertTrue(selenium.getAttribute("name=field33@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
312         selenium.type("name=field33", "B");
313         selenium.fireEvent("name=field33", "blur");
314         Assert.assertTrue(selenium.getAttribute("name=field33@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
315         selenium.type("name=field32", "A");
316         selenium.type("name=field33", "");
317         selenium.fireEvent("name=field33", "blur");
318         Assert.assertTrue(selenium.getAttribute("name=field33@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
319     }
320 }