KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Created on Jun 25, 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 import com.sun.syndication.feed.module.DCModule;
10 import com.sun.syndication.feed.module.SyModule;
11 import com.sun.syndication.feed.module.DCSubject;
12 import com.sun.syndication.feed.synd.SyndEntry;
13 import com.sun.syndication.io.impl.DateParser;
14
15 import java.util.List JavaDoc;
16 import java.util.Date JavaDoc;
17
18
19 /**
20  * @author pat
21  *
22  * TODO To change the template for this generated type comment go to
23  * Window - Preferences - Java - Code Generation - Code and Comments
24  */

25 public class TestSyndFeedRSS10DCSyModules extends TestSyndFeedRSS10 {
26
27     public TestSyndFeedRSS10DCSyModules() {
28         super("rss_1.0", "rss_1.0_DC_Sy.xml");
29     }
30
31     protected TestSyndFeedRSS10DCSyModules(String JavaDoc type) {
32         super(type);
33     }
34
35     protected TestSyndFeedRSS10DCSyModules(String JavaDoc feedType,String JavaDoc feedFileName) {
36         super(feedType,feedFileName);
37     }
38
39     public void testChannelDCModule() throws Exception JavaDoc {
40         DCModule dc = (DCModule) getCachedSyndFeed().getModule(DCModule.URI);
41         _testDCModule(dc,"channel.");
42     }
43
44     protected void _testDCModule(DCModule dc,String JavaDoc prefix) throws Exception JavaDoc {
45         assertNotNull(dc);
46         assertProperty(dc.getTitle(),prefix+"dc:title");
47         assertProperty(dc.getCreator(),prefix+"dc:creator");
48         assertProperty(((DCSubject)dc.getSubjects().get(0)).getValue(),prefix+"dc:subject[0]");
49         String JavaDoc taxo0 = ((DCSubject)dc.getSubjects().get(0)).getTaxonomyUri();
50         if (taxo0!=null) {
51             assertProperty(taxo0,prefix+"dc:subject[0].taxo:topic^resource");
52         }
53         assertProperty(((DCSubject)dc.getSubjects().get(1)).getValue(),prefix+"dc:subject[1]");
54         String JavaDoc taxo1 = ((DCSubject)dc.getSubjects().get(1)).getTaxonomyUri();
55         if (taxo1!=null) {
56             assertProperty(taxo1,prefix+"dc:subject[1].taxo:topic^resource");
57         }
58         assertProperty(dc.getDescription(),prefix+"dc:description");
59         assertProperty(dc.getPublisher(),prefix+"dc:publisher");
60         assertProperty((String JavaDoc)dc.getContributors().get(0),prefix+"dc:contributor[0]");
61         assertProperty((String JavaDoc)dc.getContributors().get(1),prefix+"dc:contributor[1]");
62         Date JavaDoc date = DateParser.parseW3CDateTime("2001-01-01T00:00+00:00");
63         assertEquals(dc.getDate(),date);
64         assertProperty(dc.getType(),prefix+"dc:type");
65         assertProperty(dc.getFormat(),prefix+"dc:format");
66         assertProperty(dc.getIdentifier(),prefix+"dc:identifier");
67         assertProperty(dc.getSource(),prefix+"dc:source");
68         assertProperty(dc.getLanguage(),prefix+"dc:language");
69         assertProperty(dc.getRelation(),prefix+"dc:relation");
70         assertProperty(dc.getCoverage(),prefix+"dc:coverage");
71         assertProperty(dc.getRights(),prefix+"dc:rights");
72     }
73
74     public void testChannelSyModule() throws Exception JavaDoc {
75         SyModule sy = (SyModule) getCachedSyndFeed().getModule(SyModule.URI);
76         assertNotNull(sy);
77         assertEquals(sy.getUpdatePeriod(),SyModule.HOURLY);
78         assertEquals(sy.getUpdateFrequency(),100);
79         Date JavaDoc date = DateParser.parseW3CDateTime("2001-01-01T01:00+00:00");
80         assertEquals(sy.getUpdateBase(),date);
81     }
82
83     public void testItemsDCModule() throws Exception JavaDoc {
84         _testItemDCModule(0);
85         _testItemDCModule(1);
86     }
87
88     protected void _testItemDCModule(int i) throws Exception JavaDoc {
89         List JavaDoc entries = getCachedSyndFeed().getEntries();
90         SyndEntry entry = (SyndEntry) entries.get(i);
91         DCModule dc = (DCModule) entry.getModule(DCModule.URI);
92         _testDCModule(dc,"item["+i+"].");
93
94     }
95
96
97 }
98
Popular Tags