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

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.resources.IFile;
import org.openiaml.model.tests.PhpRuntimeExceptionException;
import org.openiaml.model.tests.codegen.model0_5_1.RSS2_0Reader.FeedItem;

/**
* @example Frame
* A simple example of using an {@model Frame#render RSS} {@model Frame} to <em>provide</em> an RSS
* feed from a {@model DomainIterator}.
*/
public class FeedProducerSimple extends FeedCodegenTestCase {

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

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

/**
* Trying to view the 'view news' page without a query parameter fails.
*
* @throws Exception
*/
public void testViewWithoutID() throws Exception {
try {
beginAtSitemapThenPage("View News");
fail("Should not have been able to view 'View News'");
} catch (PhpRuntimeExceptionException e) {
assertContains("Required get variable 'generated_primary_key' was not found", e.getMessage());
}
}

/**
* Trying to view the 'view news' page manually passes.
*
* @throws Exception
*/
public void testViewWithID() throws Exception {
IFile sitemap = getSitemap();
beginAtSitemapThenPage(sitemap, "View News", "View News", "generated_primary_key=5");
assertNoProblem();

// date is displayed in RFC 2822 format
assertContent("Title 5", "Description 5", "Tue, 05 Jan 2010 01:00:00 +0000");

// there is no navigation buttons, since we are only selecting one
assertButtonNotPresentWithText("Next");
assertButtonNotPresentWithText("Previous");
assertButtonNotPresentWithText("First");
assertButtonNotPresentWithText("Last");
}

/**
* We can access the RSS feed without a problem.
*
* @throws Exception
*/
public void testAccessRSS() throws Exception {
beginAtSitemap();

// get the URL of the 'view news' page
String newsUrl = getURLOfLink("View News");
assertNotNull(newsUrl);

// get the 'target feed' link
String url = getURLOfLink("Target Feed");
assertNotNull(url);

RSS2_0Reader reader = getFeedReader(url, "Target Feed");

// there should be ten feed items
assertEquals(10, reader.getFeedItems().size());

// we start from 20 down to 11
Set<String> guids = new HashSet<String>();
int i = 20;
for (FeedItem item : reader.getFeedItems()) {
assertEquals("Title " + i, item.getTitle());
assertEquals("Description " + i, item.getDescription());

// construct expected URL
String expectedLink = getTestContext().getBaseUrl().toString() + newsUrl + "?generated_primary_key=" + i;
assertEquals(expectedLink, item.getLink());

// need to construct the date
assertEquals(createUTCDate(2010, 0, i, 1, 0, 0), item.getPubDate());

// and the GUID must be unique in this list
assertNotNull(item.getGuid());
assertFalse("List of GUIDs already contains '" + item.getGuid() + "': " + guids, guids.contains(item.getGuid()));
guids.add(item.getGuid());

// increment down, since we are in DESC
i--;
}

}

/**
* Check the given content on the page.
*
* <p>Because we are using a SetWire, we cannot select by TextField;
* we can only search for labels containing the given text.
*/
private void assertContent(String title, String description, String updated) {
assertLabelTextPresent(title);
assertLabelTextPresent(description);
assertLabelTextPresent(updated);
}

/**
* Populate the database with twenty news items. The SelectWire
* only selects the first 10.
*
* @param size
* @return
*/
@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, description VARCHAR(64) NOT NULL, updated DATETIME NOT NULL)");
for (int i = 1; i <= 20; 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 (generated_primary_key, title, description, updated) VALUES (" + i + ", 'Title " + i + "', 'Description " + 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

r2154 by soundasleep on May 10, 2010   Diff
removing all explicit definitions of
getDatabaseName(), since 'default.db'
is now used by default (r2152)
r2001 by soundasleep on Apr 21, 2010   Diff
adding codegen test case for
RemoteRSSFeedPiped
when a Frame is accessed, all
contained onAccess events for the
Frame and its recursive children are
...
r1981 by soundasleep on Apr 20, 2010   Diff
arguments to evaluate_select_wire()
are now cleaned before evaluating
query parameters are also now cleaned
FeedProducerSimple codegen test case
now passes
All revisions of this file

File info

Size: 4718 bytes, 151 lines
Powered by Google Project Hosting