Java Code Examples for com.rometools.rome.feed.synd.SyndEntry#getModule()

The following examples show how to use com.rometools.rome.feed.synd.SyndEntry#getModule() . 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: 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 2
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 3
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 4
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 5
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 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: GoogleTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public static 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()));
    for (final Object element : feed.getEntries()) {
        final SyndEntry entry = (SyndEntry) element;
        final MediaEntryModule m = (MediaEntryModule) entry.getModule(MediaModule.URI);
        System.out.print(m);
    }
}
 
Example 8
Source File: ThreadingModuleTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testGenerate() throws IOException, FeedException {
    final SyndFeed feed = getSyndFeed("thr/threading-main.xml");
    List<SyndEntry> entries = feed.getEntries();

    // create a new "root" entry that the next entry will reference to
    SyndEntry newRootEntry = new SyndEntryImpl();
    newRootEntry.setTitle("New, 2nd root entry");
    newRootEntry.setUri("tag:example.org,2005:2");
    newRootEntry.setLink("http://www.example.org/entries/2");
    entries.add(newRootEntry);

    // create a new reply entry that will reference the new root entry
    SyndEntry newReplyEntry = new SyndEntryImpl();
    newReplyEntry.setTitle("New test reply entry");
    newReplyEntry.setUri("tag:example.org,2005:2,1");

    ThreadingModule threadingModule = new ThreadingModuleImpl();
    threadingModule.setRef("tag:example.org,2005:2");
    threadingModule.setType("application/xhtml+xml");
    threadingModule.setHref("http://www.example.org/entries/2");
    threadingModule.setSource("http://example.org/entries/2");

    newReplyEntry.getModules().add(threadingModule);
    entries.add(newReplyEntry);

    File outputFile = new File("target/threading-testGenerate.xml");
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, outputFile);

    // read back in and validate
    final SyndFeed generatedFeed = getSyndFeed(outputFile);
    SyndEntry generatedReplyEntry = generatedFeed.getEntries().get(3);
    assertNotNull(generatedReplyEntry);
    ThreadingModule generatedReplyThreadingModule = (ThreadingModule) generatedReplyEntry.getModule(ThreadingModule.URI);
    assertEquals("tag:example.org,2005:2", generatedReplyThreadingModule.getRef());
    assertEquals("application/xhtml+xml", generatedReplyThreadingModule.getType());
    assertEquals("http://www.example.org/entries/2", generatedReplyThreadingModule.getHref());
    assertEquals("http://example.org/entries/2", generatedReplyThreadingModule.getSource());
}
 
Example 9
Source File: MediaModuleTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testParseRestrictionWithoutType() throws FeedException, IOException  {
    final SyndFeed feed = getSyndFeed("org/rometools/feed/module/mediarss/issue-331.xml");
    final SyndEntry entry = feed.getEntries().get(0);
    final MediaEntryModule module = (MediaEntryModule) entry.getModule(MediaModule.URI);
    final Restriction[] restrictions = module.getMetadata().getRestrictions();
    
    assertThat(restrictions, is(notNullValue()));
}
 
Example 10
Source File: ITunesParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testDuration() throws Exception {
    SyndFeed feed = new SyndFeedInput().build(new XmlReader(getClass().getResource("duration.xml")));
    SyndEntry entry = feed.getEntries().get(0);
    EntryInformationImpl module = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);

    assertEquals(1000, module.getDuration().getMilliseconds());
}
 
Example 11
Source File: MediaModuleTest.java    From rome with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if file not found or not accessible
 */
public void testGoogleVideo() throws Exception {
    final SyndFeed feed = getSyndFeed("data/YouTube-MostPopular.rss");
    for (final Object element : feed.getEntries()) {
        final SyndEntry entry = (SyndEntry) element;
        final MediaEntryModule m = (MediaEntryModule) entry.getModule(MediaModule.URI);
        assertNotNull(m);
    }
}
 
