001: /*
002: * Created on Jun 22, 2004
003: *
004: * TODO To change the template for this generated file go to
005: * Window - Preferences - Java - Code Generation - Code and Comments
006: */
007: package com.sun.syndication.unittest;
008:
009: /**
010: * @author pat
011: *
012: */
013: public abstract class SyndFeedTest extends FeedTest {
014: private String _prefix = null;
015:
016: protected SyndFeedTest(String feedType) {
017: this (feedType, feedType + ".xml");
018: }
019:
020: protected SyndFeedTest(String feedType, String feedFileName) {
021: super (feedFileName);
022: _prefix = feedType;
023: }
024:
025: protected String getPrefix() {
026: return _prefix;
027: }
028:
029: protected void assertProperty(String property, String value) {
030: assertEquals(property, getPrefix() + "." + value);
031: }
032:
033: public void testType() throws Exception {
034: assertEquals(getCachedSyndFeed().getFeedType(), getPrefix());
035: }
036:
037: /*
038: public void testType() throws Exception {
039: assertEquals(getPrefix(), getCachedSyndFeed().getFeedType());
040: }
041:
042: public void testTitle() throws Exception {
043: assertEqualsStr("channel.title", getCachedSyndFeed().getTitle());
044: }
045:
046: public void testLink() throws Exception {
047: assertEqualsStr("channel.link", getCachedSyndFeed().getLink());
048: }
049:
050: public void testDescription() throws Exception {
051: assertEqualsStr("channel.description", getCachedSyndFeed().getDescription());
052: }
053:
054: public void testLanguage() throws Exception {
055: assertEqualsStr("channel.language", getCachedSyndFeed().getLanguage());
056: }
057:
058: public void testCategories() throws Exception {
059: List catlist = getCachedSyndFeed().getCategories();
060: //don't understand why this one fails
061: assertEquals(2, catlist.size());
062: SyndCategory cat = (SyndCategory)catlist.get(0);
063: assertEqualsStr("channel.category[0]", cat.getName());
064: assertEqualsStr("channel.category[0]^domain", cat.getTaxonomyUri());
065: cat = (SyndCategory)catlist.get(1);
066: assertEqualsStr("channel.category[1]", cat.getName());
067: assertEqualsStr("channel.category[1]^domain", cat.getTaxonomyUri());
068: }
069:
070: public void testPublishedDate() throws Exception {
071: assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getCachedSyndFeed().getPublishedDate());
072: }
073:
074: //how do i get height and width?
075: public void testImage() throws Exception {
076: SyndImage img = getCachedSyndFeed().getImage();
077: assertEqualsStr("channel.image.description", img.getDescription());
078: assertEqualsStr("channel.image.link", img.getLink());
079: assertEqualsStr("channel.image.title", img.getTitle());
080: assertEqualsStr("channel.image.url", img.getUrl());
081: }
082:
083: public void testEntries() throws Exception {
084: List entrylist = getCachedSyndFeed().getEntries();
085: assertEquals(2, entrylist.size());
086: }
087:
088: public void testEntryTitle() throws Exception {
089: assertEqualsStr("channel.item[0].title", getEntryTitle(getCachedSyndFeed().getEntries().get(0)));
090: assertEqualsStr("channel.item[1].title", getEntryTitle(getCachedSyndFeed().getEntries().get(1)));
091: }
092:
093: public String getEntryTitle(Object o) throws Exception {
094: SyndEntry e = (SyndEntry) o;
095: return e.getTitle();
096: }
097:
098: public void testEntryDescription() throws Exception {
099: assertEqualsStr("channel.item[0].description", getEntryDescription(getCachedSyndFeed().getEntries().get(0)));
100: assertEqualsStr("channel.item[1].description", getEntryDescription(getCachedSyndFeed().getEntries().get(1)));
101: }
102:
103: public String getEntryDescription(Object o) throws Exception {
104: SyndEntry e = (SyndEntry) o;
105: return e.getDescription().getValue();
106: }
107:
108: public void testEntryLink() throws Exception {
109: assertEqualsStr("channel.item[0].link", getEntryLink(getCachedSyndFeed().getEntries().get(0)));
110: assertEqualsStr("channel.item[1].link", getEntryLink(getCachedSyndFeed().getEntries().get(1)));
111: }
112:
113: public String getEntryLink(Object o) {
114: SyndEntry e = (SyndEntry) o;
115: return e.getLink();
116: }
117:
118: public void testEntryPublishedDate() throws Exception {
119: assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getEntryPublishedDate(getCachedSyndFeed().getEntries().get(0)));
120: assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getEntryPublishedDate(getCachedSyndFeed().getEntries().get(1)));
121: }
122:
123: public Date getEntryPublishedDate(Object o) {
124: SyndEntry e = (SyndEntry) o;
125: return e.getPublishedDate();
126: }
127:
128: public void testEntryCategories() throws Exception {
129: SyndEntry e = (SyndEntry)getCachedSyndFeed().getEntries().get(0);
130: List catlist = e.getCategories();
131: //don't understand why this one fails
132: assertEquals(2, catlist.size());
133: SyndCategory cat = (SyndCategory)catlist.get(0);
134: assertEqualsStr("channel.item[0].category[0]", cat.getName());
135: assertEqualsStr("channel.item[0].category[0]^domain", cat.getTaxonomyUri());
136: cat = (SyndCategory)catlist.get(1);
137: assertEqualsStr("channel.item[0].category[1]", cat.getName());
138: assertEqualsStr("channel.item[0].category[1]^domain", cat.getTaxonomyUri());
139: //DO 2nd set of items
140: }
141:
142: public void testEntryAuthor() throws Exception {
143: assertEqualsStr("channel.item[0].author", getEntryAuthor(getCachedSyndFeed().getEntries().get(0)));
144: assertEqualsStr("channel.item[1].author", getEntryAuthor(getCachedSyndFeed().getEntries().get(1)));
145: }
146:
147: public String getEntryAuthor(Object o) {
148: SyndEntry e = (SyndEntry) o;
149: return e.getAuthor();
150: }
151:
152: */
153: /*
154: //things you cannot get from SyndEntryImpl
155: // <source url="http://localhost:8080/item0/source.url">item[0].source</source>
156: // <enclosure url="http://localhost:8080/item0/enclosure0.url" length="100" type="audio/mpeg"/>
157: // <enclosure url="http://localhost:8080/item0/enclosure1.url" length="1000" type="audio/mpeg"/>
158: <category domain="item0.domain0">item0.category0</category>
159: <category domain="item0.domain1">item0.category1</category>
160: <pubDate>Thu, 08 Jul 1999 08:00:00 GMT</pubDate>
161: <expirationDate>Thu, 08 Jul 1999 09:00:00 GMT</.expirationDate>
162: <author>item0.author</author>
163: <comments>http://localhost:8080/item0/comments</comments>
164: <guid isPermaLink="true">http://localhost:8080/item0/guid</guid>
165: //TODO: I still have the elements to test
166: */
167: /*
168: public void test() {
169: assertEqualsStr(feed, "");
170: }
171:
172: public void test() {
173: assertEqualsStr(feed, "");
174: }
175:
176: */
177: //Things that you cannot get form a SyndFeedImpl today
178: //these need to be put in a RSS 2.0 module
179: //or is a roundtrip to wirefeed the right way to do this?
180: /*
181: * <textInput>
182: <title>Search</title>
183: <description>Search this site:</description>
184: <name>q</name>
185: <link>http://example.org/mt/mt-search.cgi</link>
186: </textInput>
187:
188: image height and width
189: *
190: //<copyright>Copyright 2004, Mark Pilgrim</copyright>
191: public void test() {
192: assertEqualsStr(getCachedSyndFeed()., "");
193: }
194:
195: //<generator>Sample Toolkit</generator>
196: public void test() {
197: assertEqualsStr(feed, "");
198: }
199:
200: // <managingEditor>editor@example.org</managingEditor>
201: public void test() {
202: assertEqualsStr(feed, "");
203: }
204:
205: // <webMaster>webmaster@example.org</webMaster>
206: public void test() {
207: assertEqualsStr(feed, "");
208: }
209:
210: <docs>http://blogs.law.harvard.edu/tech/rss</docs>
211: <cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="pingMe" protocol="soap"/>
212: <ttl>60</ttl>
213: <rating>(PICS-1.1 Òhttp://www.classify.org/safesurf/Ó l r (SS~~000 1))</rating>
214:
215: <skiphours>
216: <hour>0</hour>
217: <hour>1</hour>
218: <hour>2</hour>
219: <hour>3</hour>
220: <hour>4</hour>
221: <hour>5</hour>
222: <hour>6</hour>
223: <hour>7</hour>
224: <hour>8</hour>
225: <hour>9.5</hour>
226: <hour>10</hour>
227: <hour>11</hour>
228: <hour>12</hour>
229: <hour>13</hour>
230: <hour>14</hour>
231: <hour>15</hour>
232: <hour>16</hour>
233: <hour>17</hour>
234: <hour>18</hour>
235: <hour>19</hour>
236: <hour>20</hour>
237: <hour>21</hour>
238: <hour>22</hour>
239: <hour>23</hour>
240: </skiphours>
241: <skipdays>
242: <day>Monday</day>
243: <day>Tuesday</day>
244: <day>Wednesday</day>
245: <day>Thursday</day>
246: <day>Friday</day>
247: <day>Saturday</day>
248: <day>Sunday</day>
249: </skipdays>
250:
251: **/
252:
253: /*
254: * @see TestCase#tearDown()
255: */
256: protected void tearDown() throws Exception {
257: super.tearDown();
258: }
259:
260: }
|