1   /*
2    * Created on Jun 24, 2004
3    *
4    */
5   package com.sun.syndication.unittest;
6   
7   import com.sun.syndication.feed.synd.SyndEntry;
8   import com.sun.syndication.feed.synd.SyndContent;
9   import com.sun.syndication.feed.synd.SyndEnclosure;
10  import com.sun.syndication.feed.synd.SyndLink;
11  import com.sun.syndication.io.impl.DateParser;
12  
13  import java.util.List;
14  import java.util.Date;
15  
16  /***
17   * @author pat
18   * @author Dave Johnson (modified for Atom 1.0)
19   *
20   */
21  public class TestSyndFeedAtom10 extends SyndFeedTest {
22  
23  	public TestSyndFeedAtom10() {
24  		super("atom_1.0");
25  	}
26  
27      protected TestSyndFeedAtom10(String type) {
28          super(type);
29      }
30  
31      protected TestSyndFeedAtom10(String feedType,String feedFileName) {
32          super(feedType,feedFileName);
33      }
34  
35      public void testTitle() throws Exception {
36          assertProperty(getCachedSyndFeed().getTitle(),"feed.title");
37          assertProperty(getCachedSyndFeed().getTitleEx().getValue(),"feed.title");
38          assertEquals("html", getCachedSyndFeed().getTitleEx().getType());
39      }
40  
41      public void testLink() throws Exception {
42          assertEquals( getCachedSyndFeed().getLink(),"http://example.com/blog");
43      }
44  
45      public void getAuthor() throws Exception {
46          assertProperty(getCachedSyndFeed().getAuthor(),"feed.author.name");
47      }
48  
49      public void testCopyright() throws Exception {
50          assertProperty(getCachedSyndFeed().getCopyright(),"feed.copyright");
51      }
52  
53      public void testForeignMarkup() throws Exception {
54          assertEquals(1, ((List)getCachedSyndFeed().getForeignMarkup()).size());
55      }
56  
57      public void testPublishedDate() throws Exception {
58          Date d = DateParser.parseW3CDateTime("2000-01-01T00:00:00Z");
59          assertEquals(getCachedSyndFeed().getPublishedDate(),d);
60      }
61  
62  
63      protected void _testEntry(int i) throws Exception {
64          List items = getCachedSyndFeed().getEntries();
65          SyndEntry entry = (SyndEntry) items.get(i);
66  
67          assertProperty(entry.getTitle(),"feed.entry["+i+"].title");
68          assertProperty(entry.getTitleEx().getValue(),"feed.entry["+i+"].title");
69          assertEquals("text",entry.getTitleEx().getType());
70          
71          assertEquals(entry.getLink(),"http://example.com/blog/entry" + (i + 1));
72          assertEquals(((SyndEnclosure)entry.getEnclosures().get(0)).getUrl(),"http://example.com/blog/enclosure"+(i+1)+".gif");
73          assertProperty(entry.getAuthor(),"feed.entry["+i+"].author.name");
74          Date d = DateParser.parseW3CDateTime("2000-0"+(i+1)+"-01T01:00:00Z");
75          assertEquals(entry.getPublishedDate(),d);
76          assertProperty(entry.getDescription().getValue(),"feed.entry["+i+"].summary");
77          assertProperty(((SyndContent)entry.getContents().get(0)).getValue(),"feed.entry["+i+"].content[0]");
78          assertEquals(1, ((List)entry.getForeignMarkup()).size());
79          SyndLink slink = (SyndLink)entry.getLinks().get(2);
80          assertTrue(slink.getHref().startsWith("tag:"));
81      }
82  
83      public void testEntry0() throws Exception {
84          _testEntry(0);
85      }
86  
87      public void testEntry1() throws Exception {
88          _testEntry(1);
89      }
90      
91  }