KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.impl.DateParser;
10
11 import java.util.List JavaDoc;
12 import java.util.Date JavaDoc;
13
14 /**
15  * @author pat
16  *
17  */

18 public class TestSyndFeedAtom03 extends SyndFeedTest {
19
20     public TestSyndFeedAtom03() {
21         super("atom_0.3");
22     }
23
24     protected TestSyndFeedAtom03(String JavaDoc type) {
25         super(type);
26     }
27
28     protected TestSyndFeedAtom03(String JavaDoc feedType,String JavaDoc feedFileName) {
29         super(feedType,feedFileName);
30     }
31
32     public void testTitle() throws Exception JavaDoc {
33         assertProperty(getCachedSyndFeed().getTitle(),"feed.title");
34     }
35
36     public void testLink() throws Exception JavaDoc {
37         assertProperty( getCachedSyndFeed().getLink(),"feed.link^href");
38     }
39
40     public void getAuthor() throws Exception JavaDoc {
41         assertProperty(getCachedSyndFeed().getAuthor(),"feed.author.name");
42     }
43
44     public void testCopyright() throws Exception JavaDoc {
45         assertProperty(getCachedSyndFeed().getCopyright(),"feed.copyright");
46     }
47
48     public void testPublishedDate() throws Exception JavaDoc {
49         Date JavaDoc d = DateParser.parseW3CDateTime("2000-01-01T00:00:00Z");
50         assertEquals(getCachedSyndFeed().getPublishedDate(),d);
51     }
52
53
54     protected void _testEntry(int i) throws Exception JavaDoc {
55         List JavaDoc items = getCachedSyndFeed().getEntries();
56         SyndEntry entry = (SyndEntry) items.get(i);
57         assertProperty(entry.getTitle(),"feed.entry["+i+"].title");
58         assertProperty(entry.getLink(),"feed.entry["+i+"].link^href");
59         assertProperty(entry.getAuthor(),"feed.entry["+i+"].author.name");
60         Date JavaDoc d = DateParser.parseW3CDateTime("2000-0"+(i+1)+"-01T00:00:00Z");
61         assertEquals(entry.getPublishedDate(),d);
62         assertProperty(entry.getDescription().getValue(),"feed.entry["+i+"].summary");
63         assertProperty(((SyndContent)entry.getContents().get(0)).getValue(),"feed.entry["+i+"].content[0]");
64         assertProperty(((SyndContent)entry.getContents().get(1)).getValue(),"feed.entry["+i+"].content[1]");
65     }
66
67     public void testEntry0() throws Exception JavaDoc {
68         _testEntry(0);
69     }
70
71     public void testEntry1() throws Exception JavaDoc {
72         _testEntry(1);
73     }
74
75
76 }
77
Popular Tags