KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > syndication > unittest > SyndFeedTest


1 /*
2  * Created on Jun 22, 2004
3  *
4  * TODO To change the template for this generated file go to
5  * Window - Preferences - Java - Code Generation - Code and Comments
6  */

7 package com.sun.syndication.unittest;
8
9
10
11
12 /**
13  * @author pat
14  *
15  */

16 public abstract class SyndFeedTest extends FeedTest {
17      private String JavaDoc _prefix = null;
18
19     protected SyndFeedTest(String JavaDoc feedType) {
20         this(feedType,feedType+".xml");
21     }
22
23     protected SyndFeedTest(String JavaDoc feedType,String JavaDoc feedFileName) {
24         super(feedFileName);
25         _prefix = feedType;
26     }
27
28     protected String JavaDoc getPrefix() {
29         return _prefix;
30     }
31
32     protected void assertProperty(String JavaDoc property, String JavaDoc value) {
33         assertEquals(property,getPrefix() + "." + value);
34     }
35
36     public void testType() throws Exception JavaDoc {
37         assertEquals(getCachedSyndFeed().getFeedType(),getPrefix());
38     }
39
40     
41 /*
42     public void testType() throws Exception {
43         assertEquals(getPrefix(), getCachedSyndFeed().getFeedType());
44     }
45
46     public void testTitle() throws Exception {
47         assertEqualsStr("channel.title", getCachedSyndFeed().getTitle());
48     }
49
50     public void testLink() throws Exception {
51         assertEqualsStr("channel.link", getCachedSyndFeed().getLink());
52     }
53
54     public void testDescription() throws Exception {
55         assertEqualsStr("channel.description", getCachedSyndFeed().getDescription());
56     }
57
58     public void testLanguage() throws Exception {
59         assertEqualsStr("channel.language", getCachedSyndFeed().getLanguage());
60     }
61
62     public void testCategories() throws Exception {
63         List catlist = getCachedSyndFeed().getCategories();
64         //don't understand why this one fails
65         assertEquals(2, catlist.size());
66         SyndCategory cat = (SyndCategory)catlist.get(0);
67         assertEqualsStr("channel.category[0]", cat.getName());
68         assertEqualsStr("channel.category[0]^domain", cat.getTaxonomyUri());
69         cat = (SyndCategory)catlist.get(1);
70         assertEqualsStr("channel.category[1]", cat.getName());
71         assertEqualsStr("channel.category[1]^domain", cat.getTaxonomyUri());
72     }
73
74     public void testPublishedDate() throws Exception {
75         assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getCachedSyndFeed().getPublishedDate());
76     }
77
78     //how do i get height and width?
79     public void testImage() throws Exception {
80         SyndImage img = getCachedSyndFeed().getImage();
81         assertEqualsStr("channel.image.description", img.getDescription());
82         assertEqualsStr("channel.image.link", img.getLink());
83         assertEqualsStr("channel.image.title", img.getTitle());
84         assertEqualsStr("channel.image.url", img.getUrl());
85     }
86
87     public void testEntries() throws Exception {
88         List entrylist = getCachedSyndFeed().getEntries();
89         assertEquals(2, entrylist.size());
90     }
91
92     public void testEntryTitle() throws Exception {
93         assertEqualsStr("channel.item[0].title", getEntryTitle(getCachedSyndFeed().getEntries().get(0)));
94         assertEqualsStr("channel.item[1].title", getEntryTitle(getCachedSyndFeed().getEntries().get(1)));
95     }
96
97     public String getEntryTitle(Object o) throws Exception {
98         SyndEntry e = (SyndEntry) o;
99         return e.getTitle();
100     }
101
102     public void testEntryDescription() throws Exception {
103         assertEqualsStr("channel.item[0].description", getEntryDescription(getCachedSyndFeed().getEntries().get(0)));
104         assertEqualsStr("channel.item[1].description", getEntryDescription(getCachedSyndFeed().getEntries().get(1)));
105     }
106
107     public String getEntryDescription(Object o) throws Exception {
108         SyndEntry e = (SyndEntry) o;
109         return e.getDescription().getValue();
110     }
111
112     public void testEntryLink() throws Exception {
113         assertEqualsStr("channel.item[0].link", getEntryLink(getCachedSyndFeed().getEntries().get(0)));
114         assertEqualsStr("channel.item[1].link", getEntryLink(getCachedSyndFeed().getEntries().get(1)));
115     }
116
117     public String getEntryLink(Object o) {
118         SyndEntry e = (SyndEntry) o;
119         return e.getLink();
120     }
121
122     public void testEntryPublishedDate() throws Exception {
123         assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getEntryPublishedDate(getCachedSyndFeed().getEntries().get(0)));
124         assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getEntryPublishedDate(getCachedSyndFeed().getEntries().get(1)));
125     }
126
127     public Date getEntryPublishedDate(Object o) {
128         SyndEntry e = (SyndEntry) o;
129         return e.getPublishedDate();
130     }
131
132     public void testEntryCategories() throws Exception {
133         SyndEntry e = (SyndEntry)getCachedSyndFeed().getEntries().get(0);
134         List catlist = e.getCategories();
135         //don't understand why this one fails
136         assertEquals(2, catlist.size());
137         SyndCategory cat = (SyndCategory)catlist.get(0);
138         assertEqualsStr("channel.item[0].category[0]", cat.getName());
139         assertEqualsStr("channel.item[0].category[0]^domain", cat.getTaxonomyUri());
140         cat = (SyndCategory)catlist.get(1);
141         assertEqualsStr("channel.item[0].category[1]", cat.getName());
142         assertEqualsStr("channel.item[0].category[1]^domain", cat.getTaxonomyUri());
143         //DO 2nd set of items
144     }
145
146     public void testEntryAuthor() throws Exception {
147         assertEqualsStr("channel.item[0].author", getEntryAuthor(getCachedSyndFeed().getEntries().get(0)));
148         assertEqualsStr("channel.item[1].author", getEntryAuthor(getCachedSyndFeed().getEntries().get(1)));
149     }
150
151     public String getEntryAuthor(Object o) {
152         SyndEntry e = (SyndEntry) o;
153         return e.getAuthor();
154     }
155
156 */

157 /*
158 //things you cannot get from SyndEntryImpl
159 // <source url="http://localhost:8080/item0/source.url">item[0].source</source>
160 // <enclosure url="http://localhost:8080/item0/enclosure0.url" length="100" type="audio/mpeg"/>
161 // <enclosure url="http://localhost:8080/item0/enclosure1.url" length="1000" type="audio/mpeg"/>
162     <category domain="item0.domain0">item0.category0</category>
163     <category domain="item0.domain1">item0.category1</category>
164     <pubDate>Thu, 08 Jul 1999 08:00:00 GMT</pubDate>
165     <expirationDate>Thu, 08 Jul 1999 09:00:00 GMT</.expirationDate>
166     <author>item0.author</author>
167     <comments>http://localhost:8080/item0/comments</comments>
168     <guid isPermaLink="true">http://localhost:8080/item0/guid</guid>
169     //TODO: I still have the elements to test
170 */

171     /*
172     public void test() {
173         assertEqualsStr(feed, "");
174     }
175
176     public void test() {
177         assertEqualsStr(feed, "");
178     }
179
180     */

181     //Things that you cannot get form a SyndFeedImpl today
182
//these need to be put in a RSS 2.0 module
183
//or is a roundtrip to wirefeed the right way to do this?
184
/*
185  * <textInput>
186     <title>Search</title>
187     <description>Search this site:</description>
188     <name>q</name>
189     <link>http://example.org/mt/mt-search.cgi</link>
190   </textInput>
191
192    image height and width
193  *
194     //<copyright>Copyright 2004, Mark Pilgrim</copyright>
195     public void test() {
196         assertEqualsStr(getCachedSyndFeed()., "");
197     }
198
199     //<generator>Sample Toolkit</generator>
200     public void test() {
201         assertEqualsStr(feed, "");
202     }
203
204     // <managingEditor>editor@example.org</managingEditor>
205     public void test() {
206         assertEqualsStr(feed, "");
207     }
208
209     // <webMaster>webmaster@example.org</webMaster>
210     public void test() {
211         assertEqualsStr(feed, "");
212     }
213
214       <docs>http://blogs.law.harvard.edu/tech/rss</docs>
215         <cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="pingMe" protocol="soap"/>
216         <ttl>60</ttl>
217           <rating>(PICS-1.1 Òhttp://www.classify.org/safesurf/Ó l r (SS~~000 1))</rating>
218
219   <skiphours>
220     <hour>0</hour>
221     <hour>1</hour>
222     <hour>2</hour>
223     <hour>3</hour>
224     <hour>4</hour>
225     <hour>5</hour>
226     <hour>6</hour>
227     <hour>7</hour>
228     <hour>8</hour>
229     <hour>9.5</hour>
230     <hour>10</hour>
231     <hour>11</hour>
232     <hour>12</hour>
233     <hour>13</hour>
234     <hour>14</hour>
235     <hour>15</hour>
236     <hour>16</hour>
237     <hour>17</hour>
238     <hour>18</hour>
239     <hour>19</hour>
240     <hour>20</hour>
241     <hour>21</hour>
242     <hour>22</hour>
243     <hour>23</hour>
244   </skiphours>
245   <skipdays>
246     <day>Monday</day>
247     <day>Tuesday</day>
248     <day>Wednesday</day>
249     <day>Thursday</day>
250     <day>Friday</day>
251     <day>Saturday</day>
252     <day>Sunday</day>
253   </skipdays>
254
255 **/

256
257
258     /*
259      * @see TestCase#tearDown()
260      */

261     protected void tearDown() throws Exception JavaDoc {
262         super.tearDown();
263     }
264
265
266
267 }
268
Popular Tags