com.rometools.rome.io.SyndFeedInput Java Examples

The following examples show how to use com.rometools.rome.io.SyndFeedInput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of generate method, of class com.rometools.rome.feed.module.photocast.io.Generator.
 */
public void testGenerate() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new File(super.getTestFile("index.rss")));
    final List<SyndEntry> entries = feed.getEntries();
    for (int i = 0; i < entries.size(); i++) {
        LOG.debug("{}", entries.get(i).getModule(PhotocastModule.URI));
    }
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, new File("target/index.rss"));
    final SyndFeed feed2 = input.build(new File("target/index.rss"));
    final List<SyndEntry> entries2 = feed2.getEntries();
    for (int i = 0; i < entries.size(); i++) {
        assertEquals("Module test", entries.get(i).getModule(PhotocastModule.URI), entries2.get(i).getModule(PhotocastModule.URI));
    }
}
 
Example #2
Source File: GeoRSSModuleTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * test expected latitude and longitude values in items of test file.
 *
 * @param in testfeed
 * @param expectedLat expected latitude values
 * @param expectedLng expected longitude values
 * @throws Exception if file not found or not accessible
 */
private void assertTestInputStream(final InputStream in, final Double[] expectedLat, final Double[] expectedLng) throws Exception {
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new XmlReader(in));

    final List<SyndEntry> entries = feed.getEntries();
    for (int i = 0; i < entries.size(); i++) {
        final SyndEntry entry = entries.get(i);
        final GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);
        final Position position = geoRSSModule.getPosition();
        if (expectedLat[i] == null || expectedLng[i] == null) {
            assertNull("position " + i, position);
        } else {
            assertEquals("lat " + i, expectedLat[i], position.getLatitude(), DELTA);
            assertEquals("lng " + i, expectedLng[i], position.getLongitude(), DELTA);
        }
    }
}
 
Example #3
Source File: OpenSearchModuleTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testEndToEnd() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();
    final File test = new File(super.getTestFile("os"));
    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]);
        final Module m = feed.getModule(OpenSearchModule.URI);
        final SyndFeedOutput output = new SyndFeedOutput();
        final File outfile = new File("target/" + files[j].getName());
        output.output(feed, outfile);
        final SyndFeed feed2 = input.build(outfile);
        assertEquals(m, feed2.getModule(OpenSearchModule.URI));
    }
}
 
