001: package com.sun.syndication.unittest;
002:
003: import com.sun.syndication.feed.WireFeed;
004: import com.sun.syndication.feed.synd.SyndFeed;
005: import com.sun.syndication.feed.synd.SyndFeedImpl;
006:
007: import java.io.ByteArrayOutputStream;
008: import java.io.ObjectOutputStream;
009: import java.io.ByteArrayInputStream;
010: import java.io.ObjectInputStream;
011:
012: /**
013: *
014: * <p>
015: * @author Alejandro Abdelnur
016: *
017: */
018: public abstract class FeedOpsTest extends FeedTest {
019:
020: protected FeedOpsTest(String feedType) {
021: super (feedType + ".xml");
022: System.out.println("Testing " + feedType + ".xml");
023: }
024:
025: //1.2a
026: public void testWireFeedEquals() throws Exception {
027: WireFeed feed1 = getCachedWireFeed();
028: WireFeed feed2 = getWireFeed();
029: assertTrue(feed1.equals(feed2));
030: }
031:
032: //1.2b
033: public void testWireFeedNotEqual() throws Exception {
034: WireFeed feed1 = getCachedWireFeed();
035: WireFeed feed2 = getWireFeed();
036: feed2.setFeedType("dummy");
037: assertFalse(feed1.equals(feed2));
038: }
039:
040: //1.3
041: public void testWireFeedCloning() throws Exception {
042: WireFeed feed1 = getCachedWireFeed();
043: WireFeed feed2 = (WireFeed) feed1.clone();
044: ;
045: assertTrue(feed1.equals(feed2));
046: }
047:
048: // 1.4
049: public void testWireFeedSerialization() throws Exception {
050: WireFeed feed1 = getCachedWireFeed();
051:
052: ByteArrayOutputStream baos = new ByteArrayOutputStream();
053: ObjectOutputStream oos = new ObjectOutputStream(baos);
054: oos.writeObject(feed1);
055: oos.close();
056:
057: ByteArrayInputStream bais = new ByteArrayInputStream(baos
058: .toByteArray());
059: ObjectInputStream ois = new ObjectInputStream(bais);
060: WireFeed feed2 = (WireFeed) ois.readObject();
061: ois.close();
062:
063: assertTrue(feed1.equals(feed2));
064: }
065:
066: // 1.6
067: public void testWireFeedSyndFeedConversion() throws Exception {
068: SyndFeed sFeed1 = getCachedSyndFeed();
069: WireFeed wFeed1 = sFeed1.createWireFeed();
070: SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
071:
072: assertTrue(sFeed1.equals(sFeed2));
073: }
074:
075: //1.7a
076: public void testSyndFeedEquals() throws Exception {
077: SyndFeed feed1 = getCachedSyndFeed();
078: SyndFeed feed2 = getSyndFeed();
079: assertTrue(feed1.equals(feed2));
080: }
081:
082: //1.7b
083: public void testSyndFeedNotEqual() throws Exception {
084: SyndFeed feed1 = getCachedSyndFeed();
085: SyndFeed feed2 = getSyndFeed();
086: feed2.setFeedType("dummy");
087: assertFalse(feed1.equals(feed2));
088: }
089:
090: //1.8
091: public void testSyndFeedCloning() throws Exception {
092: SyndFeed feed1 = getCachedSyndFeed();
093: SyndFeed feed2 = (SyndFeed) feed1.clone();
094: ;
095: assertTrue(feed1.equals(feed2));
096: }
097:
098: //1.9
099: public void testSyndFeedSerialization() throws Exception {
100: SyndFeed feed1 = getCachedSyndFeed();
101:
102: ByteArrayOutputStream baos = new ByteArrayOutputStream();
103: ObjectOutputStream oos = new ObjectOutputStream(baos);
104: oos.writeObject(feed1);
105: oos.close();
106:
107: ByteArrayInputStream bais = new ByteArrayInputStream(baos
108: .toByteArray());
109: ObjectInputStream ois = new ObjectInputStream(bais);
110: SyndFeed feed2 = (SyndFeed) ois.readObject();
111: ois.close();
112:
113: assertTrue(feed1.equals(feed2));
114: }
115:
116: }
|