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
/**
*
*/
package org.openiaml.model.tests.codegen.model0_5_2;

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

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


/**
* DomainIterators can be searched, and the results displayed in
* a IteratorList instantly (through AJAX).
*
*/
public class IteratorListSetWireSearch extends DatabaseCodegenTestCase {

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

/**
* The home page can be accessed.
* The results are returned in order of ID ascending.
*
* @throws Exception
*/
public void testHome() throws Exception {
newsCount = 12;
initialiseDatabase();
beginAtSitemapThenPage("Home");
assertNoProblem();

// first set the query to the empty string ''
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, "");
}

// check the content on the page
assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextExactlyPresent("Title 2");
assertLabelTextExactlyPresent("Content 2");
assertLabelTextExactlyPresent("Title 3");
assertLabelTextExactlyPresent("Content 3");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");
}

/**
* If we access the home page without setting a query, the
* query is currently <code>null</code>, so there will be no results.
*
* @implementation DomainIterator
* Incoming {@model Parameter}s into a {@model DomainIterator}
* can be <code>null</code>; this may cause some queries to fail
* (e.g. <em>matches(a, <code>null</code>)</em> will return no results).
*
* @throws Exception
*/
public void testHomeNull() throws Exception {
newsCount = 12;
initialiseDatabase();
beginAtSitemapThenPage("Home");
assertNoProblem();

// no results are visible
assertLabelTextNotPresent("Title 1");
assertLabelTextNotPresent("Content 1");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");
}

/**
* Search for '1'.
*
* @throws Exception
*/
public void testSearch1() throws Exception {
// go to the home page
testHome();

// enter in the query
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, "1");
}

// this will search for '1'
assertNoProblem();

// check the content on the page
assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextExactlyPresent("Title 10");
assertLabelTextExactlyPresent("Content 10");
assertLabelTextExactlyPresent("Title 11");
assertLabelTextExactlyPresent("Content 11");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertLabelTextNotPresent("Title 12"); // over limit
assertLabelTextNotPresent("Content 12");
}

/**
* Search for '1', then search for empty string again.
*
* @throws Exception
*/
public void testSearch1ThenEmpty() throws Exception {
// search for '1'
testSearch1();

// reset the query
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "1");
setLabeledFormElementField(target, "");
}

// this will search for ''
assertNoProblem();

// check the content on the page
assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextExactlyPresent("Title 2");
assertLabelTextExactlyPresent("Content 2");
assertLabelTextExactlyPresent("Title 3");
assertLabelTextExactlyPresent("Content 3");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");
}

/**
* Search for '10': there is only one result.
*
* @throws Exception
*/
public void testSearch10() throws Exception {
// go to the home page
testHome();

// enter in the query
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, "10");
}

// this will search for '10'
assertNoProblem();

// check the content on the page
assertLabelTextExactlyPresent("Title 10");
assertLabelTextExactlyPresent("Content 10");
assertLabelTextNotPresent("Title 11");
assertLabelTextNotPresent("Content 11");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
}

/**
* Search for a query that has no results.
*
* @throws Exception
*/
public void testSearchEmpty() throws Exception {
// go to the home page
testHome();

// enter in the query
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, "invalid");
}

// this will search for 'invalid'
assertNoProblem();

// check the content on the page
assertLabelTextNotPresent("Title 1");
assertLabelTextNotPresent("Content 1");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");

// now search for '2'
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "invalid");
setLabeledFormElementField(target, "2");
}

assertLabelTextExactlyPresent("Title 2");
assertLabelTextExactlyPresent("Content 2");
assertLabelTextExactlyPresent("Title 12");
assertLabelTextExactlyPresent("Content 12");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
}

/**
* If the DomainIterator has a limit of 3, but the database is empty,
* we can still display a page with no errors, and search over an empty
* database.
*
* @throws Exception
*/
public void testEmptyDatabase() throws Exception {
newsCount = 0;
initialiseDatabase();
beginAtSitemapThenPage("Home");
assertNoProblem();

assertLabelTextNotPresent("Title 1");
assertLabelTextNotPresent("Content 1");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");

// enter in the query
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, "1");
}

// nothing has changed
assertNoProblem();
assertLabelTextNotPresent("Title 1");
assertLabelTextNotPresent("Content 1");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");

}

/**
* If we search, then reload the page, the results will persist.
*
* @throws Exception
*/
public void testSearchesPersist() throws Exception {
newsCount = 12;
initialiseDatabase();
IFile sitemap = beginAtSitemapThenPage("Home");
assertNoProblem();

// first set the query to the empty string ''
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, "");
}

// check the content on the page
assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextExactlyPresent("Title 2");
assertLabelTextExactlyPresent("Content 2");
assertLabelTextExactlyPresent("Title 3");
assertLabelTextExactlyPresent("Content 3");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");

// enter in the query
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, "1");
}

// this will search for '1'
assertNoProblem();

// check the content on the page
assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextExactlyPresent("Title 10");
assertLabelTextExactlyPresent("Content 10");
assertLabelTextExactlyPresent("Title 11");
assertLabelTextExactlyPresent("Content 11");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertLabelTextNotPresent("Title 12"); // over limit
assertLabelTextNotPresent("Content 12");

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

// query still present
{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "1");
}

// content still present
assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextExactlyPresent("Title 10");
assertLabelTextExactlyPresent("Content 10");
assertLabelTextExactlyPresent("Title 11");
assertLabelTextExactlyPresent("Content 11");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertLabelTextNotPresent("Title 12"); // over limit
assertLabelTextNotPresent("Content 12");

}

private int newsCount = -1;

/**
* Populate the database with twenty news items. The DomainIterator
* only selects the first 3.
*
* @param size
* @return
*/
@Override
protected List<String> getDatabaseInitialisers() {
if (newsCount < 0)
throw new IllegalArgumentException("newsCount has to be set");

List<String> s = new ArrayList<String>();
s.add("CREATE TABLE News (id INTEGER PRIMARY KEY AUTOINCREMENT, title VARCHAR(64) NOT NULL, content VARCHAR(64) NOT NULL, updated DATETIME NOT NULL)");
for (int i = 1; i <= newsCount; i++) {
// SQLite does not actually support dates, and they are stored as strings!
// we have to insert the date with a leading zero, to enable sorting correctly.
String i2 = i < 10 ? "0" + i : Integer.toString(i);
s.add("INSERT INTO News (id, title, content, updated) VALUES (" + i + ", 'Title " + i + "', 'Content " + i + "', '2010-01-" + i2 + " 01:00: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

r2265 by soundasleep on May 20, 2010   Diff
fixing the crash that was causing
IteratorListSetWireSearch to fail
r2262 by soundasleep on May 19, 2010   Diff
adding codegen test case for
IteratorListSetWireSearch
initial implementation of updating
query parameters for DomainIterators
when connected to IteratorLists;
...
All revisions of this file

File info

Size: 11586 bytes, 382 lines
Powered by Google Project Hosting