001: /*
002: * Created on Jun 24, 2004
003: *
004: */
005: package com.sun.syndication.unittest;
006:
007: import com.sun.syndication.feed.synd.SyndEntry;
008: import com.sun.syndication.feed.synd.SyndContent;
009: import com.sun.syndication.feed.synd.SyndEnclosure;
010: import com.sun.syndication.feed.synd.SyndLink;
011: import com.sun.syndication.io.impl.DateParser;
012:
013: import java.util.List;
014: import java.util.Date;
015:
016: /**
017: * @author pat
018: * @author Dave Johnson (modified for Atom 1.0)
019: *
020: */
021: public class TestSyndFeedAtom10 extends SyndFeedTest {
022:
023: public TestSyndFeedAtom10() {
024: super ("atom_1.0");
025: }
026:
027: protected TestSyndFeedAtom10(String type) {
028: super (type);
029: }
030:
031: protected TestSyndFeedAtom10(String feedType, String feedFileName) {
032: super (feedType, feedFileName);
033: }
034:
035: public void testTitle() throws Exception {
036: assertProperty(getCachedSyndFeed().getTitle(), "feed.title");
037: assertProperty(getCachedSyndFeed().getTitleEx().getValue(),
038: "feed.title");
039: assertEquals("html", getCachedSyndFeed().getTitleEx().getType());
040: }
041:
042: public void testLink() throws Exception {
043: assertEquals(getCachedSyndFeed().getLink(),
044: "http://example.com/blog");
045: }
046:
047: public void getAuthor() throws Exception {
048: assertProperty(getCachedSyndFeed().getAuthor(),
049: "feed.author.name");
050: }
051:
052: public void testCopyright() throws Exception {
053: assertProperty(getCachedSyndFeed().getCopyright(),
054: "feed.copyright");
055: }
056:
057: public void testForeignMarkup() throws Exception {
058: assertEquals(1, ((List) getCachedSyndFeed().getForeignMarkup())
059: .size());
060: }
061:
062: public void testPublishedDate() throws Exception {
063: Date d = DateParser.parseW3CDateTime("2000-01-01T00:00:00Z");
064: assertEquals(getCachedSyndFeed().getPublishedDate(), d);
065: }
066:
067: protected void _testEntry(int i) throws Exception {
068: List items = getCachedSyndFeed().getEntries();
069: SyndEntry entry = (SyndEntry) items.get(i);
070:
071: assertProperty(entry.getTitle(), "feed.entry[" + i + "].title");
072: assertProperty(entry.getTitleEx().getValue(), "feed.entry[" + i
073: + "].title");
074: assertEquals("text", entry.getTitleEx().getType());
075:
076: assertEquals(entry.getLink(), "http://example.com/blog/entry"
077: + (i + 1));
078: assertEquals(((SyndEnclosure) entry.getEnclosures().get(0))
079: .getUrl(), "http://example.com/blog/enclosure"
080: + (i + 1) + ".gif");
081: assertProperty(entry.getAuthor(), "feed.entry[" + i
082: + "].author.name");
083: Date d = DateParser.parseW3CDateTime("2000-0" + (i + 1)
084: + "-01T01:00:00Z");
085: assertEquals(entry.getPublishedDate(), d);
086: assertProperty(entry.getDescription().getValue(), "feed.entry["
087: + i + "].summary");
088: assertProperty(((SyndContent) entry.getContents().get(0))
089: .getValue(), "feed.entry[" + i + "].content[0]");
090: assertEquals(1, ((List) entry.getForeignMarkup()).size());
091: SyndLink slink = (SyndLink) entry.getLinks().get(2);
092: assertTrue(slink.getHref().startsWith("tag:"));
093: }
094:
095: public void testEntry0() throws Exception {
096: _testEntry(0);
097: }
098:
099: public void testEntry1() throws Exception {
100: _testEntry(1);
101: }
102:
103: }
|