Example #4
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testWanted2Parse() throws Exception {
    LOG.debug("testVehicle2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/wanted2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final Wanted module = (Wanted) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
    cal.set(2005, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Wanted", "Truck" }, module.getLabels());
    Assert.assertEquals("Location", "123 Main Street, Anytown, CA, 12345, USA", module.getLocation());
}
 
Example #5
Source File: ITunesGeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testImage() throws Exception {
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    feed.setTitle("title");
    feed.setDescription("description");
    feed.setLink("https://example.org");

    FeedInformation itunesFeed = new FeedInformationImpl();
    itunesFeed.setImage(new URL("https://example.org/test.png"));
    feed.getModules().add(itunesFeed);

    String xml = new SyndFeedOutput().outputString(feed);

    AbstractITunesObject parsedItunesFeed =
            (AbstractITunesObject) new SyndFeedInput()
                    .build(new XmlReader(new ByteArrayInputStream(xml.getBytes("UTF-8"))))
                    .getModule(AbstractITunesObject.URI);
    assertEquals(new URL("https://example.org/test.png"), parsedItunesFeed.getImage());
    assertEquals(new java.net.URI("https://example.org/test.png"),
            parsedItunesFeed.getImageUri());
}
 
Example #6
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testReview2Parse() throws Exception {
    LOG.debug("testReview2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/reviews2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final Review module = (Review) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
    cal.set(2005, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Review", "Earth", "Google" }, module.getLabels());
    cal.set(2005, 2, 24);
    Assert.assertEquals("PubDate", cal.getTime(), module.getPublishDate());
    this.assertEquals("Authors", new String[] { "Jimmy Smith" }, module.getAuthors());
    Assert.assertEquals("Name of Item Rev", "Google Earth", module.getNameOfItemBeingReviewed());
    Assert.assertEquals("Type", "Product", module.getReviewType());
    Assert.assertEquals("Rever Type", "editorial", module.getReviewerType());
    Assert.assertEquals("Rating", new Float(5), module.getRating());
    Assert.assertEquals("URL of Item", new URL("http://earth.google.com/"), module.getUrlOfItemBeingReviewed());

}
 
Example #7
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testResearch2Parse() throws Exception {
    LOG.debug("testResearch2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/research2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final ScholarlyArticle module = (ScholarlyArticle) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
    cal.set(2005, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Economy", "Tsunami" }, module.getLabels());
    cal.set(2005, 1, 25);
    Assert.assertEquals("PubDate", cal.getTime(), module.getPublishDate());
    this.assertEquals("Authors", new String[] { "James Smith" }, module.getAuthors());
    Assert.assertEquals("Pub Name", "Tsunami and the Economy", module.getPublicationName());
    Assert.assertEquals("Pub Vol", "III", module.getPublicationVolume());
    Assert.assertEquals("Pages", new Integer(5), module.getPages());
}
 
Example #8
Source File: ITunesGeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testImageUri() throws Exception {
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    feed.setTitle("title");
    feed.setDescription("description");
    feed.setLink("https://example.org");

    FeedInformation itunesFeed = new FeedInformationImpl();
    itunesFeed.setImageUri(new java.net.URI("https://example.org/test.png"));
    feed.getModules().add(itunesFeed);

    String xml = new SyndFeedOutput().outputString(feed);

    AbstractITunesObject parsedItunesFeed =
            (AbstractITunesObject) new SyndFeedInput()
                    .build(new XmlReader(new ByteArrayInputStream(xml.getBytes("UTF-8"))))
                    .getModule(AbstractITunesObject.URI);
    assertEquals(new java.net.URI("https://example.org/test.png"),
            parsedItunesFeed.getImageUri());
    assertEquals(new URL("https://example.org/test.png"),
            parsedItunesFeed.getImage());
}
 
Example #9
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testPersona2Parse() throws Exception {
    LOG.debug("testPerson2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/personals2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final Person module = (Person) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
    cal.set(2005, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Personals", "m4w" }, module.getLabels());
    this.assertEquals("Ethnicity", new String[] { "South Asian" }, module.getEthnicities());
    Assert.assertEquals("Gender", GenderEnumeration.MALE, module.getGender());
    Assert.assertEquals("Sexual Orientation", "straight", module.getSexualOrientation());
    this.assertEquals("Interested In", new String[] { "Single Women" }, module.getInterestedIn());
    Assert.assertEquals("Marital Status", "single", module.getMaritalStatus());
    Assert.assertEquals("Occupation", "Sales", module.getOccupation());
    Assert.assertEquals("Employer", "Google, Inc.", module.getEmployer());
    Assert.assertEquals("Age", new Integer(23), module.getAge());
    Assert.assertEquals("Location", "Anytown, 12345, USA", module.getLocation());

}
 
Example #10
Source File: ITunesGeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testImageTakesPrecedenceOverImageUri() throws Exception {
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    feed.setTitle("title");
    feed.setDescription("description");
    feed.setLink("https://example.org");

    FeedInformation itunesFeed = new FeedInformationImpl();
    itunesFeed.setImage(new URL("https://example.org/test1.png"));
    itunesFeed.setImageUri(new java.net.URI("https://example.org/test2.png"));
    feed.getModules().add(itunesFeed);

    String xml = new SyndFeedOutput().outputString(feed);

    AbstractITunesObject parsedItunesFeed =
            (AbstractITunesObject) new SyndFeedInput()
                    .build(new XmlReader(new ByteArrayInputStream(xml.getBytes("UTF-8"))))
                    .getModule(AbstractITunesObject.URI);
    assertEquals(new URL("https://example.org/test1.png"), parsedItunesFeed.getImage());
    assertEquals(new java.net.URI("https://example.org/test1.png"),
            parsedItunesFeed.getImageUri());
}
 
Example #11
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testNews2Parse() throws Exception {
    LOG.debug("testNews2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/news2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final Article module = (Article) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
    cal.set(2007, 2, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "news", "old" }, module.getLabels());
    Assert.assertEquals("Source", "Journal", module.getNewsSource());
    cal.set(1961, 3, 12, 0, 0, 0);
    Assert.assertEquals("Pub Date", cal.getTime(), module.getPublishDate());
    this.assertEquals("Authors", new String[] { "James Smith" }, module.getAuthors());
    Assert.assertEquals("Pages", new Integer(1), module.getPages());

}
 
Example #12
Source File: ContentModuleParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of parse method, of class com.rometools.rome.feed.module.content.ContentModuleParser.
 * It will test through the whole ROME framework.
 */
public void testParse() throws Exception {

    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("xml/test-rdf.xml")).toURI().toURL()));
    final SyndEntry entry = feed.getEntries().get(0);
    final ContentModule module = (ContentModule) entry.getModule(ContentModule.URI);
    final List<ContentItem> items = module.getContentItems();

    for (int i = 0; i < items.size(); i++) {
        // FIXME
        // final ContentItem item = ContentModuleImplTest.contentItems.get(i);
        // assertEquals (item , items.get(i));
    }

}
 
Example #13
Source File: ContentModuleGeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of generate method, of class com.totsp.xml.syndication.content.ContentModuleGenerator.
 */
public void testGenerate() throws Exception {

    LOG.debug("testGenerate");

    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("xml/test-rdf.xml")).toURI().toURL()));
    final SyndEntry entry = feed.getEntries().get(0);
    entry.getModule(ContentModule.URI);
    final SyndFeedOutput output = new SyndFeedOutput();
    final StringWriter writer = new StringWriter();
    output.output(feed, writer);

    LOG.debug("{}", writer);

}
 
Example #14
Source File: ITunesParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of parse method, of class com.rometools.modules.itunes.io.ITunesParser.
 */
public void testParseItem() throws Exception {
    File feed = new File(getTestFile("xml/leshow.xml"));
    final SyndFeedInput input = new SyndFeedInput();
    SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));

    SyndEntry entry = syndfeed.getEntries().get(0);

    EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
    assertEquals(true, entryInfo.getClosedCaptioned());
    assertEquals(Integer.valueOf(2), entryInfo.getOrder());
    assertEquals("http://example.org/image.png", entryInfo.getImage().toString());
    assertFalse(entryInfo.getExplicit());
    assertEquals("test-itunes-title", entryInfo.getTitle());

    SyndEntry entry1 = syndfeed.getEntries().get(1);
    EntryInformationImpl entryInfo1 = (EntryInformationImpl) entry1.getModule(AbstractITunesObject.URI);
    assertTrue(entryInfo1.getExplicit());

    SyndEntry entry2 = syndfeed.getEntries().get(2);
    EntryInformationImpl entryInfo2 = (EntryInformationImpl) entry2.getModule(AbstractITunesObject.URI);
    assertFalse(entryInfo2.getExplicit());
    assertNull(entryInfo2.getExplicitNullable());
}
 
