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
/**
*
*/
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
* Using a {@model IteratorList} to render the contents of a {@model DomainIterator}.
*
*/
public class IteratorListSetWire extends DatabaseCodegenTestCase {

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

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

/**
* A ListIterator displays all of the contents of the Iterator, up to
* the limit provided by the Iterator.
*
* @throws Exception
*/
public void testAllLabelsArePopulated() throws Exception {
newsCount = 10;
initialiseDatabase();
beginAtSitemapThenPage("Home");
assertNoProblem();

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 the DomainIterator has a limit of 3, but there is only 2 elements
* in the database, we can still see these two elements.
*
* @throws Exception
*/
public void testLessLabels() throws Exception {
newsCount = 2;
initialiseDatabase();
beginAtSitemapThenPage("Home");
assertNoProblem();

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

}

/**
* If the DomainIterator has a limit of 3, but the database is empty,
* we can still display a page with no errors.
*
* @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");

}

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

r2257 by soundasleep on May 18, 2010   Diff
implementing IteratorList.hide()/show()
improving the definition of
assertLabelTextNotPresent(): asks HtmlUnit
if the element is actually displayed, so
it supports recursive hidden elements
Go to: 
Project members, sign in to write a code review

Older revisions

r2254 by soundasleep on May 18, 2010   Diff
implementing inference test case for
IteratorListSetWire
adding a codegen test case for
IteratorListSetWire
All revisions of this file

File info

Size: 4051 bytes, 136 lines
Powered by Google Project Hosting