My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/**
*
*/
package org.openiaml.model.tests.codegen.model0_4_4;

import org.eclipse.core.resources.IFile;

/**
* @example SyncWire,InputTextField
* {@model SyncWire}s connected between {@model InputTextField}s of
* different types.
*/
public class InputTextFieldDataTypeSync extends WarningEnabledCodegenTestCase {

@Override
protected void setUp() throws Exception {
super.setUp();
root = loadAndCodegen(InputTextFieldDataTypeSync.class);
}

/**
* The home page can be accessed.
*
* @throws Exception
*/
public void testHome() throws Exception {

beginAtSitemapThenPage("Home");
assertNoProblem();

}

/**
* If we just load the page, and then just reload it, no warnings
* should show.
*
* @throws Exception
*/
public void testReloadingPageDoesntShowErrors() throws Exception {
IFile sitemap = beginAtSitemapThenPage("Home");
assertNoProblem();

// reload
reloadPage(sitemap, "Home");
assertNoProblem();

// restart session
restartSession(sitemap, "Home");
assertNoProblem();
}

/**
* Default to String shouldn't have any problems.
*/
public void testDefaultToString() throws Exception {
doInputWithNoWarnings("Default", "String", "hello, world!", "hello, world!");
}

/**
* String to Default shouldn't have any problems.
*/
public void testStringToDefault() throws Exception {
doInputWithNoWarnings("String", "Default", "hello, world!", "hello, world!");
}

/**
* String 2 to Email, with a valid input, shouldn't have any problems.
*/
public void testStringToEmailValid() throws Exception {
doInputWithNoWarnings("String 2", "Email", "test@openiaml.org", "test@openiaml.org");
}

/**
* String 2 to Email, with an invalid input, should have a problem.
*/
public void testStringToEmailInvalid() throws Exception {
doInputWithWarnings("String 2", "Email", "invalid e-mail address");
}

/**
* Email 2 to Integer, with an invalid input, should have a problem.
*/
public void testEmailToIntegerInvalid() throws Exception {
doInputWithWarnings("Email 2", "Integer", "test@openiaml.org");
}

/**
* Email 2 to Integer, with an invalid input, should revert back
* before it can even be passed along.
*/
public void testEmailToIntegerInvalid2() throws Exception {
beginAtSitemapThenPage("Home");
{
String target = getLabelIDForText("Email 2");
assertLabeledFieldEquals(target, ""); // empty

// we can set it to a string
setLabeledFormElementField(target, "123");

// it will revert back
assertLabeledFieldEquals(target, "");
}

// but no warning will be displayed
assertNoProblem();

// and the target value should be as expected
{
String target = getLabelIDForText("Integer", "Integer 2");
assertLabeledFieldEquals(target, ""); // should not change
}
}

/**
* If we insert an invalid input, a warning will display.
* If we however then set it to a valid input, the warning will disappear.
*/
public void testStringToEmailInvalidThenValid() throws Exception {
IFile sitemap = doInputWithWarnings("String 2", "Email", "invalid e-mail address");

// now insert in a valid e-mail address
{
String target = getLabelIDForText("String 2");
assertLabeledFieldEquals(target, "invalid e-mail address"); // from previous call

// we can set it to a string
setLabeledFormElementField(target, "test@openiaml.org");
assertLabeledFieldEquals(target, "test@openiaml.org");
}

// there should NOT be any warnings
assertNoProblem();

// and the target value should be as expected
{
String target = getLabelIDForText("Email", "Email 2");
assertLabeledFieldEquals(target, "test@openiaml.org");
}

// even if we reload the page
reloadPage(sitemap, "Home");
assertNoProblem();
{
String target = getLabelIDForText("String 2");
assertLabeledFieldEquals(target, "test@openiaml.org");
}
{
String target = getLabelIDForText("Email", "Email 2");
assertLabeledFieldEquals(target, "test@openiaml.org");
}

}

/**
* If we enter in an invalid input, and refresh the page, the invalid
* input should not automatically be loaded into a field that cannot
* support it.
*
* @throws Exception
*/
public void testInvalidInputDoesNotShowOnInit() throws Exception {

// set the Integer to a field
// 'Email 2' will remain blank
IFile sitemap = doInputWithWarnings("Integer", "Email 2", "12345");

// reload the page
reloadPage(sitemap, "Home");

{
String target = getLabelIDForText("Integer", "Integer 2");
assertLabeledFieldEquals(target, "12345");
}

// e-mail should still be blank
{
String target = getLabelIDForText("Email 2");
assertLabeledFieldEquals(target, "");
}

// and there should be a problem
assertProblem();
assertMatch("Invalid input.");

}

/**
* Enter in 'input' into 'fieldName'. No warnings should
* occur, and the target 'targetName' should be updated to the
* 'expected' value.
*
* @param fieldName
* @param targetName
* @param input
* @param expected
* @throws Exception
*/
protected void doInputWithNoWarnings(String fieldName, String targetName, String input, String expected) throws Exception {

beginAtSitemapThenPage("Home");
assertNoProblem();
{
String target = getLabelIDForText(fieldName, fieldName + " 2");
assertLabeledFieldEquals(target, ""); // empty

// we can set it to a string
setLabeledFormElementField(target, input);
assertLabeledFieldEquals(target, input);
}

// there should NOT be any warnings
assertNoProblem();

// and the target value should be as expected
{
String target = getLabelIDForText(targetName, fieldName + " 2");
assertLabeledFieldEquals(target, expected);
}

}

/**
* Enter in 'input' into 'fieldName'. A warning should occur, and the
* target 'targetName' should NOT be changed (i.e. remain empty).
*
* @param fieldName
* @param targetName
* @param input
* @throws Exception
* @returns the sitemap
*/
protected IFile doInputWithWarnings(String fieldName, String targetName, String input) throws Exception {
return doInputWithWarnings(fieldName, targetName, input, input);
}

/**
* Enter in 'input' into 'fieldName'. A warning should occur, and the
* target 'targetName' should NOT be changed (i.e. remain empty).
* Expect that 'fieldName' will revert back to 'expected'.
*
* @param fieldName
* @param targetName
* @param input
* @throws Exception
* @returns the sitemap
*/
protected IFile doInputWithWarnings(String fieldName, String targetName, String input, String expectedInput) throws Exception {
IFile sitemap = beginAtSitemapThenPage("Home");
assertNoProblem();
{
String target = getLabelIDForText(fieldName, fieldName + " 2");
assertLabeledFieldEquals(target, ""); // empty

// we can set it to a string
setLabeledFormElementField(target, input);

// it may be reverted
assertLabeledFieldEquals(target, expectedInput);
}

// there should be a warning
assertProblem();
assertMatch("Invalid input.");

// and the target value should be as expected
{
String target = getLabelIDForText(targetName, fieldName + " 2");
assertLabeledFieldEquals(target, ""); // should not change
}

return sitemap;

}


}

Change log

r2659 by soundasleep on Apr 10, 2011   Diff
improving some failing codegen tests
Go to: 
Project members, sign in to write a code review

Older revisions

r1726 by soundasleep on Mar 16, 2010   Diff
adding
InputTextFieldDataTypeSyncDirect test
case
r1711 by soundasleep on Mar 15, 2010   Diff
InputTextField.onAccess should call
validate (but only if the fieldValue
has been set)
'update', 'init' operations now
explicitly cast input parameters
r1708 by soundasleep on Mar 15, 2010   Diff
adding more codegen tests to
InputTextFieldDataTypeSync
adding additional inference tests
All revisions of this file

File info

Size: 7622 bytes, 276 lines
Powered by Google Project Hosting