Example #15
Source File: PodloveSimpleChapterGeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testGenerateAtom() throws Exception {

        log.debug("testGenerateAtom");

        final SyndFeedInput input = new SyndFeedInput();
        final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("psc/atom.xml")).toURI().toURL()));
        final SyndEntry entry = feed.getEntries().get(0);
        entry.getModule(PodloveSimpleChapterModule.URI);
        final SyndFeedOutput output = new SyndFeedOutput();
        final StringWriter writer = new StringWriter();
        output.output(feed, writer);

        final String xml = writer.toString();
        log.debug("{}", writer);

        assertTrue(xml.contains("xmlns:psc=\"http://podlove.org/simple-chapters\""));
        assertTrue(xml.contains("<psc:chapters version=\"1.2\">"));
        assertTrue(xml.contains("<psc:chapter start=\"00:00:00.000\" title=\"Lorem Ipsum\" href=\"http://example.org\" image=\"http://example.org/cover\" />"));
    }
 
Example #16
Source File: ModuleParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void atestParse() throws Exception {

        final SyndFeedInput input = new SyndFeedInput();
        final File testDir = new File(super.getTestFile("test/xml"));
        final File[] testFiles = testDir.listFiles();
        for (int h = 0; h < testFiles.length; h++) {
            if (!testFiles[h].getName().endsWith(".xml")) {
                continue;
            }
            LOG.debug(testFiles[h].getName());
            final SyndFeed feed = input.build(testFiles[h]);
            final List<SyndEntry> entries = feed.getEntries();
            final CreativeCommons fMod = (CreativeCommons) feed.getModule(CreativeCommons.URI);
            LOG.debug("{}", fMod);
            for (int i = 0; i < entries.size(); i++) {
                final SyndEntry entry = entries.get(i);
                final CreativeCommons eMod = (CreativeCommons) entry.getModule(CreativeCommons.URI);
                LOG.debug("\nEntry:");
                LOG.debug("{}", eMod);
            }
        }
    }
 