Example 12
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testVehicle2Parse() 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/vehicles2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final Vehicle module = (Vehicle) 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[] { "car", "mini" }, module.getLabels());
    cal.set(2005, 2, 24);
    Assert.assertEquals("Currency", CurrencyEnumeration.USD, module.getCurrency());
    Assert.assertEquals("Price", 24000, module.getPrice().getValue(), 0);
    Assert.assertEquals("PriceType", PriceTypeEnumeration.STARTING, module.getPriceType());
    this.assertEquals("Payment Accepted", new PaymentTypeEnumeration[] { PaymentTypeEnumeration.CHECK, PaymentTypeEnumeration.VISA,
            PaymentTypeEnumeration.MASTERCARD }, module.getPaymentAccepted());
    Assert.assertEquals("Payment Notes", "financing available", module.getPaymentNotes());
    Assert.assertEquals("Vehicle Type", "car", module.getVehicleType());
    Assert.assertEquals("Make", "Mini", module.getMake());
    Assert.assertEquals("Model", "Cooper S", module.getModel());
    Assert.assertEquals("Year", "2006", module.getYear().toString());
    Assert.assertEquals("Mileage", new Integer(0), module.getMileage());
    this.assertEquals("Colors", new String[] { "red" }, module.getColors());
    Assert.assertEquals("Vin", "1M8GDM9AXKP042788", module.getVin());
    Assert.assertEquals("Location", "123 Main Street, Anytown, CA, 12345, USA", module.getLocation());

}
 
Example 13
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testService2Parse() throws Exception {
    LOG.debug("testService2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/services2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final Service module = (Service) 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[] { "Food delivery" }, module.getLabels());
    cal.set(2005, 2, 24);
    Assert.assertEquals("Currency", CurrencyEnumeration.USD, module.getCurrency());
    Assert.assertEquals("Price", 15, module.getPrice().getValue(), 0);
    Assert.assertEquals("PriceType", PriceTypeEnumeration.STARTING, module.getPriceType());
    this.assertEquals("Payment Accepted", new PaymentTypeEnumeration[] { PaymentTypeEnumeration.VISA, PaymentTypeEnumeration.MASTERCARD },
            module.getPaymentAccepted());
    Assert.assertEquals("Payment Notes", "minimum payment on credit cards:45", module.getPaymentNotes());
    Assert.assertEquals("Service Type", "delivery", module.getServiceType());
    Assert.assertEquals("Location", "Anytown, CA, USA", module.getLocation());
    Assert.assertEquals("DeliveryRad", 20, module.getDeliveryRadius().getValue(), 0);
    Assert.assertEquals("Delivery Notes", "will deliver between 9am -5pm", module.getDeliveryNotes());

}
 
Example 14
Source File: CCModuleGeneratorTest.java    From rome with Apache License 2.0 5 votes vote down vote up
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(testFiles[h].getName());
        final SyndFeed feed = input.build(testFiles[h]);
        // if( !feed.getFeedType().equals("rss_1.0"))
        {
            feed.setFeedType("rss_2.0");
            if (feed.getDescription() == null) {
                feed.setDescription("test file");
            }
            output.output(feed, new File("target/" + testFiles[h].getName()));
            final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName()));
            for (int i = 0; i < feed.getEntries().size(); i++) {
                // FIXME
                // final SyndEntry entry = feed.getEntries().get(i);
                final SyndEntry entry2 = feed2.getEntries().get(i);
                // / FIXME
                // final CreativeCommons base = (CreativeCommons)
                // entry.getModule(CreativeCommons.URI);
                final CreativeCommons base2 = (CreativeCommons) entry2.getModule(CreativeCommons.URI);
                LOG.debug("{}", base2);
                // FIXME
                // if( base != null)
                // this.assertEquals( testFiles[h].getName(), base.getLicenses(),
                // base2.getLicenses() );
            }
        }
    }

}
 
