KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Created on Jun 24, 2004
3  *
4  */

5 package com.sun.syndication.unittest;
6
7 import com.sun.syndication.feed.synd.SyndCategory;
8 import com.sun.syndication.feed.synd.SyndEntry;
9
10 import java.util.List JavaDoc;
11 import java.util.Set JavaDoc;
12 import java.util.HashSet JavaDoc;
13
14 /**
15  * @author pat
16  *
17  */

18 public class TestSyndFeedRSS092 extends TestSyndFeedRSS091N {
19
20     public TestSyndFeedRSS092() {
21         super("rss_0.92");
22     }
23
24     protected TestSyndFeedRSS092(String JavaDoc type) {
25         super(type);
26     }
27
28     protected TestSyndFeedRSS092(String JavaDoc feedType,String JavaDoc feedFileName) {
29         super(feedType,feedFileName);
30     }
31
32     protected void _testItem(int i) throws Exception JavaDoc {
33         super._testItem(i);
34         List JavaDoc items = getCachedSyndFeed().getEntries();
35         SyndEntry entry = (SyndEntry) items.get(i);
36
37         assertProperty(entry.getTitle(),"channel.item["+i+"].title");
38         assertProperty(entry.getLink(),"channel.item["+i+"].link");
39         assertProperty(entry.getDescription().getValue(),"channel.item["+i+"].description");
40         _testCategories(entry.getCategories(),"channel.item["+i+"]");
41     }
42
43     protected void _testCategories(List JavaDoc cats,String JavaDoc prefix) throws Exception JavaDoc {
44         Set JavaDoc s1 = new HashSet JavaDoc();
45         Set JavaDoc s2 = new HashSet JavaDoc();
46         for (int i=0;i<cats.size();i++) {
47             SyndCategory cat = (SyndCategory) cats.get(i);
48             s1.add(cat.getTaxonomyUri()+" "+cat.getName());
49             s2.add(getPrefix() + "." +prefix+".category["+i+"]^domain"+" "+getPrefix() + "." +prefix+".category["+i+"]");
50         }
51         assertTrue(s1.equals(s2));
52     }
53
54 }
55
Popular Tags