1 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 ; 16 import java.util.Date ; 17 18 19 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 type) { 32 super(type); 33 } 34 35 protected TestSyndFeedRSS10DCSyModules(String feedType,String feedFileName) { 36 super(feedType,feedFileName); 37 } 38 39 public void testChannelDCModule() throws Exception { 40 DCModule dc = (DCModule) getCachedSyndFeed().getModule(DCModule.URI); 41 _testDCModule(dc,"channel."); 42 } 43 44 protected void _testDCModule(DCModule dc,String prefix) throws Exception { 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 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 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 )dc.getContributors().get(0),prefix+"dc:contributor[0]"); 61 assertProperty((String )dc.getContributors().get(1),prefix+"dc:contributor[1]"); 62 Date 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 { 75 SyModule sy = (SyModule) getCachedSyndFeed().getModule(SyModule.URI); 76 assertNotNull(sy); 77 assertEquals(sy.getUpdatePeriod(),SyModule.HOURLY); 78 assertEquals(sy.getUpdateFrequency(),100); 79 Date date = DateParser.parseW3CDateTime("2001-01-01T01:00+00:00"); 80 assertEquals(sy.getUpdateBase(),date); 81 } 82 83 public void testItemsDCModule() throws Exception { 84 _testItemDCModule(0); 85 _testItemDCModule(1); 86 } 87 88 protected void _testItemDCModule(int i) throws Exception { 89 List 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 |