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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/**
*
*/
package org.openiaml.model.tests.codegen.model0_5;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.openiaml.model.tests.PhpRuntimeExceptionException;
import org.openiaml.model.tests.codegen.DatabaseCodegenTestCase;

/**
*
* @example DomainIterator
* Navigating with a {@model DomainIterator} using the provided
* {@model BuiltinOperation}s.
* @implementation DomainIterator
* A {@model DomainIterator} must have a limit not equal to 1 in order to
* navigate successfully.
* @author jmwright
*
*/
public class IteratedSyncWires extends DatabaseCodegenTestCase {

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

/**
* The home page can be accessed.
*
* @throws Exception
*/
public void testHome() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();
}

/**
* All of the necessary fields are accessible on the page.
*
* @throws Exception
*/
public void testFormExists() throws Exception {
beginAtSitemapThenPage("Home");

getLabelIDForText("title");
getLabelIDForText("content");
getLabelIDForText("posted");
}

/**
* When loading the page for the first time, we get the first result.
*
* @throws Exception
*/
public void testStartsWithFirst() throws Exception {
beginAtSitemapThenPage("Home");
assertContent1();
}

/**
* Because we are only selecting one result, we should not
* have any navigation results.
*
* @see SelectWireManyPaginate
* @throws Exception
*/
public void testNoPaginationButtons() throws Exception {
beginAtSitemapThenPage("Home");

assertButtonNotPresentWithText("Next");
assertButtonNotPresentWithText("Previous");
assertButtonNotPresentWithText("First");
assertButtonNotPresentWithText("Last");
}

/**
* Check the given content on the page.
*/
private void assertContent(String title, String content, String posted) {
{
String id = getLabelIDForText("title");
assertLabeledFieldEquals(id, title);
}

{
String id = getLabelIDForText("content");
assertLabeledFieldEquals(id, content);
}

{
String id = getLabelIDForText("posted");
assertLabeledFieldEquals(id, posted);
}
}

private void assertContent1() {
assertContent("Title 1", "Content 1", "Fri, 01 Jan 2010 11:11:00 +0000");
}
private void assertContent2() {
assertContent("Title 2", "Content 2", "Mon, 01 Feb 2010 12:11:00 +0000");
}
private void assertContent3() {
assertContent("Title 3", "Content 3", "Sun, 03 Jan 2010 11:13:00 +0000");
}
private void assertNewContent1() {
assertContent("New Title 1", "Content 1", "Fri, 01 Jan 2010 11:11:00 +0000");
}
private void assertNewContent3() {
assertContent("Title 3", "New Content 3", "Sun, 03 Jan 2010 11:13:00 +0000");
}

/**
* Click 'next' to get to the next element.
*
* @throws Exception
*/
public void testNavigateNext() throws Exception {
beginAtSitemapThenPage("Home");

clickButtonWithText("next");
assertNoProblem();

assertContent2();

// and again
clickButtonWithText("next");
assertNoProblem();

assertContent3();

// but if we click it again, we get an error
try {
clickButtonWithText("next");
fail("Should have thrown an exception");
} catch (PhpRuntimeExceptionException e) {
// expected
assertContains("No results found for query", e.getMessage());
}
assertProblem();

}


/**
* Click 'possibly next' to get to the next element.
*
* @throws Exception
*/
public void testNavigatePossiblyNext() throws Exception {
beginAtSitemapThenPage("Home");

clickButtonWithText("possibly next");
assertNoProblem();
assertContent2();

// and again
clickButtonWithText("possibly next");
assertNoProblem();
assertContent3();

// but if we click it again, we won't proceed anywhere
clickButtonWithText("possibly next");
assertNoProblem();
assertContent3();

}

/**
* Click 'next' then 'previous'
*
* @throws Exception
*/
public void testNavigateNextThenPrevious() throws Exception {
beginAtSitemapThenPage("Home");

clickButtonWithText("next");
assertNoProblem();
assertContent2();

clickButtonWithText("previous");
assertNoProblem();
assertContent1();

clickButtonWithText("next");
assertNoProblem();
assertContent2();

}

/**
* Click 'previous' immediately.
*
* @throws Exception
*/
public void testPreviousFails() throws Exception {
beginAtSitemapThenPage("Home");

// but if we click it again, we get an error
try {
clickButtonWithText("previous");
fail("Should have thrown an exception");
} catch (PhpRuntimeExceptionException e) {
// expected
assertContains("Offset cannot be negative", e.getMessage());
}
assertProblem();

}

/**
* Click 'possibly previous' immediately.
*
* @throws Exception
*/
public void testPossiblyPreviousPasses() throws Exception {
beginAtSitemapThenPage("Home");

clickButtonWithText("possibly previous");
assertNoProblem();
assertContent1();

}

