01: /*
02: * Created on Jun 24, 2004
03: *
04: */
05: package com.sun.syndication.unittest;
06:
07: import com.sun.syndication.feed.synd.SyndCategory;
08: import com.sun.syndication.feed.synd.SyndEntry;
09: import com.sun.syndication.feed.synd.SyndEnclosure;
10:
11: import java.util.List;
12: import java.util.Set;
13: import java.util.HashSet;
14:
15: /**
16: * @author pat
17: *
18: */
19: public class TestSyndFeedRSS092 extends TestSyndFeedRSS091N {
20:
21: public TestSyndFeedRSS092() {
22: super ("rss_0.92");
23: }
24:
25: protected TestSyndFeedRSS092(String type) {
26: super (type);
27: }
28:
29: protected TestSyndFeedRSS092(String feedType, String feedFileName) {
30: super (feedType, feedFileName);
31: }
32:
33: protected void _testItem(int i) throws Exception {
34: super ._testItem(i);
35: List items = getCachedSyndFeed().getEntries();
36: SyndEntry entry = (SyndEntry) items.get(i);
37:
38: assertProperty(entry.getTitle(), "channel.item[" + i
39: + "].title");
40: assertProperty(entry.getLink(), "channel.item[" + i + "].link");
41: assertProperty(entry.getDescription().getValue(),
42: "channel.item[" + i + "].description");
43: _testCategories(entry.getCategories(), "channel.item[" + i
44: + "]");
45: _testEnclosures(entry.getEnclosures(), "channel.item[" + i
46: + "]");
47: }
48:
49: protected void _testCategories(List cats, String prefix)
50: throws Exception {
51: Set s1 = new HashSet();
52: Set s2 = new HashSet();
53: for (int i = 0; i < cats.size(); i++) {
54: SyndCategory cat = (SyndCategory) cats.get(i);
55: s1.add(cat.getTaxonomyUri() + " " + cat.getName());
56: s2.add(getPrefix() + "." + prefix + ".category[" + i
57: + "]^domain" + " " + getPrefix() + "." + prefix
58: + ".category[" + i + "]");
59: }
60: assertTrue(s1.equals(s2));
61: }
62:
63: protected void _testEnclosures(List encs, String prefix)
64: throws Exception {
65: Set s1 = new HashSet();
66: Set s2 = new HashSet();
67: for (int i = 0; i < encs.size(); i++) {
68: SyndEnclosure enc = (SyndEnclosure) encs.get(i);
69: s1.add(enc.getUrl() + " " + enc.getType() + " "
70: + enc.getLength());
71: s2.add(getPrefix() + "." + prefix + ".enclousure[" + i
72: + "]^url" + " " + getPrefix() + "." + prefix
73: + ".enclousure[" + i + "]^type" + " " + "100");
74: }
75: assertTrue(s1.equals(s2));
76: }
77: }
|