Package therandomhomepage.common.rss

Examples of therandomhomepage.common.rss.RSSItem


                UIObject.setVisible(imageElement, false);
            }


            int randomIdx = Random.nextInt(rssItems.length);
            RSSItem randomItem = (RSSItem) rssItems[randomIdx];

            Element imageElement = DOM.getChild(lightbox.getElement(), randomIdx);
            DOM.setInnerHTML(imageElement, StringUtil.grep(randomItem.getDesc(), "<img", ">"));

            UIObject.setVisible(imageElement, true);
            prevIdx = randomIdx;
            randomFlickrImageTitle.setHTML("<a class=\"randomFlickrImageTitle\" target=\"_new\" href=\"" + randomItem.getLink() + "\">" + getTitle(randomItem) + "</a>");
        }
    }
View Full Code Here


    }

    private Image[] getImages(RSSItem rssItems[]) {
        Image[] images = new Image[rssItems.length];
        for (int i = 0; i < rssItems.length; i++) {
            RSSItem rssItem = (RSSItem) rssItems[i];
            images[i] = rssItem.getMedia().getContent();
            images[i].setVisible(false);
        }
        return images;
    }
View Full Code Here

    public void testParseYahooRSS() {
        List rssItems = JSON2RSSParser.parse(yahooRSSJSON);
        assertNotNull(rssItems);
        assertEquals(4, rssItems.size());

        RSSItem expectedRSSItem1 = new RSSItem("Mexican tells crowd he'll seek recount \n" +
                "    (AP)", "http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_la_am_ca/mexico_elections", "<p><a href=\"http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_la_am_ca/mexico_elections\"><img src=\"http://us.news3.yimg.com/us.i2.yimg.com/p/ap/20060709/capt.5a2fa662f8bc413597f669a36b502eab.mexico_elections__momu107.jpg?x=130&amp;y=83&amp;sig=67xo1gNkImk80pvOmOFUGQ--\" align=\"left\" height=\"83\" width=\"130\" alt=\"A lone flag of the Democratic Revolution Party (PRD) flies over thousands of supporters of Mexican presidential candidate Andres Manuel Lopez Obrador during a rally at the main Zocalo plaza in Mexico City, Mexico on Saturday, July 8, 2006. Obrador called his supporters onto the streets Saturday to protest his rival's narrow victory in a vote he said was more fraudulent than those held during 71 years of one-party rule. (AP Photo/Marco Ugarte) border=\"0\" /></a>AP - Leftist presidential candidate Andres Manuel Lopez Obrador called on a huge crowd of supporters Saturday to keep peacefully protesting as he goes to court to challenge what he called his fraudulent electoral defeat.</p><br clear=all>");
        expectedRSSItem1.setGuid("ap/20060709/mexico_elections");
        expectedRSSItem1.setPublishedDate("Sun, 09 Jul 2006 03:22:54 GMT");
        System.out.println("JSON2RSSParser_UT.testParseYahooRSS");
        assertRSSItem(expectedRSSItem1, rssItems);

        RSSItem expectedRSSItem2 = new RSSItem("Scores feared dead in Siberia runway crash \n" +
                "    (AP)", "http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_eu/russia_plane_crash", "AP - An airplane carrying about 200 people crashed Sunday in the Siberian city of Irkutsk and most on board were feared dead, officials said.");
        expectedRSSItem2.setGuid("ap/20060709/russia_plane_crash");
        expectedRSSItem2.setPublishedDate("Sun, 09 Jul 2006 03:58:19 GMT");
        assertRSSItem(expectedRSSItem2, rssItems);

        RSSItem expectedRSSItem3 = new RSSItem("U.S. seeks to exhume Iraqi girl's remains \n" +
                "    (AP)", "http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_mi_ea/iraq_rape_investigation", "<p><a href=\"http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_mi_ea/iraq_rape_investigation\"><img src=\"http://us.news3.yimg.com/us.i2.yimg.com/p/ap/20060706/capt.505f0de59abc48fb931cf4e851be7378.iraq_bag126.jpg?x=130&amp;y=86&amp;sig=D5Qs9rc_s61I84Jz1d1wvg--\" align=\"left\" height=\"86\" width=\"130\" alt=\"Neighbor and eyewitness Hussein Mohammed, 33, points to the charred ground where clothing of the young Iraqi girl who was allegedly raped then killed along with family members was burned outside of their home, Thursday, July 6, 2006, in Mahmoudiya, south of Baghdad, Iraq. Former US Army Pfc. Steve D. Green was charged Monday in federal court in Charlotte, North Carolina, with rape and four counts of murder. At least four other U.S. soldiers still in Iraq are under investigation in the attack. (AP Photo/Ali al-Mahmouri) border=\"0\" /></a>AP - U.S. investigators have asked Iraqi authorities to help them navigate cultural sensitivities to exhume the body of a teenager allegedly raped and murdered with her family by American soldiers, a military official said Saturday.</p><br clear=all>");
        expectedRSSItem3.setGuid("ap/20060709/iraq_rape_investigation");
        expectedRSSItem3.setPublishedDate("Sun, 09 Jul 2006 02:22:45 GMT");
        assertRSSItem(expectedRSSItem3, rssItems);

        RSSItem expectedRSSItem4 = new RSSItem("Astronauts: Daring spacewalk method works \n" +
                "    (AP)", "http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_sc/space_shuttle", "<p><a href=\"http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_sc/space_shuttle\"><img src=\"http://us.news3.yimg.com/us.i2.yimg.com/p/ap/20060708/capt.d38cfd8b40774ebe9bb3c06b25ac41be.space_shuttle_txdc116.jpg?x=130&amp;y=97&amp;sig=1lrj6s3UxNaH.vQDoHFKEQ--\" align=\"left\" height=\"97\" width=\"130\" alt=\"In this image made from NASA TV, astronaut Piers Sellers, works on the end of the robotic arm during a spacewalk  Saturday, July 8, 2006.  Sellers is testing how different movements affect the robotic arm.  (AP Photo/NASA TV) border=\"0\" /></a>AP - A key test of a daring yet wobbly spacewalking technique that could be used someday to repair space shuttle heat shields worked well Saturday and got good reviews from two astronauts from the shuttle Discovery, NASA officials said.</p><br clear=all>");
        expectedRSSItem4.setGuid("ap/20060709/space_shuttle");
        expectedRSSItem4.setPublishedDate("Sun, 09 Jul 2006 03:13:06 GMT");
        assertRSSItem(expectedRSSItem4, rssItems);

    }
