001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: TestFeedProvider.java 3634 2007-01-08 21:42:24Z gbevin $
007: */
008: package com.uwyn.rife.feed;
009:
010: import com.uwyn.rife.TestCaseServerside;
011: import com.uwyn.rife.tools.HttpUtils;
012:
013: public class TestFeedProvider extends TestCaseServerside {
014: public TestFeedProvider(int siteType, String name) {
015: super (siteType, name);
016: }
017:
018: public void testFeedProviderRss() throws Exception {
019: setupSite("site/feed.xml");
020:
021: HttpUtils.Request request = new HttpUtils.Request(
022: "http://localhost:8181/rss");
023: HttpUtils.Page page = request.retrieve();
024:
025: assertEquals(
026: page.getContent(),
027: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
028: + "<rss version=\"2.0\">\n"
029: + " <channel>\n"
030: + " <title>feed_title</title>\n"
031: + " <link>feed_link</link>\n"
032: + " <description>feed_description</description>\n"
033: + " <language>feed_language</language>\n"
034: + " <copyright>feed_copyright</copyright>\n"
035: + " <pubDate>Sat, 01 Jan 2005 02:00:00 +0100</pubDate>\n"
036: + " <managingEditor>feed_author</managingEditor>\n"
037: + " \n"
038: + " <item>\n"
039: + " <title>entry_title1</title>\n"
040: + " <link>entry_link1</link>\n"
041: + " <description>entry_content1</description>\n"
042: + " <pubDate>Sat, 01 Jan 2005 01:00:00 +0100</pubDate>\n"
043: + " <author>entry_author1</author>\n"
044: + " <guid>entry_link1</guid>\n"
045: + " </item>\n"
046: + " \n"
047: + " <item>\n"
048: + " <title>entry_title2</title>\n"
049: + " <link>entry_link2</link>\n"
050: + " <description>entry_content2</description>\n"
051: + " <pubDate>Sat, 01 Jan 2005 02:00:00 +0100</pubDate>\n"
052: + " <author>entry_author2</author>\n"
053: + " <guid>entry_link2</guid>\n"
054: + " </item>\n" + " \n" + " \n"
055: + " </channel>\n" + "</rss>");
056: }
057:
058: public void testFeedProviderAtom() throws Exception {
059: setupSite("site/feed.xml");
060:
061: HttpUtils.Request request = new HttpUtils.Request(
062: "http://localhost:8181/atom");
063: HttpUtils.Page page = request.retrieve();
064:
065: assertEquals(
066: page.getContent(),
067: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
068: + "<feed xmlns=\"http://purl.org/atom/ns#\" xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" version=\"0.3\">\n"
069: + " <title>feed_title</title>\n"
070: + " <link rel=\"alternate\" href=\"feed_link\" type=\"text/html\" />\n"
071: + " <author>\n"
072: + " <name>feed_author</name>\n"
073: + " </author>\n"
074: + " <copyright>feed_copyright</copyright>\n"
075: + " <info>feed_description</info>\n"
076: + " <modified>2005-01-01T02:00:00+0100</modified>\n"
077: + " <dc:creator>feed_author</dc:creator>\n"
078: + " <dc:date>2005-01-01T02:00:00+0100</dc:date>\n"
079: + " <dc:language>feed_language</dc:language>\n"
080: + " <dc:rights>feed_copyright</dc:rights>\n"
081: + " \n"
082: + " \n"
083: + " <entry>\n"
084: + " <title>entry_title1</title>\n"
085: + " <link rel=\"alternate\" href=\"entry_link1\" type=\"text/html\" />\n"
086: + " <author>\n"
087: + " <name>entry_author1</name>\n"
088: + " </author>\n"
089: + " <modified>2005-01-01T01:00:00+0100</modified>\n"
090: + " <content type=\"text/html\" mode=\"escaped\">entry_content1</content>\n"
091: + " <id>entry_link1</id>\n"
092: + " <issued>2005-01-01T01:00:00+0100</issued>\n"
093: + " <dc:creator>entry_author1</dc:creator>\n"
094: + " <dc:date>2005-01-01T01:00:00+0100</dc:date>\n"
095: + " </entry>\n"
096: + " \n"
097: + " <entry>\n"
098: + " <title>entry_title2</title>\n"
099: + " <link rel=\"alternate\" href=\"entry_link2\" type=\"text/html\" />\n"
100: + " <author>\n"
101: + " <name>entry_author2</name>\n"
102: + " </author>\n"
103: + " <modified>2005-01-01T02:00:00+0100</modified>\n"
104: + " <content type=\"text/html\" mode=\"escaped\">entry_content2</content>\n"
105: + " <id>entry_link2</id>\n"
106: + " <issued>2005-01-01T02:00:00+0100</issued>\n"
107: + " <dc:creator>entry_author2</dc:creator>\n"
108: + " <dc:date>2005-01-01T02:00:00+0100</dc:date>\n"
109: + " </entry>\n" + " \n" + " \n" + "</feed>");
110: }
111:
112: public void testFeedProviderNamespacesRss() throws Exception {
113: setupSite("site/feed.xml");
114:
115: HttpUtils.Request request = new HttpUtils.Request(
116: "http://localhost:8181/namespaces_rss");
117: HttpUtils.Page page = request.retrieve();
118:
119: assertEquals(
120: page.getContent(),
121: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
122: + "<rss xmlns:doap=\"http://usefulinc.com/ns/doap#\" xmlns:foaf=\"http://xmlns.com/foaf/0.1/\" version=\"2.0\">\n"
123: + " <channel>\n"
124: + " <title>feed_title_namespace</title>\n"
125: + " <link>feed_link_namespace</link>\n"
126: + " <description>feed_description_namespace</description>\n"
127: + " <language>feed_language_namespace</language>\n"
128: + " <copyright>feed_copyright_namespace</copyright>\n"
129: + " <pubDate>Sat, 01 Jan 2005 02:00:00 +0100</pubDate>\n"
130: + " <managingEditor>feed_author_namespace</managingEditor>\n"
131: + " \n"
132: + " <item>\n"
133: + " <title>entry_title_namespace1</title>\n"
134: + " <link>entry_link_namespace1</link>\n"
135: + " <description><doap:Project>entry_content_namespace1</doap:Project></description>\n"
136: + " <pubDate>Sat, 01 Jan 2005 01:00:00 +0100</pubDate>\n"
137: + " <author>entry_author_namespace1</author>\n"
138: + " <guid>entry_link_namespace1</guid>\n"
139: + " </item>\n"
140: + " \n"
141: + " <item>\n"
142: + " <title>entry_title_namespace2</title>\n"
143: + " <link>entry_link_namespace2</link>\n"
144: + " <description><doap:Project>entry_content_namespace2</doap:Project></description>\n"
145: + " <pubDate>Sat, 01 Jan 2005 02:00:00 +0100</pubDate>\n"
146: + " <author>entry_author_namespace2</author>\n"
147: + " <guid>entry_link_namespace2</guid>\n"
148: + " </item>\n" + " \n" + " \n"
149: + " </channel>\n" + "</rss>");
150: }
151:
152: public void testFeedProviderNamespacesAtom() throws Exception {
153: setupSite("site/feed.xml");
154:
155: HttpUtils.Request request = new HttpUtils.Request(
156: "http://localhost:8181/namespaces_atom");
157: HttpUtils.Page page = request.retrieve();
158:
159: assertEquals(
160: page.getContent(),
161: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
162: + "<feed xmlns=\"http://purl.org/atom/ns#\" xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:doap=\"http://usefulinc.com/ns/doap#\" xmlns:foaf=\"http://xmlns.com/foaf/0.1/\" version=\"0.3\">\n"
163: + " <title>feed_title_namespace</title>\n"
164: + " <link rel=\"alternate\" href=\"feed_link_namespace\" type=\"text/html\" />\n"
165: + " <author>\n"
166: + " <name>feed_author_namespace</name>\n"
167: + " </author>\n"
168: + " <copyright>feed_copyright_namespace</copyright>\n"
169: + " <info>feed_description_namespace</info>\n"
170: + " <modified>2005-01-01T02:00:00+0100</modified>\n"
171: + " <dc:creator>feed_author_namespace</dc:creator>\n"
172: + " <dc:date>2005-01-01T02:00:00+0100</dc:date>\n"
173: + " <dc:language>feed_language_namespace</dc:language>\n"
174: + " <dc:rights>feed_copyright_namespace</dc:rights>\n"
175: + " \n"
176: + " \n"
177: + " <entry>\n"
178: + " <title>entry_title_namespace1</title>\n"
179: + " <link rel=\"alternate\" href=\"entry_link_namespace1\" type=\"text/html\" />\n"
180: + " <author>\n"
181: + " <name>entry_author_namespace1</name>\n"
182: + " </author>\n"
183: + " <modified>2005-01-01T01:00:00+0100</modified>\n"
184: + " <content type=\"application/rdf+xml\"><doap:Project>entry_content_namespace1</doap:Project></content>\n"
185: + " <id>entry_link_namespace1</id>\n"
186: + " <issued>2005-01-01T01:00:00+0100</issued>\n"
187: + " <dc:creator>entry_author_namespace1</dc:creator>\n"
188: + " <dc:date>2005-01-01T01:00:00+0100</dc:date>\n"
189: + " </entry>\n"
190: + " \n"
191: + " <entry>\n"
192: + " <title>entry_title_namespace2</title>\n"
193: + " <link rel=\"alternate\" href=\"entry_link_namespace2\" type=\"text/html\" />\n"
194: + " <author>\n"
195: + " <name>entry_author_namespace2</name>\n"
196: + " </author>\n"
197: + " <modified>2005-01-01T02:00:00+0100</modified>\n"
198: + " <content type=\"application/rdf+xml\"><doap:Project>entry_content_namespace2</doap:Project></content>\n"
199: + " <id>entry_link_namespace2</id>\n"
200: + " <issued>2005-01-01T02:00:00+0100</issued>\n"
201: + " <dc:creator>entry_author_namespace2</dc:creator>\n"
202: + " <dc:date>2005-01-01T02:00:00+0100</dc:date>\n"
203: + " </entry>\n" + " \n" + " \n" + "</feed>");
204: }
205: }
|