KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.syndication.unittest;
2
3 import com.sun.syndication.feed.WireFeed;
4 import com.sun.syndication.feed.synd.SyndFeed;
5 import com.sun.syndication.feed.synd.SyndFeedImpl;
6
7 import java.io.ByteArrayOutputStream JavaDoc;
8 import java.io.ObjectOutputStream JavaDoc;
9 import java.io.ByteArrayInputStream JavaDoc;
10 import java.io.ObjectInputStream JavaDoc;
11
12 /**
13  *
14  * <p>
15  * @author Alejandro Abdelnur
16  *
17  */

18 public abstract class FeedOpsTest extends FeedTest {
19
20     protected FeedOpsTest(String JavaDoc feedType) {
21         super(feedType+".xml");
22     }
23
24     //1.2a
25
public void testWireFeedEquals() throws Exception JavaDoc {
26         WireFeed feed1 = getCachedWireFeed();
27         WireFeed feed2 = getWireFeed();
28         assertTrue(feed1.equals(feed2));
29     }
30
31     //1.2b
32
public void testWireFeedNotEqual() throws Exception JavaDoc {
33         WireFeed feed1 = getCachedWireFeed();
34         WireFeed feed2 = getWireFeed();
35         feed2.setFeedType("dummy");
36         assertFalse(feed1.equals(feed2));
37     }
38
39     //1.3
40
public void testWireFeedCloning() throws Exception JavaDoc {
41         WireFeed feed1 = getCachedWireFeed();
42         WireFeed feed2 = (WireFeed) feed1.clone();;
43         assertTrue(feed1.equals(feed2));
44     }
45
46     // 1.4
47
public void testWireFeedSerialization() throws Exception JavaDoc {
48         WireFeed feed1 = getCachedWireFeed();
49
50         ByteArrayOutputStream JavaDoc baos = new ByteArrayOutputStream JavaDoc();
51         ObjectOutputStream JavaDoc oos = new ObjectOutputStream JavaDoc(baos);
52         oos.writeObject(feed1);
53         oos.close();
54
55         ByteArrayInputStream JavaDoc bais = new ByteArrayInputStream JavaDoc(baos.toByteArray());
56         ObjectInputStream JavaDoc ois = new ObjectInputStream JavaDoc(bais);
57         WireFeed feed2 = (WireFeed) ois.readObject();
58         ois.close();
59
60         assertTrue(feed1.equals(feed2));
61     }
62
63     // 1.6
64
public void testWireFeedSyndFeedConversion() throws Exception JavaDoc {
65         SyndFeed sFeed1 = getCachedSyndFeed();
66         WireFeed wFeed1 = sFeed1.createWireFeed();
67         SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
68
69         assertTrue(sFeed1.equals(sFeed2));
70     }
71
72     //1.7a
73
public void testSyndFeedEquals() throws Exception JavaDoc {
74         SyndFeed feed1 = getCachedSyndFeed();
75         SyndFeed feed2 = getSyndFeed();
76         assertTrue(feed1.equals(feed2));
77     }
78
79     //1.7b
80
public void testSyndFeedNotEqual() throws Exception JavaDoc {
81         SyndFeed feed1 = getCachedSyndFeed();
82         SyndFeed feed2 = getSyndFeed();
83         feed2.setFeedType("dummy");
84         assertFalse(feed1.equals(feed2));
85     }
86
87     //1.8
88
public void testSyndFeedCloning() throws Exception JavaDoc {
89         SyndFeed feed1 = getCachedSyndFeed();
90         SyndFeed feed2 = (SyndFeed) feed1.clone();;
91         assertTrue(feed1.equals(feed2));
92     }
93
94     //1.9
95
public void testSyndFeedSerialization() throws Exception JavaDoc {
96         SyndFeed feed1 = getCachedSyndFeed();
97
98         ByteArrayOutputStream JavaDoc baos = new ByteArrayOutputStream JavaDoc();
99         ObjectOutputStream JavaDoc oos = new ObjectOutputStream JavaDoc(baos);
100         oos.writeObject(feed1);
101         oos.close();
102
103         ByteArrayInputStream JavaDoc bais = new ByteArrayInputStream JavaDoc(baos.toByteArray());
104         ObjectInputStream JavaDoc ois = new ObjectInputStream JavaDoc(bais);
105         SyndFeed feed2 = (SyndFeed) ois.readObject();
106         ois.close();
107
108         assertTrue(feed1.equals(feed2));
109     }
110
111 }
112
Popular Tags