View Full Code Here

        List rssItems = JSON2RSSParser.parse(googleRSSJSON);
        assertNotNull(rssItems);
        assertEquals(6, rssItems.size());

        RSSItem expectedRSSItem1 = new RSSItem("Plane crashes in Russia, death toll reaches 120 - Reuters.uk", "http://news.google.com/news/url?sa=T&ct=us/0-0-0&fd=R&url=http://today.reuters.co.uk/news/newsArticle.aspx%3Ftype%3DtopNews%26storyID%3D2006-07-09T072653Z_01_L09335850_RTRUKOC_0_UK-RUSSIA-PLANE.xml&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg", "<br><table border=0 align= cellpadding=5 cellspacing=0><tr><td width=80 align=center valign=top><a href=\"http://news.google.com/news/url?sa=T&ct=us/0-0i-0&fd=R&url=http://news.bbc.co.uk/1/hi/world/europe/5162082.stm&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg\"><img src=http://news.google.com/news?imgefp=RVLpY5ko6Q8J&imgurl=newsimg.bbc.co.uk/media/images/41864000/jpg/_41864964_crash.jpg width=79 height=59 alt=\"\" border=1><br><font size=-2>BBC News</font></a></td></tr></table><a href=\"http://news.google.com/news/url?sa=T&ct=us/0-0-0&fd=R&url=http://today.reuters.co.uk/news/newsArticle.aspx%3Ftype%3DtopNews%26storyID%3D2006-07-09T072653Z_01_L09335850_RTRUKOC_0_UK-RUSSIA-PLANE.xml&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg\"><b>Plane crashes in Russia, death toll reaches 120</b></a><br><font size=-1><font color=#6f6f6f><b>Reuters.uk&nbsp;-</font> <nobr>25 minutes ago</nobr></b></font><br><font size=-1>By Dmitry Solovyov. MOSCOW (Reuters) - A Russian airliner crashed on landing and burst into flames in Siberia on Sunday, killing at least 120 people and injuring more than 50, emergencies officials said. A <b>...</b>  </font><br><font size=-1><a href=\"http://news.google.com/news/url?sa=T&ct=us/0-0-1&fd=R&url=http://news.independent.co.uk/world/asia/article1168576.ece&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg\">118 killed in Siberia plane crash</a> <font size=-1 color=#6f6f6f><nobr>Independent</nobr></font></font><br><font size=-1><a href=\"http://news.google.com/news/url?sa=T&ct=us/0-0-2&fd=R&url=http://www.tass.ru/eng/level2.html%3FNewsID%3D10606632%26PageNum%3D0&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg\">A-310 crash in Irkutsk leaves 127 dead</a> <font size=-1 color=#6f6f6f><nobr>ITAR-TASS</nobr></font></font><br><font size=-1 class=p><a href=\"http://news.google.com/news/url?sa=T&ct=us/0-0-3&fd=R&url=http://english.eastday.com/eastday/englishedition/node20676/userobject1ai2166050.html&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg\"><nobr>EastDay.com</nobr></a>&nbsp;- <a href=\"http://news.google.com/news/url?sa=T&ct=us/0-0-4&fd=R&url=http://www.nytimes.com/2006/07/09/world/europe/09crash.html%3Fhp%26ex%3D1152504000%26en%3D4e6cdc6d6ae4bc76%26ei%3D5094%26partner%3Dhomepage&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg\"><nobr>New York Times</nobr></a>&nbsp;- <a href=\"http://news.google.com/news/url?sa=T&ct=us/0-0-5&fd=R&url=http://msnbc.msn.com/id/13773633/&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg\"><nobr>MSNBC</nobr></a>&nbsp;- <a href=\"http://news.google.com/news/url?sa=T&ct=us/0-0-6&fd=R&url=http://news.bbc.co.uk/2/hi/5162082.stm%3Fls&cid=1107810086&ei=X7awRISXGoz8oQLrsvnMBg\"><nobr>BBC News</nobr></a>&nbsp;- </font><font class=p size=-1><a class=p href=http://news.google.com/?ncl=http://today.reuters.co.uk/news/newsArticle.aspx%3Ftype%3DtopNews%26storyID%3D2006-07-09T072653Z_01_L09335850_RTRUKOC_0_UK-RUSSIA-PLANE.xml&hl=en><nobr><b>all 441 related</b></nobr></a></font><br clear=all>");
        expectedRSSItem1.setGuid("tag:news.google.com,2005:cluster=4207d726");
        expectedRSSItem1.setPublishedDate("Sun, 09 Jul 2006 07:30:00 GMT");

        assertRSSItem(expectedRSSItem1, rssItems);
    }