Example #17
Source File: SSEParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void xtestParseGenerateV5() throws Exception {
    final URL feedURL = new File(getTestFile("xml/v/v5.xml")).toURI().toURL();
    // parse the document for comparison
    final SAXBuilder builder = new SAXBuilder();
    final Document directlyBuilt = builder.build(feedURL);

    // generate the feed back into a document
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed inputFeed = input.build(new XmlReader(feedURL));

    final SyndFeedOutput output = new SyndFeedOutput();
    final Document parsedAndGenerated = output.outputJDom(inputFeed);

    // XMLOutputter outputter = new XMLOutputter();
    // outputter.setFormat(Format.getPrettyFormat());
    // outputter.output(directlyBuilt, new
    // FileOutputStream("c:\\cygwin\\tmp\\sync-direct.xml"));
    // outputter.output(parsedAndGenerated, new
    // FileOutputStream("c:\\cygwin\\tmp\\sync-pg.xml"));

    assertDocumentsEqual(directlyBuilt, parsedAndGenerated);
}
 
Example #18
Source File: ITunesGeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
private void testFile(final String filename) throws Exception {
    final File feed = new File(getTestFile(filename));
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));

    final SyndFeedOutput output = new SyndFeedOutput();
    final File outfeed = new File("target/" + feed.getName());
    output.output(syndfeed, outfeed);

    final SyndFeed syndCheck = input.build(new XmlReader(outfeed.toURI().toURL()));
    LOG.debug(syndCheck.getModule(AbstractITunesObject.URI).toString());
    assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString());

    final List<SyndEntry> syndEntries = syndfeed.getEntries();
    final List<SyndEntry> syndChecks = syndCheck.getEntries();

    for (int i = 0; i < syndEntries.size(); i++) {
        final SyndEntry entry = syndEntries.get(i);
        final SyndEntry check = syndChecks.get(i);
        LOG.debug("Original: {}", entry.getModule(AbstractITunesObject.URI));
        LOG.debug("Check:    {}", check.getModule(AbstractITunesObject.URI));
        assertEquals("Entry Level: ", entry.getModule(AbstractITunesObject.URI).toString(), check.getModule(AbstractITunesObject.URI).toString());
    }
}
 
Example #19
Source File: CustomTagGeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testGenerate() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new File(super.getTestFile("xml/custom-tags-example.xml")));
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, new File("target/custom-tags-example.xml"));
    final SyndFeed feed2 = input.build(new File("target/custom-tags-example.xml"));

    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI);

    final List<SyndEntry> entries2 = feed2.getEntries();
    final SyndEntry entry2 = entries2.get(0);
    final CustomTags customTags2 = (CustomTags) entry2.getModule(CustomTags.URI);

    final Iterator<CustomTag> it = customTags.getValues().iterator();
    final Iterator<CustomTag> it2 = customTags2.getValues().iterator();
    while (it.hasNext()) {
        final CustomTag tag = it.next();
        final CustomTag tag2 = it2.next();
        LOG.debug("tag1: {}", tag);
        LOG.debug("tag2: {}", tag2);
        Assert.assertEquals(tag, tag2);
    }
}
 
Example #20
Source File: ModuleParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Test of parse method, of class com.rometools.rome.feed.module.sle.io.ModuleParser.
 */
