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 ; 8 import java.io.ObjectOutputStream ; 9 import java.io.ByteArrayInputStream ; 10 import java.io.ObjectInputStream ; 11 12 18 public abstract class FeedOpsTest extends FeedTest { 19 20 protected FeedOpsTest(String feedType) { 21 super(feedType+".xml"); 22 } 23 24 public void testWireFeedEquals() throws Exception { 26 WireFeed feed1 = getCachedWireFeed(); 27 WireFeed feed2 = getWireFeed(); 28 assertTrue(feed1.equals(feed2)); 29 } 30 31 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 public void testWireFeedCloning() throws Exception { 41 WireFeed feed1 = getCachedWireFeed(); 42 WireFeed feed2 = (WireFeed) feed1.clone();; 43 assertTrue(feed1.equals(feed2)); 44 } 45 46 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 public void testWireFeedSyndFeedConversion() throws Exception { 65 SyndFeed sFeed1 = getCachedSyndFeed(); 66 WireFeed wFeed1 = sFeed1.createWireFeed(); 67 SyndFeed sFeed2 = new SyndFeedImpl(wFeed1); 68 69 assertTrue(sFeed1.equals(sFeed2)); 70 } 71 72 public void testSyndFeedEquals() throws Exception { 74 SyndFeed feed1 = getCachedSyndFeed(); 75 SyndFeed feed2 = getSyndFeed(); 76 assertTrue(feed1.equals(feed2)); 77 } 78 79 public void testSyndFeedNotEqual() throws Exception { 81 SyndFeed feed1 = getCachedSyndFeed(); 82 SyndFeed feed2 = getSyndFeed(); 83 feed2.setFeedType("dummy"); 84 assertFalse(feed1.equals(feed2)); 85 } 86 87 public void testSyndFeedCloning() throws Exception { 89 SyndFeed feed1 = getCachedSyndFeed(); 90 SyndFeed feed2 = (SyndFeed) feed1.clone();; 91 assertTrue(feed1.equals(feed2)); 92 } 93 94 public void testSyndFeedSerialization() throws Exception { 96 SyndFeed 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 SyndFeed feed2 = (SyndFeed) ois.readObject(); 106 ois.close(); 107 108 assertTrue(feed1.equals(feed2)); 109 } 110 111 } 112 | Popular Tags |