View Full Code Here

    private void assertRSSItem(RSSItem expectedRSSItem, List actualRSSItems) {

        boolean asserted = false;
        for (int i = 0; i < actualRSSItems.size(); i++) {
            RSSItem actualRSSItem = (RSSItem) actualRSSItems.get(i);
            if (expectedRSSItem.getTitle().equals(actualRSSItem.getTitle())) {
                asserted = true;
                assertEquals(expectedRSSItem.getTitle(), actualRSSItem.getTitle());
                assertEquals(expectedRSSItem.getLink(), actualRSSItem.getLink());
                assertEquals(expectedRSSItem.getDesc(), actualRSSItem.getDesc());
                assertEquals(expectedRSSItem.getGuid(), actualRSSItem.getGuid());
                assertEquals(expectedRSSItem.getPublishedDate(), actualRSSItem.getPublishedDate());
                break;
            }
        }
        assertTrue("Should have asserted with some values !", asserted);
    }
View Full Code Here

    private void assertResult(String result) {
        List rssItems = RSS2XMLDocumentParser.parse(result);
        assertEquals(1,rssItems.size());
        for (Iterator iterator = rssItems.iterator(); iterator.hasNext();) {
            RSSItem rssItem = (RSSItem) iterator.next();
            assertEquals("hotel glória",rssItem.getTitle());
            assertEquals("http://www.flickr.com/photos/gastaum/310473631/",rssItem.getLink());
            String expectedDesc = "<p><a href=\"http://www.flickr.com/people/gastaum/\">ftrc</a> posted a photo:</p>\n" +
                    "\n" +
                    "<p><a href=\"http://www.flickr.com/photos/gastaum/310473631/\" title=\"hotel glória\"><img src=\"http://static.flickr.com/123/310473631_0f69135463_m.jpg\" width=\"240\" height=\"176\" alt=\"hotel glória\" style=\"border: 1px solid #ddd;\" /></a></p>\n" +
                    "\n" +
                    "<p>hotel glória<br />\n" +
                    "<br />\n" +
                    "djs<br />\n" +
                    "<br />\n" +
                    "joakim + marcos morcerf + luca &amp; liana + no porn<br />\n" +
                    "<br />\n" +
                    "<a href=\"http://www.clubegloria.com.br\">www.clubegloria.com.br</a></p>";
            assertEquals(expectedDesc,rssItem.getDesc());

            String expectedContentImage = "<IMG class=gwt-Image height=176 src=\"http://static.flickr.com/123/310473631_0f69135463_m.jpg\" width=240 __eventBits=\"98429\" onchange=\"null\">";
            String actualContent = rssItem.getMedia().getContent().toString();
            assertEquals(expectedContentImage, actualContent);
        }
        finishTest();
    }