public void testParse() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed feed = input.build(new File(super.getTestFile("data/bookexample.xml")));
    final SimpleListExtension sle = (SimpleListExtension) feed.getModule(SimpleListExtension.URI);

    assertEquals("list", sle.getTreatAs());
    final Group[] groups = sle.getGroupFields();
    assertEquals("genre", groups[0].getElement());
    assertEquals("Genre", groups[0].getLabel());
    final Sort[] sorts = sle.getSortFields();
    assertEquals("Relevance", sorts[0].getLabel());
    assertTrue(sorts[0].getDefaultOrder());
    assertEquals(sorts[1].getNamespace(), Namespace.getNamespace("http://www.example.com/book"));
    assertEquals(sorts[1].getDataType(), Sort.DATE_TYPE);
    assertEquals(sorts[1].getElement(), "firstedition");
    final SyndEntry entry = feed.getEntries().get(0);
    final SleEntry sleEntry = (SleEntry) entry.getModule(SleEntry.URI);
    LOG.debug("{}", sleEntry);
    LOG.debug("getGroupByElement");
    LOG.debug("{}", sleEntry.getGroupByElement(groups[0]));
    LOG.debug("getSortByElement");
    LOG.debug("{}", sleEntry.getSortByElement(sorts[0]));
}
 
Example #21
Source File: PodloveSimpleChapterParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testParseRss() throws Exception {

        log.debug("testParseRss");

        final SyndFeedInput input = new SyndFeedInput();
        final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("psc/rss.xml")).toURI().toURL()));
        final SyndEntry entry = feed.getEntries().get(0);
        final PodloveSimpleChapterModule simpleChapters = (PodloveSimpleChapterModule) entry.getModule(PodloveSimpleChapterModule.URI);

        assertNotNull(simpleChapters);
        for (SimpleChapter c : simpleChapters.getChapters()) {
            assertEquals("00:00:00.000", c.getStart());
            assertEquals("Lorem Ipsum", c.getTitle());
            assertEquals("http://example.org", c.getHref());
            assertEquals("http://example.org/cover", c.getImage());
        }
    }
 
Example #22
Source File: PodloveSimpleChapterParserTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testParseAtom() throws Exception {

        log.debug("testParseAtom");

        final SyndFeedInput input = new SyndFeedInput();
        final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("psc/atom.xml")).toURI().toURL()));
        final SyndEntry entry = feed.getEntries().get(0);
        final PodloveSimpleChapterModule simpleChapters = (PodloveSimpleChapterModule) entry.getModule(PodloveSimpleChapterModule.URI);

        assertNotNull(simpleChapters);
        for (SimpleChapter c : simpleChapters.getChapters()) {
            assertEquals("00:00:00.000", c.getStart());
            assertEquals("Lorem Ipsum", c.getTitle());
            assertEquals("http://example.org", c.getHref());
            assertEquals("http://example.org/cover", c.getImage());
        }
    }
 
Example #23
Source File: PodloveSimpleChapterGeneratorTest.java    From rome with Apache License 2.0 6 votes vote down vote up
public void testGenerateRss() throws Exception {

        log.debug("testGenerateRss");

        final SyndFeedInput input = new SyndFeedInput();
        final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("psc/rss.xml")).toURI().toURL()));
        final SyndEntry entry = feed.getEntries().get(0);
        entry.getModule(PodloveSimpleChapterModule.URI);
        final SyndFeedOutput output = new SyndFeedOutput();
        final StringWriter writer = new StringWriter();
        output.output(feed, writer);

        final String xml = writer.toString();
        log.debug("{}", writer);

        assertTrue(xml.contains("xmlns:psc=\"http://podlove.org/simple-chapters\""));
        assertTrue(xml.contains("<psc:chapters version=\"1.2\">"));
        assertTrue(xml.contains("<psc:chapter start=\"00:00:00.000\" title=\"Lorem Ipsum\" href=\"http://example.org\" image=\"http://example.org/cover\" />"));
    }
 
Example #24
Source File: CsdbReleasesSD2IEC.java    From petscii-bbs with Mozilla Public License 2.0 5 votes vote down vote up
private static List<NewsFeed> getFeeds(String urlString) throws IOException, FeedException {
    URL url = new URL(urlString);
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = input.build(new XmlReader(url));
    List<CsdbReleasesSD2IEC.NewsFeed> result = new LinkedList<>();
    List<SyndEntry> entries = feed.getEntries();
    for (SyndEntry e : entries)
        result.add(new CsdbReleasesSD2IEC.NewsFeed(
                e.getPublishedDate(),
                e.getTitle().replaceAll("(?is) by .*?$", EMPTY),
                e.getDescription().getValue(),
                e.getUri()));
    return result;
}
 
