diff --git a/src/test/java/org/rometools/feed/module/mediarss/MediaModuleTest.java b/src/test/java/org/rometools/feed/module/mediarss/MediaModuleTest.java index b6de878..d1aab7f 100644 --- a/src/test/java/org/rometools/feed/module/mediarss/MediaModuleTest.java +++ b/src/test/java/org/rometools/feed/module/mediarss/MediaModuleTest.java @@ -9,9 +9,9 @@ package org.rometools.feed.module.mediarss; import java.io.BufferedWriter; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileWriter; -import java.io.InputStreamReader; -import java.net.URL; +import java.io.IOException; import java.util.List; import junit.framework.Test; @@ -21,6 +21,7 @@ import org.rometools.feed.module.AbstractTestCase; import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.io.FeedException; import com.sun.syndication.io.SyndFeedInput; import com.sun.syndication.io.SyndFeedOutput; @@ -41,32 +42,26 @@ public class MediaModuleTest extends AbstractTestCase { } public void testGoogleVideo() throws Exception { - final SyndFeedInput input = new SyndFeedInput(); - final SyndFeed feed = input.build(new InputStreamReader(new URL("http://video.google.com/videofeed?type=top100new&num=20&output=rss").openStream())); + final SyndFeed feed = getSyndFeed(new File(getTestFile("data/YouTube-MostPopular.rss"))); for (final Object element : feed.getEntries()) { final SyndEntry entry = (SyndEntry) element; final MediaEntryModule m = (MediaEntryModule) entry.getModule(MediaModule.URI); - System.out.print(m); + assertNotNull(m); } } public void testParse() throws Exception { - final SyndFeedInput input = new SyndFeedInput(); final File test = new File(super.getTestFile("xml")); final File[] files = test.listFiles(); for (int j = 0; j < files.length; j++) { if (!files[j].getName().endsWith(".xml")) { continue; } - final SyndFeed feed = input.build(files[j]); - // System.out.println( feed ); - final List entries = feed.getEntries(); - for (int i = 0; i < entries.size(); i++) { - // System.out.println( ((SyndEntry) entries.get(i)).getModule( MediaModule.URI ) ); - } + final SyndFeed feed = getSyndFeed(files[j]); + final List entries = feed.getEntries(); final SyndFeedOutput output = new SyndFeedOutput(); output.output(feed, new File("target/" + j + ".xml")); - final SyndFeed feed2 = input.build(new File("target/" + j + ".xml")); + final SyndFeed feed2 = getSyndFeed(new File("target/" + j + ".xml")); for (int i = 0; i < entries.size(); i++) { BufferedWriter b = new BufferedWriter(new FileWriter("target/" + j + "a.txt")); b.write("" + ((SyndEntry) entries.get(i)).getModule(MediaModule.URI)); @@ -79,57 +74,8 @@ public class MediaModuleTest extends AbstractTestCase { } } - /** - * This code represents the original MediaModuleTest main class from openvision.tv - */ - public void xtestOriginal() throws Exception { - // - /* - * //You can test with blip tv or broadcast machine - * - * String rss = "http://blip.tv/?1=1&&skin=rss";// // String rss = "http://openvision.tv/bm/rss.php?i=4"; // String rss = - * "http://api.search.yahoo.com/VideoSearchService/rss/videoSearch.xml?appid=yahoosearchvideorss&query=surfing&adult_ok=0"; - * - * - * URLConnection uc = new URL(rss).openConnection(); String contentType = uc.getContentEncoding(); - * - * WireFeedInput input = new WireFeedInput(); - * - * XmlReader xmlReader = new XmlReader(uc.getInputStream(), contentType, true); - * - * Channel chnl = (Channel)input.build(xmlReader); - * - * String feedTitle = chnl.getTitle(); String feedDesc = chnl.getDescription(); - * - * - * List items = chnl.getItems(); - * - * ListIterator li = items.listIterator(); Item item = null; Enclosure enc = null; MediaModule mModule = null; - * - * while (li.hasNext()) { - * - * item = (Item)li.next(); enc = (Enclosure)item.getEnclosures().get(0); - * - * mModule = (MediaModule)item.getModule(MediaModule.URI); - * - * List modules = item.getModules(); System.out.println("title: " + item.getTitle()); System.out.println("module count: " + modules.size()); - * - * if (mModule != null) { Thumbnail[] mThumbs = mModule.getMediaThumbnails(); - * - * if (mThumbs != null) { for (int i = 0; i < mThumbs.length; i++) { String imgUrl = mThumbs[i].getUrl(); System.out.println("got MediaModule img " + i - * + ": " + imgUrl); } } - * - * System.out.println("MediaModule title: " + mModule.getTitle()); System.out.println("MediaModule isAdult: " + mModule.isAdult()); /* if - * (mModule.getMediaContent() != null) { for (int i = 0; i < mModule.getMediaContent().length; i++) { MediaContent mc = mModule.getMediaContent()[i]; - * mThumbs = mc.getMediaThumbnails(); if (mThumbs != null) { for (int n = 0; n < mThumbs.length; n++) { String imgUrl = mThumbs[n].getUrl(); - * System.out.println("got MediaContentImage " + n + " img: " + imgUrl); } } System.out.println("MediaContent title:" + mc.getTitle()); - * System.out.println("MediaContent text:" + mc.getText()); - * - * } - * - * } - * - * } else { System.out.println("no MediaModule!"); } } - */ + private SyndFeed getSyndFeed(final File file) throws FileNotFoundException, IllegalArgumentException, IOException, FeedException { + final SyndFeedInput input = new SyndFeedInput(); + return input.build(file); } } diff --git a/src/test/resources/data/YouTube-MostPopular.rss b/src/test/resources/data/YouTube-MostPopular.rss new file mode 100644 index 0000000..63e20c1 --- /dev/null +++ b/src/test/resources/data/YouTube-MostPopular.rss @@ -0,0 +1,54 @@ +http://gdata.youtube.com/feeds/api/standardfeeds/most_popular2013-10-09T17:35:53.618ZMost Popularhttp://www.gstatic.com/youtube/img/logo.pngYouTubehttp://www.youtube.com/YouTube data API9125http://gdata.youtube.com/feeds/api/videos/_OBlgSz8sSM2007-05-22T20:29:24.000Z2013-10-09T17:34:13.000ZCharlie bit my finger - again !HDCYThttps://gdata.youtube.com/feeds/api/users/HDCYTComedyhdcytT-Shirts http://charliebitme.firebrandstore.com/ +iPhone http://itunes.apple.com/gb/app/charlie-bit-me!!!/id494858348?mt=8 +Android https://play.google.com/store/apps/details?id=com.viralspiral.charlie +Even had I thought of trying to get my boys to do this I probably couldn't have. Neither were coerced into any of this and neither were hurt (for very long anyway). This was just one of those moments when I had the video camera out because the boys were being fun and they provided something really very funny. + +FAQ Harry is 8 3/4, Charlie is 6 1/2, Jasper is 4 1/4, Rupert is 1 1/2 +(November 2012) + +Harry and Charlie Blogging - Charlie Bit My Finger Again! +http://harryandcharlie.blogspot.com/ + +Twitter +http://twitter.com/harryandcharlieCharlie bit my finger - again !2007-05-22T20:29:24.000ZUCfHZCZHykS3IQDPyFfnqjWg_OBlgSz8sSM2007-03-19http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg2006-04-06T21:30:53.000Z2013-10-09T17:22:49.000ZEvolution of Dance - By Judson LaipplyJudson Laipplyhttps://gdata.youtube.com/feeds/api/users/judsonlaipplyComedyjudsonlaipplyFor more visit http://www.mightaswelldance.comEvolution of Dance - By Judson Laipply2006-04-06T21:30:53.000ZUC5B9H4l2vtgo7cAoExcFh-wdMH0bHeiRNghttp://gdata.youtube.com/feeds/api/videos/1uwOL4rB-go2007-09-29T17:04:02.000Z2013-10-09T17:31:44.000ZJeff Dunham - Achmed the Dead TerroristKrowBatelliohttps://gdata.youtube.com/feeds/api/users/KrowBatellioEntertainmentkrowbatellioAll rights reserved to Jeff Dunham.Jeff Dunham - Achmed the Dead Terroristwidescreen2007-09-29T17:04:02.000ZUC0W_cSq4Vhidc0LsuHT27jA1uwOL4rB-gohttp://gdata.youtube.com/feeds/api/videos/7AVHXe-ol-s2006-10-11T22:20:59.000Z2013-10-09T15:20:47.000ZSyndication of this video was restricted.Cut Chemist feat. Hymnal "What's the Altitude" Music Videointernmarkethttps://gdata.youtube.com/feeds/api/users/internmarketMusicinternmarketCut Chemist Music Video "What's the Altitude" Music VideoCut Chemist feat. Hymnal "What's the Altitude" Music Video2006-10-11T22:20:59.000ZUCwd3x4lKPVvvnziwO_CcabA7AVHXe-ol-shttp://gdata.youtube.com/feeds/api/videos/ePyRrb2-fzs2007-05-22T14:42:52.000Z2013-10-09T16:35:36.000ZSyndication of this video was restricted.Timbaland - Apologize (feat. One Republic)1988bastihttps://gdata.youtube.com/feeds/api/users/1988bastiMusic1988bastiVideo made by: http://www.aaronplatt.com / http://de.youtube.com/user/plattino + +Song: Timbaland presents One Republic: Apologize + +Lyrics: + +I'm holding on your rope, +Got me ten feet off the ground +And I'm hearing what you say but I just can't make a sound +You tell me that you need me +Then you go and cut me down, but wait +You tell me that you're sorry +Didn't think I'd turn around, and say... + +That it's too late to apologize, it's too late +I said it's too late to apologize, it's too late + +I'd take another chance, take a fall +Take a shot for you +And I need you like a heart needs a beat +But it's nothing new - yeah yeah + +I loved you with the fire red +Now it's turning blue, and you say... +"Sorry" like the angel heaven let me think was you +But I'm afraid... + +It's too late to apologize, it's too late +I said it's too late to apologize, it's too late whoa..... + +It's too late to apologize, it's too late +I said it's too late to apologize, it's too late +I said it's too late to apologize, yeah +I said it's too late to apologize, yeah +I'm holding on your rope, got me ten feet off the ground...Timbaland - Apologize (feat. One Republic)widescreen2007-05-22T14:42:52.000ZUChLKT__F8P1juQWQ39whVnQePyRrb2-fzs2007-05-21http://gdata.youtube.com/feeds/api/videos/Tx1XIm6q4r42007-03-24T06:32:49.000Z2013-10-09T17:28:41.000ZSyndication of this video was restricted.Potter Puppet Pals: The Mysterious Ticking NoiseNeilCicieregahttps://gdata.youtube.com/feeds/api/users/NeilCicieregaComedyneilcicieregahttp://www.potterpuppetpals.com +Snape hears a strange ticking sound. Love ensues.Potter Puppet Pals: The Mysterious Ticking Noise2007-03-24T06:32:49.000ZUCDrJor35jYVnuC3JgRzheIwTx1XIm6q4r4http://gdata.youtube.com/feeds/api/videos/FzRH3iTQPrk2006-11-06T15:51:58.000Z2013-10-09T17:33:13.000ZThe Sneezing Baby Pandajimvwmosshttps://gdata.youtube.com/feeds/api/users/jimvwmossComedyjimvwmossA Baby Panda Sneezing + +Original footage taken and being used with kind permission of LJM Productions Pty. Ltd.,/Wild Candy Pty. Ltd. Authentic t-shirts http://www.sneezingbabypanda.com + +*The link in the video is at the request of the original owner of the footage. Do NOT ask for your link to be added as I will not respond. Thank you.The Sneezing Baby Panda2006-11-06T15:51:58.000ZUCX72ZQtKY8DUYQqYBc3zMRQFzRH3iTQPrkhttp://gdata.youtube.com/feeds/api/videos/F5VvvVxuKko2007-03-19T18:01:58.000Z2013-10-09T17:33:28.000ZVanessa Hudgens Say Ok Music Video (Official with Zac Efron)hollywoodrecordshttps://gdata.youtube.com/feeds/api/users/hollywoodrecordsMusichollywoodrecordsSay Ok is the second single from High School Musical's own Vanessa Hudgens. Her debut album V is in stores now and features the hit single "Come Back To Me".Vanessa Hudgens Say Ok Music Video (Official with Zac Efron)2007-03-19T18:01:58.000ZUCufxAtBrPqlPy5fHNIZwauAF5VvvVxuKkohttp://gdata.youtube.com/feeds/api/videos/QWNoiVrJDsE2007-06-13T18:38:37.000Z2013-10-09T17:32:06.000Z☆"Britains Got Talent or Americas Got Talent ♥ Connie Talbot WOWs Simon Cowell !"behindthesecrethttps://gdata.youtube.com/feeds/api/users/behindthesecretEntertainmentbehindthesecretYou won't believe which of your favorite celebs have had a nip and tuck! #5 is extreme! http://bit.ly/13pqycy + +Download album: http://amzn.to/SOgKb0☆"Britains Got Talent or Americas Got Talent ♥ Connie Talbot WOWs Simon Cowell !"2007-06-13T18:38:37.000ZUC_UgAFa_i_baEmeoAgsqYgwQWNoiVrJDsE \ No newline at end of file