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
/**
*
*/
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.openiaml.model.tests.PhpRuntimeExceptionException;
import org.openiaml.model.tests.codegen.model0_5_1.RSS2_0Reader.FeedItem;

/**
* @example DomainSource,Frame
* An {@model DomainSource external feed} can be piped through to
* a local {@model Frame#render RSS} {@model Frame}.
*/
public class RemoteRSSFeedPiped extends FeedCodegenTestCase {

@Override
protected void setUp() throws Exception {
super.setUp();
root = loadAndCodegen(RemoteRSSFeedPiped.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("Details");
fail("Should not have been able to view 'Details'");
} catch (PhpRuntimeExceptionException e) {
assertContains("Required get variable 'generated_primary_key' was not found", e.getMessage());
}
}

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

// get the URL of the 'details' page
String newsUrl = getURLOfLink("Details");
assertNotNull(newsUrl);

// get the 'view remote feed' link
String url = getURLOfLink("View Remote Feed");
assertNotNull(url);

RSS2_0Reader reader = getFeedReader(url, "View Remote Feed");

// there should be two feed items, ordered by title
assertEquals(2, reader.getFeedItems().size());
Set<String> guids = new HashSet<String>();

{
// first item: New Event 123
FeedItem item = reader.getFeedItems().get(0);

assertEquals("New Event 123", item.getTitle());
assertEquals("This event is great, because it was loaded through RSS!", item.getDescription());

// construct expected URL
String expectedLink = getTestContext().getBaseUrl().toString() + newsUrl + "?generated_primary_key=";
assertTrue("Link '" + item.getLink() + "' does not begin with '" + expectedLink + "'", item.getLink().startsWith(expectedLink));

// need to construct the date
assertEquals(createUTCDate(2008, 05, 03, 9, 39, 21), 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());
}

{
// first item: New Event 123
FeedItem item = reader.getFeedItems().get(1);

assertEquals("New Event 124", item.getTitle());
assertEquals("This event is great, because it was also loaded through RSS!", item.getDescription());

// construct expected URL
String expectedLink = getTestContext().getBaseUrl().toString() + newsUrl + "?generated_primary_key=";
assertTrue("Link '" + item.getLink() + "' does not begin with '" + expectedLink + "'", item.getLink().startsWith(expectedLink));

// need to construct the date
assertEquals(createUTCDate(2008, 05, 03, 9, 39, 21), 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());
}

}

/**
* 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>();
// does nothing
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
...
All revisions of this file

File info

Size: 3966 bytes, 130 lines
Powered by Google Project Hosting