Example 15
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 16
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 5 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testJobs2Parse() throws Exception {
    LOG.debug("testJobs2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/jobs2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final Job module = (Job) 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[] { "Coordinator", "Google", "Online Support" }, module.getLabels());
    this.assertEquals("Industriy", new String[] { "Internet" }, module.getJobIndustries());
    Assert.assertEquals("Employer", "Google, Inc", module.getEmployer());
    this.assertEquals("Job Function", new String[] { "Google Coordinator" }, module.getJobFunctions());
    LOG.debug("{}", new Object[] { module.getJobTypes() });
    this.assertEquals("Job Type", new String[] { "full-time" }, module.getJobTypes());
    Assert.assertEquals("Currency", CurrencyEnumeration.USD, module.getCurrency());
    Assert.assertEquals("Salary", new Float(40000), module.getSalary());
    Assert.assertEquals("Salary Type", PriceTypeEnumeration.STARTING, module.getSalaryType());
    Assert.assertEquals("Education", "BS", module.getEducation());
    Assert.assertEquals("Immigration", "Permanent Resident", module.getImmigrationStatus());
    Assert.assertEquals("Location", "1600 Amphitheatre Parkway, Mountain View, CA, 94043, USA", module.getLocation());

}
 
Example 17
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 18
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 19
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 4 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testHousing2Parse() throws Exception {
    LOG.debug("testHousing2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/housing2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    SyndEntry entry = entries.get(0);
    Housing module = (Housing) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
    cal.set(2007, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Housing", "New House", "Sale" }, module.getLabels());
    Assert.assertEquals("Currency", CurrencyEnumeration.USD, module.getCurrency());
    Assert.assertEquals("Price", 350000, module.getPrice().getValue(), 0);
    Assert.assertEquals("PriceUnit", null, module.getPrice().getUnits());
    Assert.assertEquals("PriceType", PriceTypeEnumeration.STARTING, module.getPriceType());
    this.assertEquals("Payment Accepted", new PaymentTypeEnumeration[] { PaymentTypeEnumeration.CASH, PaymentTypeEnumeration.CHECK,
            PaymentTypeEnumeration.VISA }, module.getPaymentAccepted());
    Assert.assertEquals("Payment Notes", "1000 deposit", module.getPaymentNotes());
    Assert.assertEquals("Listing Type", new Boolean(true), module.getListingType());
    this.assertEquals("PropertyTypes", new String[] { "Townhouse" }, module.getPropertyTypes());
    Assert.assertEquals("Location", "123 Main St, Anytown, CA, 12345, USA", module.getLocation());
    Assert.assertEquals("Bedrooms", new Integer(3), module.getBedrooms());
    Assert.assertEquals("Bathrooms", new Float(3), module.getBathrooms());
    Assert.assertEquals("Area", 1300, module.getArea().getValue());
    Assert.assertEquals("Area Units", null, module.getArea().getUnits());
    Assert.assertEquals("School District", "Union School District", module.getSchoolDistrict());
    Assert.assertEquals("HOA Dues", new Float(120), module.getHoaDues());
    Assert.assertEquals("Year", "2005", module.getYear().toString());
    this.assertEquals("Agents", new String[] { "Sue Smith" }, module.getAgents());
    Assert.assertEquals("Tax Region", "California", module.getTaxRegion());
    Assert.assertEquals("Tax Percentage", new Float(8.25), module.getTaxPercent());

    entry = entries.get(1);
    module = (Housing) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image2.jpg", module.getImageLinks()[0].toString());
    cal.set(2008, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Housing", "rent", "lease" }, module.getLabels());
    Assert.assertEquals("Currency", CurrencyEnumeration.USD, module.getCurrency());
    Assert.assertEquals("Price", 1400, module.getPrice().getValue(), 0);
    Assert.assertEquals("PriceUnit", null, module.getPrice().getUnits());
    Assert.assertEquals("PriceType", PriceTypeEnumeration.STARTING, module.getPriceType());
    this.assertEquals("Payment Accepted", new PaymentTypeEnumeration[] { PaymentTypeEnumeration.CHECK }, module.getPaymentAccepted());
    Assert.assertEquals("Payment Notes", "1000 deposit", module.getPaymentNotes());
    Assert.assertEquals("Listing Type", new Boolean(false), module.getListingType());
    this.assertEquals("PropertyTypes", new String[] { "apartment" }, module.getPropertyTypes());
    Assert.assertEquals("Location", "123 Main St, Anytown, CA, 12345, USA", module.getLocation());
    Assert.assertEquals("Bedrooms", new Integer(2), module.getBedrooms());
    Assert.assertEquals("Bathrooms", new Float(2), module.getBathrooms());
    Assert.assertEquals("Area", 1100, module.getArea().getValue());
    Assert.assertEquals("Area Units", null, module.getArea().getUnits());
    Assert.assertEquals("School District", "Union School District", module.getSchoolDistrict());
    Assert.assertEquals("HOA Dues", null, module.getHoaDues());
    Assert.assertEquals("Year", "2004", module.getYear().toString());
    this.assertEquals("Agents", new String[] { "Sue Smith" }, module.getAgents());
    Assert.assertEquals("Tax Region", null, module.getTaxRegion());
    Assert.assertEquals("Tax Percentage", null, module.getTaxPercent());
}
 
Example 20
Source File: GoogleBaseParserTest.java    From rome with Apache License 2.0 4 votes vote down vote up
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testEvent2Parse() throws Exception {
    LOG.debug("testEvent2Parse");
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new File(super.getTestFile("xml/events2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    SyndEntry entry = entries.get(0);
    Event event = (Event) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", event.getImageLinks()[0].toString());
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    cal.set(2005, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), event.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Festival", "Halloween", "Party", "Costumes" }, event.getLabels());
    Assert.assertEquals("Currency", CurrencyEnumeration.USD, event.getCurrency());
    Assert.assertEquals("Price", 10, event.getPrice().getValue(), 0);
    Assert.assertEquals("PriceUnit", null, event.getPrice().getUnits());
    Assert.assertEquals("PriceType", PriceTypeEnumeration.STARTING, event.getPriceType());
    this.assertEquals("Payment Accepted", new PaymentTypeEnumeration[] { PaymentTypeEnumeration.CASH, PaymentTypeEnumeration.CHECK,
            PaymentTypeEnumeration.VISA }, event.getPaymentAccepted());
    Assert.assertEquals("Payment Notes", "Cash only for local orders", event.getPaymentNotes());
    /*
     * <g:event_date_range> <g:start>2005-07-04T20:00:00</g:start>
     * <g:end>2005-07-04T23:00:00</g:end> </g:event_date_range>
     */
    cal.set(2005, 06, 04, 20, 00, 00);
    Assert.assertEquals("Start Time", cal.getTime(), event.getEventDateRange().getStart());
    cal.set(2005, 06, 04, 23, 00, 00);
    Assert.assertEquals("End Time", cal.getTime(), event.getEventDateRange().getEnd());
    Assert.assertEquals("Location", "1600 Amphitheatre Parkway, Mountain View, CA, 94043", event.getLocation());
    Assert.assertEquals("Shipping Price", (float) 32.95, event.getShipping()[0].getPrice().getValue(), 0);
    // TODO: Determine what to do about the bogus services.
    Assert.assertEquals("Shipping Country", "US", event.getShipping()[0].getCountry());
    Assert.assertEquals("Tax Region", "California", event.getTaxRegion());
    Assert.assertEquals("Tax Percentage", new Float(8.25), event.getTaxPercent());

    entry = entries.get(1);
    event = (Event) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image2.jpg", event.getImageLinks()[0].toString());
    cal.setTimeInMillis(0);
    cal.set(2005, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), event.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Concert", "festival", "music" }, event.getLabels());
    Assert.assertEquals("Currency", CurrencyEnumeration.USD, event.getCurrency());
    Assert.assertEquals("Price", 50, event.getPrice().getValue(), 0);
    Assert.assertEquals("PriceUnit", null, event.getPrice().getUnits());
    Assert.assertEquals("PriceType", PriceTypeEnumeration.STARTING, event.getPriceType());
    this.assertEquals("Payment Accepted", new PaymentTypeEnumeration[] { PaymentTypeEnumeration.CASH, PaymentTypeEnumeration.CHECK,
            PaymentTypeEnumeration.VISA }, event.getPaymentAccepted());
    Assert.assertEquals("Payment Notes", "Cash only for local orders", event.getPaymentNotes());
    /*
     * <g:event_date_range> <g:start>2005-08-23T20:00:00</g:start>
     * <g:end>2005-08-23T23:00:00</g:end> </g:event_date_range>
     */
    cal.set(2005, 07, 23, 20, 00, 00);
    Assert.assertEquals("Start Time", cal.getTime(), event.getEventDateRange().getStart());
    cal.set(2005, 07, 23, 23, 00, 00);
    Assert.assertEquals("End Time", cal.getTime(), event.getEventDateRange().getEnd());
    Assert.assertEquals("Location", "123 Main St, Anytown, CA, 12345, USA", event.getLocation());
    Assert.assertEquals("Shipping Price", (float) 32.95, event.getShipping()[0].getPrice().getValue(), 0);
    // TODO: Determine what to do about the bogus services.
    Assert.assertEquals("Shipping Country", "US", event.getShipping()[0].getCountry());
    Assert.assertEquals("Tax Region", "California", event.getTaxRegion());
    Assert.assertEquals("Tax Percentage", new Float(8.25), event.getTaxPercent());

}