Example #25
Source File: WeatherGeneratorTest.java    From rome with Apache License 2.0 5 votes vote down vote up
/**
 * Test of generate method, of class com.totsp.xml.syndication.base.io.SlashGenerator.
 *
 * @throws Exception on error
 */
public void testGenerate() throws Exception {
    LOG.debug("testGenerate");
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeedOutput output = new SyndFeedOutput();
    final File testDir = new File(super.getTestFile("xml"));
    final File[] testFiles = testDir.listFiles();
    for (int h = 0; h < testFiles.length; h++) {
        if (!testFiles[h].getName().endsWith(".xml")) {
            continue;
        }
        LOG.debug("processing" + testFiles[h]);
        final SyndFeed feed = input.build(testFiles[h]);
        output.output(feed, new File("target/" + testFiles[h].getName()));
        final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName()));
        final YWeatherModule weather = (YWeatherModule) feed.getModule(YWeatherModule.URI);
        final YWeatherModule weather2 = (YWeatherModule) feed2.getModule(YWeatherModule.URI);
        Assert.assertEquals(testFiles[h].getName(), weather, weather2);
        for (int i = 0; i < feed.getEntries().size(); i++) {
            final SyndEntry entry = feed.getEntries().get(i);
            final SyndEntry entry2 = feed2.getEntries().get(i);
            final YWeatherModule weatherEntry = (YWeatherModule) entry.getModule(YWeatherModule.URI);
            final YWeatherModule weatherEntry2 = (YWeatherModule) entry2.getModule(YWeatherModule.URI);
            assertEquals(testFiles[h].getName(), weatherEntry, weatherEntry2);
        }
    }

}
 
Example #26
Source File: ITunesParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testDurationEmpty() throws Exception {
    SyndFeed feed = new SyndFeedInput().build(new XmlReader(getClass().getResource("duration-empty.xml")));
    SyndEntry entry = feed.getEntries().get(0);
    EntryInformationImpl module = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);

    assertNull(module.getDuration());
}
 
Example #27
Source File: ITunesParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testParseNonHttpUris() throws Exception {
    File feed = new File(getTestFile("itunes/no-http-uris.xml"));
    final SyndFeedInput input = new SyndFeedInput();
    SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));

    final FeedInformationImpl feedInfo = (FeedInformationImpl) syndfeed.getModule(AbstractITunesObject.URI);

    assertEquals(URI.create("file://some-location/1.jpg"), feedInfo.getImageUri());

    SyndEntry entry = syndfeed.getEntries().get(0);
    EntryInformationImpl module = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);

    assertEquals(URI.create("gs://some-location/2.jpg"), module.getImageUri());
}
 
Example #28
Source File: ITunesParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testExplicitnessFalse() throws Exception {
    ArrayList<String> xmlFiles = new ArrayList<String>();
    xmlFiles.add("explicitness-no.xml");
    xmlFiles.add("explicitness-clean.xml");

    for (String xml : xmlFiles) {
        SyndFeed feed = new SyndFeedInput().build(new XmlReader(getClass().getResource(xml)));
        FeedInformationImpl module = (FeedInformationImpl) feed.getModule(AbstractITunesObject.URI);

        assertFalse(module.getExplicitNullable());
    }
}
 
Example #29
Source File: ITunesParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testDurationBad() throws Exception {
    SyndFeed feed = new SyndFeedInput().build(new XmlReader(getClass().getResource("duration-bad.xml")));
    SyndEntry entry = feed.getEntries().get(0);
    EntryInformationImpl module = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);

    assertNull(module.getDuration());
}
 
Example #30
Source File: ITunesParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testExplicitnessTrue() throws Exception {
    ArrayList<String> xmlFiles = new ArrayList<String>();
    xmlFiles.add("explicitness-capital-yes.xml");
    xmlFiles.add("explicitness-yes.xml");

    for (String xml : xmlFiles) {
        SyndFeed feed = new SyndFeedInput().build(new XmlReader(getClass().getResource(xml)));
        FeedInformationImpl module = (FeedInformationImpl) feed.getModule(AbstractITunesObject.URI);

        assertTrue(module.getExplicitNullable());
    }
}