1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.krad.compview;
18
19 import com.thoughtworks.selenium.Selenium;
20 import com.thoughtworks.selenium.SeleneseTestCase;
21 import junit.framework.Assert;
22 import org.openqa.selenium.firefox.FirefoxDriver;
23 import org.openqa.selenium.WebDriver;
24 import org.openqa.selenium.WebDriverBackedSelenium;
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28 import java.util.regex.Pattern;
29
30 public class ValidCharsConstraintIT{
31 private Selenium selenium;
32 @Before
33 public void setUp() throws Exception {
34 WebDriver driver = new FirefoxDriver();
35 selenium = new WebDriverBackedSelenium(driver,
36 "http://localhost:8080/kr-dev/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page4");
37
38
39 selenium.open("http://localhost:8080/kr-dev/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page4");
40 Assert.assertEquals("Login", selenium.getTitle());
41 selenium.type("__login_user", "admin");
42 selenium.click("//input[@value='Login']");
43 selenium.waitForPageToLoad("30000");
44 }
45
46 @Test
47 public void testValidCharsConstraintIT() throws Exception {
48 selenium.focus("name=field50");
49 selenium.type("name=field50", "12.333");
50 selenium.fireEvent("name=field50", "blur");
51 Assert.assertTrue(selenium.getAttribute("name=field50@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
52 selenium.focus("name=field50");
53 selenium.type("name=field50", "123.33");
54 selenium.fireEvent("name=field50", "blur");
55 Assert.assertTrue(selenium.getAttribute("name=field50@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
56 selenium.focus("name=field51");
57 selenium.type("name=field51", "A");
58 selenium.fireEvent("name=field51", "blur");
59 Assert.assertTrue(selenium.getAttribute("name=field51@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
60 selenium.focus("name=field51");
61 selenium.type("name=field51", "-123.33");
62 selenium.fireEvent("name=field51", "blur");
63 Assert.assertTrue(selenium.getAttribute("name=field51@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
64 selenium.focus("name=field77");
65 selenium.type("name=field77", "1.1");
66 selenium.fireEvent("name=field77", "blur");
67 Assert.assertTrue(selenium.getAttribute("name=field77@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
68 selenium.focus("name=field77");
69 selenium.type("name=field77", "12");
70 selenium.fireEvent("name=field77", "blur");
71 Assert.assertTrue(selenium.getAttribute("name=field77@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
72 selenium.focus("name=field52");
73 selenium.type("name=field52", "5551112222");
74 selenium.fireEvent("name=field52", "blur");
75 Assert.assertTrue(selenium.getAttribute("name=field52@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
76 selenium.focus("name=field52");
77 selenium.type("name=field52", "555-111-1111");
78 selenium.fireEvent("name=field52", "blur");
79 Assert.assertTrue(selenium.getAttribute("name=field52@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
80 selenium.focus("name=field53");
81 selenium.type("name=field53", "1ClassName.java");
82 selenium.fireEvent("name=field53", "blur");
83 Assert.assertTrue(selenium.getAttribute("name=field53@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
84 selenium.focus("name=field53");
85 selenium.type("name=field53", "ClassName.java");
86 selenium.fireEvent("name=field53", "blur");
87 Assert.assertTrue(selenium.getAttribute("name=field53@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
88 selenium.focus("name=field54");
89 selenium.type("name=field54", "aaaaa");
90 selenium.fireEvent("name=field54", "blur");
91 Assert.assertTrue(selenium.getAttribute("name=field54@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
92 selenium.focus("name=field54");
93 selenium.type("name=field54", "aaaaa@kuali.org");
94 selenium.fireEvent("name=field54", "blur");
95 Assert.assertTrue(selenium.getAttribute("name=field54@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
96 selenium.focus("name=field84");
97 selenium.type("name=field84", "aaaaa");
98 selenium.fireEvent("name=field84", "blur");
99 Assert.assertTrue(selenium.getAttribute("name=field84@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
100 selenium.focus("name=field84");
101 selenium.type("name=field84", "http://www.kuali.org");
102 selenium.fireEvent("name=field84", "blur");
103 Assert.assertTrue(selenium.getAttribute("name=field84@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
104 selenium.focus("name=field55");
105 selenium.type("name=field55", "023512");
106 selenium.fireEvent("name=field55", "blur");
107 Assert.assertTrue(selenium.getAttribute("name=field55@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
108 selenium.focus("name=field55");
109 selenium.type("name=field55", "022812");
110 selenium.fireEvent("name=field55", "blur");
111 Assert.assertTrue(selenium.getAttribute("name=field55@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
112 selenium.focus("name=field75");
113 selenium.type("name=field75", "02/35/12");
114 selenium.fireEvent("name=field75", "blur");
115 Assert.assertTrue(selenium.getAttribute("name=field75@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
116 selenium.focus("name=field75");
117 selenium.type("name=field75", "02/28/12");
118 selenium.fireEvent("name=field75", "blur");
119 Assert.assertTrue(selenium.getAttribute("name=field75@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
120 selenium.focus("name=field82");
121 selenium.type("name=field82", "13:22");
122 selenium.fireEvent("name=field82", "blur");
123 Assert.assertTrue(selenium.getAttribute("name=field82@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
124 selenium.focus("name=field82");
125 selenium.type("name=field82", "02:33");
126 selenium.fireEvent("name=field82", "blur");
127 Assert.assertTrue(selenium.getAttribute("name=field82@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
128 selenium.focus("name=field83");
129 selenium.type("name=field83", "25:22");
130 selenium.fireEvent("name=field83", "blur");
131 Assert.assertTrue(selenium.getAttribute("name=field83@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
132 selenium.focus("name=field83");
133 selenium.type("name=field83", "14:33");
134 selenium.fireEvent("name=field83", "blur");
135 Assert.assertTrue(selenium.getAttribute("name=field83@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
136 selenium.focus("name=field57");
137 selenium.type("name=field57", "0");
138 selenium.fireEvent("name=field57", "blur");
139 Assert.assertTrue(selenium.getAttribute("name=field57@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
140 selenium.focus("name=field57");
141 selenium.type("name=field57", "2020");
142 selenium.fireEvent("name=field57", "blur");
143 Assert.assertTrue(selenium.getAttribute("name=field57@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
144 selenium.focus("name=field58");
145 selenium.type("name=field58", "13");
146 selenium.fireEvent("name=field58", "blur");
147 Assert.assertTrue(selenium.getAttribute("name=field58@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
148 selenium.focus("name=field58");
149 selenium.type("name=field58", "12");
150 selenium.fireEvent("name=field58", "blur");
151 Assert.assertTrue(selenium.getAttribute("name=field58@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
152 selenium.focus("name=field61");
153 selenium.type("name=field61", "5555-444");
154 selenium.fireEvent("name=field61", "blur");
155 Assert.assertTrue(selenium.getAttribute("name=field61@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
156 selenium.focus("name=field61");
157 selenium.type("name=field61", "55555-4444");
158 selenium.fireEvent("name=field61", "blur");
159 Assert.assertTrue(selenium.getAttribute("name=field61@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
160 selenium.focus("name=field62");
161 selenium.type("name=field62", "aa5bb6_a");
162 selenium.fireEvent("name=field62", "blur");
163 Assert.assertTrue(selenium.getAttribute("name=field62@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
164 selenium.focus("name=field62");
165 selenium.type("name=field62", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890");
166 selenium.fireEvent("name=field62", "blur");
167 Assert.assertTrue(selenium.getAttribute("name=field62@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
168 selenium.focus("name=field63");
169 selenium.type("name=field63", "fff555$");
170 selenium.fireEvent("name=field63", "blur");
171 Assert.assertTrue(selenium.getAttribute("name=field63@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
172 selenium.focus("name=field63");
173 selenium.type("name=field63", "aa22 _/");
174 selenium.fireEvent("name=field63", "blur");
175 Assert.assertTrue(selenium.getAttribute("name=field63@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
176 selenium.focus("name=field64");
177 selenium.type("name=field64", "AABB55");
178 selenium.fireEvent("name=field64", "blur");
179 Assert.assertTrue(selenium.getAttribute("name=field64@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
180 selenium.focus("name=field64");
181 selenium.type("name=field64", "ABCDEFGHIJKLMNOPQRSTUVWXY,Z abcdefghijklmnopqrstuvwxy,z");
182 selenium.fireEvent("name=field64", "blur");
183 Assert.assertTrue(selenium.getAttribute("name=field64@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
184 selenium.focus("name=field76");
185 selenium.type("name=field76", "AA~BB%");
186 selenium.fireEvent("name=field76", "blur");
187 Assert.assertTrue(selenium.getAttribute("name=field76@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
188 selenium.focus("name=field76");
189 selenium.type("name=field76", "abcABC %$#@&<>\\{}[]*-+!=.()/\"\"',:;?");
190 selenium.fireEvent("name=field76", "blur");
191 Assert.assertTrue(selenium.getAttribute("name=field76@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
192 selenium.focus("name=field65");
193 selenium.type("name=field65", "sdfs$#$# dsffs");
194 selenium.fireEvent("name=field65", "blur");
195 Assert.assertTrue(selenium.getAttribute("name=field65@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
196 selenium.focus("name=field65");
197 selenium.type("name=field65", "sdfs$#$#sffs");
198 selenium.fireEvent("name=field65", "blur");
199 Assert.assertTrue(selenium.getAttribute("name=field65@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
200 selenium.focus("name=field66");
201 selenium.type("name=field66", "abcABCD");
202 selenium.fireEvent("name=field66", "blur");
203 Assert.assertTrue(selenium.getAttribute("name=field66@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
204 selenium.focus("name=field66");
205 selenium.type("name=field66", "ABCabc");
206 selenium.fireEvent("name=field66", "blur");
207 Assert.assertTrue(selenium.getAttribute("name=field66@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
208 selenium.focus("name=field67");
209 selenium.type("name=field67", "(111)B-(222)A");
210 selenium.fireEvent("name=field67", "blur");
211 Assert.assertTrue(selenium.getAttribute("name=field67@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
212 selenium.focus("name=field67");
213 selenium.type("name=field67", "(12345)-(67890)");
214 selenium.fireEvent("name=field67", "blur");
215 Assert.assertTrue(selenium.getAttribute("name=field67@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
216 selenium.focus("name=field68");
217 selenium.type("name=field68", "A.66");
218 selenium.fireEvent("name=field68", "blur");
219 Assert.assertTrue(selenium.getAttribute("name=field68@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
220 selenium.focus("name=field68");
221 selenium.type("name=field68", "a.4");
222 selenium.fireEvent("name=field68", "blur");
223 Assert.assertTrue(selenium.getAttribute("name=field68@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
224 selenium.focus("name=field56");
225 selenium.type("name=field56", "2020-06-02");
226 selenium.fireEvent("name=field56", "blur");
227 Assert.assertTrue(selenium.getAttribute("name=field56@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
228 selenium.focus("name=field56");
229 selenium.type("name=field56", "2020-06-02 03:30:30.22");
230 selenium.fireEvent("name=field56", "blur");
231 Assert.assertTrue(selenium.getAttribute("name=field56@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
232 }
233
234 @After
235 public void tearDown() throws Exception {
236 selenium.stop();
237 }
238 }