/**
* Click 'reset' immediately.
*
* @throws Exception
*/
public void testReset() throws Exception {
beginAtSitemapThenPage("Home");

clickButtonWithText("reset");
assertNoProblem();
assertContent1();

}

/**
* Click 'reset' twice.
*
* @throws Exception
*/
public void testResetTwice() throws Exception {
beginAtSitemapThenPage("Home");

clickButtonWithText("reset");
assertNoProblem();
assertContent1();

clickButtonWithText("reset");
assertNoProblem();
assertContent1();

}

/**
* 'Next', 'next', 'reset', 'next'
*
* @throws Exception
*/
public void testNextNextResetNext() throws Exception {
beginAtSitemapThenPage("Home");

clickButtonWithText("next");
assertNoProblem();
assertContent2();

// and again
clickButtonWithText("next");
assertNoProblem();
assertContent3();

// reset
clickButtonWithText("reset");
assertNoProblem();
assertContent1();

// and again
clickButtonWithText("next");
assertNoProblem();
assertContent2();

}

/**
* 'Next', 'previous', 'reset', 'next'
*
* @throws Exception
*/
public void testNextPreviousResetNext() throws Exception {
beginAtSitemapThenPage("Home");

clickButtonWithText("possibly next");
assertNoProblem();
assertContent2();

// and again
clickButtonWithText("previous");
assertNoProblem();
assertContent1();

// reset
clickButtonWithText("reset");
assertNoProblem();
assertContent1();

// and again
clickButtonWithText("possibly next");
assertNoProblem();
assertContent2();

}

/**
* Update the content of the first entry.
*
* @throws Exception
*/
public void testEditingFirst() throws Exception {
IFile sitemap = beginAtSitemapThenPage("Home");
assertContent1();

{
String id = getLabelIDForText("title");
setLabeledFormElementField(id, "New Title 1");
assertLabeledFieldEquals(id, "New Title 1");
}

clickButtonWithText("save current");
assertNoProblem();

assertNewContent1();

// next
clickButtonWithText("possibly next");
assertNoProblem();
assertContent2();

// previous
clickButtonWithText("possibly previous");
assertNoProblem();
assertNewContent1();

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

/**
* Update the content of the third entry entry.
*
* @throws Exception
*/
public void testEditingThird() throws Exception {
IFile sitemap = beginAtSitemapThenPage("Home");

clickButtonWithText("possibly next"); // to #2
clickButtonWithText("possibly next"); // to #3

{
String id = getLabelIDForText("content");
setLabeledFormElementField(id, "New Content 3");
}

clickButtonWithText("save current");
assertNoProblem();

assertNewContent3();

// next
clickButtonWithText("possibly next");
assertNoProblem();
assertNewContent3();

// previous
clickButtonWithText("possibly previous");
assertNoProblem();
assertContent2();

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

// next
clickButtonWithText("possibly next");
assertNoProblem();
assertNewContent3();
}

@Override
protected List<String> getDatabaseInitialisers() {
List<String> s = new ArrayList<String>();
s.add("CREATE TABLE News (generated_primary_key INTEGER PRIMARY KEY AUTOINCREMENT, title VARCHAR(64) NOT NULL, content VARCHAR(64) NOT NULL, posted VARCHAR(64) NOT NULL)");
s.add("INSERT INTO News (generated_primary_key, title, content, posted) VALUES (1, 'Title 1', 'Content 1', '2010-01-01 11:11:00 +0000')");
s.add("INSERT INTO News (generated_primary_key, title, content, posted) VALUES (2, 'Title 2', 'Content 2', '2010-02-01 12:11:00 +0000')");
s.add("INSERT INTO News (generated_primary_key, title, content, posted) VALUES (3, 'Title 3', 'Content 3', '2010-01-03 11:13:00 +0000')");
return s;
}

}

Change log

r3072 by soundasleep on Aug 8, 2011   Diff
fixing references to old metamodel
elements across project documentation
Go to: 
Project members, sign in to write a code review

Older revisions

r2154 by soundasleep on May 10, 2010   Diff
removing all explicit definitions of
getDatabaseName(), since 'default.db'
is now used by default (r2152)
r2122 by soundasleep on May 5, 2010   Diff
IteratedSyncWires test case needs to
have a limit set, or else it cannot be
navigated
r1961 by soundasleep on Apr 19, 2010   Diff
updating IteratedSyncWires test case
to use date data types correctly
All revisions of this file

File info

Size: 9386 bytes, 408 lines
Powered by Google Project Hosting