001: /*
002: * Created on Jun 25, 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: import com.sun.syndication.feed.module.DCModule;
010: import com.sun.syndication.feed.module.SyModule;
011: import com.sun.syndication.feed.module.DCSubject;
012: import com.sun.syndication.feed.synd.SyndEntry;
013: import com.sun.syndication.io.impl.DateParser;
014:
015: import java.util.List;
016: import java.util.Date;
017:
018: /**
019: * @author pat
020: *
021: * TODO To change the template for this generated type comment go to
022: * Window - Preferences - Java - Code Generation - Code and Comments
023: */
024: public class TestSyndFeedRSS10DCSyModules extends TestSyndFeedRSS10 {
025:
026: public TestSyndFeedRSS10DCSyModules() {
027: super ("rss_1.0", "rss_1.0_DC_Sy.xml");
028: }
029:
030: protected TestSyndFeedRSS10DCSyModules(String type) {
031: super (type);
032: }
033:
034: protected TestSyndFeedRSS10DCSyModules(String feedType,
035: String feedFileName) {
036: super (feedType, feedFileName);
037: }
038:
039: public void testChannelDCModule() throws Exception {
040: DCModule dc = (DCModule) getCachedSyndFeed().getModule(
041: DCModule.URI);
042: _testDCModule(dc, "channel.");
043: }
044:
045: protected void _testDCModule(DCModule dc, String prefix)
046: throws Exception {
047: assertNotNull(dc);
048: assertProperty(dc.getTitle(), prefix + "dc:title");
049: assertProperty(dc.getCreator(), prefix + "dc:creator");
050: assertProperty(
051: ((DCSubject) dc.getSubjects().get(0)).getValue(),
052: prefix + "dc:subject[0]");
053: String taxo0 = ((DCSubject) dc.getSubjects().get(0))
054: .getTaxonomyUri();
055: if (taxo0 != null) {
056: assertProperty(taxo0, prefix
057: + "dc:subject[0].taxo:topic^resource");
058: }
059: assertProperty(
060: ((DCSubject) dc.getSubjects().get(1)).getValue(),
061: prefix + "dc:subject[1]");
062: String taxo1 = ((DCSubject) dc.getSubjects().get(1))
063: .getTaxonomyUri();
064: if (taxo1 != null) {
065: assertProperty(taxo1, prefix
066: + "dc:subject[1].taxo:topic^resource");
067: }
068: assertProperty(dc.getDescription(), prefix + "dc:description");
069: assertProperty(dc.getPublisher(), prefix + "dc:publisher");
070: assertProperty((String) dc.getContributors().get(0), prefix
071: + "dc:contributor[0]");
072: assertProperty((String) dc.getContributors().get(1), prefix
073: + "dc:contributor[1]");
074: Date date = DateParser
075: .parseW3CDateTime("2001-01-01T00:00+00:00");
076: assertEquals(dc.getDate(), date);
077: assertProperty(dc.getType(), prefix + "dc:type");
078: assertProperty(dc.getFormat(), prefix + "dc:format");
079: assertProperty(dc.getIdentifier(), prefix + "dc:identifier");
080: assertProperty(dc.getSource(), prefix + "dc:source");
081: assertProperty(dc.getLanguage(), prefix + "dc:language");
082: assertProperty(dc.getRelation(), prefix + "dc:relation");
083: assertProperty(dc.getCoverage(), prefix + "dc:coverage");
084: assertProperty(dc.getRights(), prefix + "dc:rights");
085: }
086:
087: public void testChannelSyModule() throws Exception {
088: SyModule sy = (SyModule) getCachedSyndFeed().getModule(
089: SyModule.URI);
090: assertNotNull(sy);
091: assertEquals(sy.getUpdatePeriod(), SyModule.HOURLY);
092: assertEquals(sy.getUpdateFrequency(), 100);
093: Date date = DateParser
094: .parseW3CDateTime("2001-01-01T01:00+00:00");
095: assertEquals(sy.getUpdateBase(), date);
096: }
097:
098: public void testItemsDCModule() throws Exception {
099: _testItemDCModule(0);
100: _testItemDCModule(1);
101: }
102:
103: protected void _testItemDCModule(int i) throws Exception {
104: List entries = getCachedSyndFeed().getEntries();
105: SyndEntry entry = (SyndEntry) entries.get(i);
106: DCModule dc = (DCModule) entry.getModule(DCModule.URI);
107: _testDCModule(dc, "item[" + i + "].");
108:
109: }
110:
111: }
|