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

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

import org.openiaml.model.tests.codegen.DatabaseCodegenTestCase;

/**
*
* @example IteratorList,DomainIterator
* Searching a {@model DomainIterator} instantly and populating the results
* into an {@model IteratorList}.
*
*/
public class IteratorListSearchInstant extends DatabaseCodegenTestCase {

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

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

public void testDefaultSearch() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();

// initial results
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");

{
String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, "1");
}

// changed results
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");
}

/**
* Test searching instantly.
*
* @throws Exception
*/
public void testInstantSearch() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();

// initial results
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");

String target = getLabelIDForText("search");
assertLabeledFieldEquals(target, "");

// just type in 1
typeLabeledFormElement(target, "1");

// changed results
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");

// type in '2' to make '12'
typeLabeledFormElement(target, "2");
assertLabelTextExactlyPresent("Title 12");
assertLabelTextExactlyPresent("Content 12");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");
assertLabelTextNotPresent("Title 11");
assertLabelTextNotPresent("Content 11");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");

// lose focus
loseFocus(target);
assertLabeledFieldEquals(target, "12");
assertLabelTextExactlyPresent("Title 12");
assertLabelTextExactlyPresent("Content 12");
assertLabelTextNotPresent("Title 10");
assertLabelTextNotPresent("Content 10");
assertLabelTextNotPresent("Title 11");
assertLabelTextNotPresent("Content 11");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");

}


/**
* Populate the database with twenty news items. The DomainIterator
* only selects the first 3.
*
* @param size
* @return
*/
@Override
protected List<String> getDatabaseInitialisers() {
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 <= 12; 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

r2274 by soundasleep on May 20, 2010   Diff
implementing codegen test case for
IteratorListSearchInstant
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 5230 bytes, 162 lines
Powered by Google Project Hosting