1 package com.sun.syndication.unittest;
2
3 import com.sun.syndication.feed.WireFeed;
4 import com.sun.syndication.feed.synd.SyndFeedI;
5 import com.sun.syndication.feed.synd.SyndFeed;
6
7 import java.io.ByteArrayOutputStream;
8 import java.io.ObjectOutputStream;
9 import java.io.ByteArrayInputStream;
10 import java.io.ObjectInputStream;
11
12 /***
13 *
14 * <p>
15 * @author Alejandro Abdelnur
16 *
17 */
18 public abstract class FeedOpsTest extends FeedTest {
19
20 protected FeedOpsTest(String feedType) {
21 super(feedType+".xml");
22 }
23
24
25 public void testWireFeedEquals() throws Exception {
26 WireFeed feed1 = getCachedWireFeed();
27 WireFeed feed2 = getWireFeed();
28 assertTrue(feed1.equals(feed2));
29 }
30
31
32 public void testWireFeedNotEqual() throws Exception {
33 WireFeed feed1 = getCachedWireFeed();
34 WireFeed feed2 = getWireFeed();
35 feed2.setFeedType("dummy");
36 assertFalse(feed1.equals(feed2));
37 }
38
39
40 public void testWireFeedCloning() throws Exception {
41 WireFeed feed1 = getCachedWireFeed();
42 WireFeed feed2 = (WireFeed) feed1.clone();;
43 assertTrue(feed1.equals(feed2));
44 }
45
46
47 public void testWireFeedSerialization() throws Exception {
48 WireFeed feed1 = getCachedWireFeed();
49
50 ByteArrayOutputStream baos = new ByteArrayOutputStream();
51 ObjectOutputStream oos = new ObjectOutputStream(baos);
52 oos.writeObject(feed1);
53 oos.close();
54
55 ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
56 ObjectInputStream ois = new ObjectInputStream(bais);
57 WireFeed feed2 = (WireFeed) ois.readObject();
58 ois.close();
59
60 assertTrue(feed1.equals(feed2));
61 }
62
63
64 public void testWireFeedSyndFeedConversion() throws Exception {
65 SyndFeedI sFeed1 = getCachedSyndFeed();
66 WireFeed wFeed1 = sFeed1.createWireFeed();
67 SyndFeedI sFeed2 = new SyndFeed(wFeed1);
68
69 assertTrue(sFeed1.equals(sFeed2));
70 }
71
72
73 public void testSyndFeedEquals() throws Exception {
74 SyndFeedI feed1 = getCachedSyndFeed();
75 SyndFeedI feed2 = getSyndFeed();
76 assertTrue(feed1.equals(feed2));
77 }
78
79
80 public void testSyndFeedNotEqual() throws Exception {
81 SyndFeedI feed1 = getCachedSyndFeed();
82 SyndFeedI feed2 = getSyndFeed();
83 feed2.setFeedType("dummy");
84 assertFalse(feed1.equals(feed2));
85 }
86
87
88 public void testSyndFeedCloning() throws Exception {
89 SyndFeedI feed1 = getCachedSyndFeed();
90 SyndFeedI feed2 = (SyndFeedI) feed1.clone();;
91 assertTrue(feed1.equals(feed2));
92 }
93
94
95 public void testSyndFeedSerialization() throws Exception {
96 SyndFeedI feed1 = getCachedSyndFeed();
97
98 ByteArrayOutputStream baos = new ByteArrayOutputStream();
99 ObjectOutputStream oos = new ObjectOutputStream(baos);
100 oos.writeObject(feed1);
101 oos.close();
102
103 ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
104 ObjectInputStream ois = new ObjectInputStream(bais);
105 SyndFeedI feed2 = (SyndFeedI) ois.readObject();
106 ois.close();
107
108 assertTrue(feed1.equals(feed2));
109 }
110
111 }