View Full Code Here

* Time: 4:57:24 AM
*/
public class Randomizer_UT extends TheRandomHomepageAbstract_UT {

  public void testGetRandomItem() {
    RSSItem expectedRSSItem1 = new RSSItem("Mexican tells crowd he'll seek recount \n" +
            "    (AP)", "http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_la_am_ca/mexico_elections", "<p><a href=\"http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_la_am_ca/mexico_elections\"><img src=\"http://us.news3.yimg.com/us.i2.yimg.com/p/ap/20060709/capt.5a2fa662f8bc413597f669a36b502eab.mexico_elections__momu107.jpg?x=130&amp;y=83&amp;sig=67xo1gNkImk80pvOmOFUGQ--\" align=\"left\" height=\"83\" width=\"130\" alt=\"A lone flag of the Democratic Revolution Party (PRD) flies over thousands of supporters of Mexican presidential candidate Andres Manuel Lopez Obrador during a rally at the main Zocalo plaza in Mexico City, Mexico on Saturday, July 8, 2006. Obrador called his supporters onto the streets Saturday to protest his rival's narrow victory in a vote he said was more fraudulent than those held during 71 years of one-party rule. (AP Photo/Marco Ugarte) border=\"0\" /></a>AP - Leftist presidential candidate Andres Manuel Lopez Obrador called on a huge crowd of supporters Saturday to keep peacefully protesting as he goes to court to challenge what he called his fraudulent electoral defeat.</p><br clear=all>");
    expectedRSSItem1.setGuid("ap/20060709/mexico_elections");
    expectedRSSItem1.setPublishedDate("Sun, 09 Jul 2006 03:22:54 GMT");

    RSSItem expectedRSSItem2 = new RSSItem("Scores feared dead in Siberia runway crash \n" +
            "    (AP)", "http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_eu/russia_plane_crash", "AP - An airplane carrying about 200 people crashed Sunday in the Siberian city of Irkutsk and most on board were feared dead, officials said.");
    expectedRSSItem2.setGuid("ap/20060709/russia_plane_crash");
    expectedRSSItem2.setPublishedDate("Sun, 09 Jul 2006 03:58:19 GMT");

    RSSItem expectedRSSItem3 = new RSSItem("U.S. seeks to exhume Iraqi girl's remains \n" +
            "    (AP)", "http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_mi_ea/iraq_rape_investigation", "<p><a href=\"http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_re_mi_ea/iraq_rape_investigation\"><img src=\"http://us.news3.yimg.com/us.i2.yimg.com/p/ap/20060706/capt.505f0de59abc48fb931cf4e851be7378.iraq_bag126.jpg?x=130&amp;y=86&amp;sig=D5Qs9rc_s61I84Jz1d1wvg--\" align=\"left\" height=\"86\" width=\"130\" alt=\"Neighbor and eyewitness Hussein Mohammed, 33, points to the charred ground where clothing of the young Iraqi girl who was allegedly raped then killed along with family members was burned outside of their home, Thursday, July 6, 2006, in Mahmoudiya, south of Baghdad, Iraq. Former US Army Pfc. Steve D. Green was charged Monday in federal court in Charlotte, North Carolina, with rape and four counts of murder. At least four other U.S. soldiers still in Iraq are under investigation in the attack. (AP Photo/Ali al-Mahmouri) border=\"0\" /></a>AP - U.S. investigators have asked Iraqi authorities to help them navigate cultural sensitivities to exhume the body of a teenager allegedly raped and murdered with her family by American soldiers, a military official said Saturday.</p><br clear=all>");
    expectedRSSItem3.setGuid("ap/20060709/iraq_rape_investigation");
    expectedRSSItem3.setPublishedDate("Sun, 09 Jul 2006 02:22:45 GMT");

    RSSItem expectedRSSItem4 = new RSSItem("Astronauts: Daring spacewalk method works \n" +
            "    (AP)", "http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_sc/space_shuttle", "<p><a href=\"http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20060709/ap_on_sc/space_shuttle\"><img src=\"http://us.news3.yimg.com/us.i2.yimg.com/p/ap/20060708/capt.d38cfd8b40774ebe9bb3c06b25ac41be.space_shuttle_txdc116.jpg?x=130&amp;y=97&amp;sig=1lrj6s3UxNaH.vQDoHFKEQ--\" align=\"left\" height=\"97\" width=\"130\" alt=\"In this image made from NASA TV, astronaut Piers Sellers, works on the end of the robotic arm during a spacewalk  Saturday, July 8, 2006.  Sellers is testing how different movements affect the robotic arm.  (AP Photo/NASA TV) border=\"0\" /></a>AP - A key test of a daring yet wobbly spacewalking technique that could be used someday to repair space shuttle heat shields worked well Saturday and got good reviews from two astronauts from the shuttle Discovery, NASA officials said.</p><br clear=all>");
    expectedRSSItem4.setGuid("ap/20060709/space_shuttle");
    expectedRSSItem4.setPublishedDate("Sun, 09 Jul 2006 03:13:06 GMT");

    List rssItems = new ArrayList();
    rssItems.add(expectedRSSItem1);
    rssItems.add(expectedRSSItem2);
    rssItems.add(expectedRSSItem3);
    rssItems.add(expectedRSSItem4);

    boolean item1Randomized = false, item2Randomized = false, item3Randomized = false, item4Randomized = false;
    for (int i = 0; i < (rssItems.size()* 5); i++) {
      RSSItem randomItem = (RSSItem) Randomizer.getRandomItem(rssItems);
      if (randomItem.getTitle().equals(expectedRSSItem1.getTitle())) {
        item1Randomized = true;
      } else if (randomItem.getTitle().equals(expectedRSSItem2.getTitle())) {
        item2Randomized = true;
      } else if (randomItem.getTitle().equals(expectedRSSItem3.getTitle())) {
        item3Randomized = true;
      } else if (randomItem.getTitle().equals(expectedRSSItem4.getTitle())) {
        item4Randomized = true;
      }
    }

    assertTrue(item1Randomized);
View Full Code Here

TOP

Related Classes of therandomhomepage.common.rss.RSSItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.