• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SyndFeedOutput类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.rometools.rome.io.SyndFeedOutput的典型用法代码示例。如果您正苦于以下问题:Java SyndFeedOutput类的具体用法?Java SyndFeedOutput怎么用?Java SyndFeedOutput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SyndFeedOutput类属于com.rometools.rome.io包,在下文中一共展示了SyndFeedOutput类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getStreamRssByUserName

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
@Override
public GetStreamRssByUserNameResponse getStreamRssByUserName(String userName) throws Exception {
  StreamingOutput rssOutput = outputStream -> {
    PageRequest pageable = new PageRequest(0, 30);

    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");

    feed.setTitle("PutPut RSS");
    feed.setLink("https://putput.org/api/stream/rss/"+userName);
    feed.setDescription("PutPut feed for @" + userName);

    feed.setEntries(rssEntries(userName, pageable));
    try {
      outputStream.write(new SyndFeedOutput().outputString(feed, true).getBytes("UTF-8"));
    } catch (FeedException e) {
      throw new RuntimeException(e);
    }
  };

  return GetStreamRssByUserNameResponse.withRssxmlOK(rssOutput);
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:23,代码来源:StreamResource.java


示例2: testGenerate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
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);
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:CustomTagGeneratorTest.java


示例3: testEndToEnd

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
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));
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:18,代码来源:OpenSearchModuleTest.java


示例4: xtestProduceAndReadGML

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * @throws Exception if file not found or not accessible
 */
public void xtestProduceAndReadGML() throws Exception {
    final SyndFeed feed = createFeed();
    final GeoRSSModule geoRSSModule = new GMLModuleImpl();
    final double latitude = 47.0;
    final double longitude = 9.0;
    final Position position = new Position();
    position.setLatitude(latitude);
    position.setLongitude(longitude);
    geoRSSModule.setPosition(position);

    final SyndEntry entry = feed.getEntries().get(0);
    entry.getModules().add(geoRSSModule);

    final SyndFeedOutput output = new SyndFeedOutput();

    final StringWriter stringWriter = new StringWriter();
    output.output(feed, stringWriter);

    final InputStream in = new ByteArrayInputStream(stringWriter.toString().getBytes("UTF8"));
    final Double[] lat = { latitude };
    final Double[] lng = { longitude };
    assertTestInputStream(in, lat, lng);
}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:GeoRSSModuleTest.java


示例5: testProduceAndReadSimple

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * @throws Exception if file not found or not accessible
 */
public void testProduceAndReadSimple() throws Exception {
    final SyndFeed feed = createFeed();
    final GeoRSSModule geoRSSModule = new SimpleModuleImpl();
    final double latitude = 47.0;
    final double longitude = 9.0;
    final Position position = new Position();
    position.setLatitude(latitude);
    position.setLongitude(longitude);
    geoRSSModule.setPosition(position);

    final SyndEntry entry = feed.getEntries().get(0);
    entry.getModules().add(geoRSSModule);

    final SyndFeedOutput output = new SyndFeedOutput();

    final StringWriter stringWriter = new StringWriter();
    output.output(feed, stringWriter);

    final InputStream in = new ByteArrayInputStream(stringWriter.toString().getBytes("UTF8"));
    final Double[] lat = { latitude };
    final Double[] lng = { longitude };
    assertTestInputStream(in, lat, lng);
}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:GeoRSSModuleTest.java


示例6: compareFeedFiles

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * @param expected original file
 * @param generated file for output
 * @throws IOException if file not found or not accessible
 * @throws FeedException when the feed can't be parsed
 */
private void compareFeedFiles(final File expected, final File generated) throws IOException, FeedException {
    final SyndFeed feed = getSyndFeed(expected);
    final List<SyndEntry> entries = feed.getEntries();
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, generated);
    final SyndFeed feed2 = getSyndFeed(generated);
    for (int i = 0; i < entries.size(); i++) {
        BufferedWriter b = new BufferedWriter(new FileWriter(generated.getAbsolutePath() + ".a.txt"));
        b.write("" + entries.get(i).getModule(MediaModule.URI));
        b.close();
        b = new BufferedWriter(new FileWriter(generated.getAbsolutePath() + ".b.txt"));
        b.write("" + feed2.getEntries().get(i).getModule(MediaModule.URI));
        b.close();
        assertEquals(entries.get(i).getModule(MediaModule.URI), feed2.getEntries().get(i).getModule(MediaModule.URI));
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:23,代码来源:MediaModuleTest.java


示例7: testCreate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
public void testCreate() throws Exception {

        final SyndFeed feed = new SyndFeedImpl();
        final String feedType = "rss_2.0";
        feed.setFeedType(feedType);
        feed.setLanguage("en-us");
        feed.setTitle("sales.com on the Radio!");
        feed.setDescription("sales.com radio shows in MP3 format");
        feed.setLink("http://foo/rss/podcasts.rss");

        final FeedInformation fi = new FeedInformationImpl();
        fi.setOwnerName("sales.com");
        fi.getCategories().add(new Category("Shopping"));
        fi.setOwnerEmailAddress("[email protected]");
        fi.setType("serial");
        feed.getModules().add(fi);

        final SyndFeedOutput output = new SyndFeedOutput();
        final StringWriter writer = new StringWriter();
        output.output(feed, writer);
        LOG.debug("{}", writer);

    }
 
开发者ID:rometools,项目名称:rome,代码行数:24,代码来源:ITunesGeneratorTest.java


示例8: testGenerate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * 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);

}
 
开发者ID:rometools,项目名称:rome,代码行数:19,代码来源:ContentModuleGeneratorTest.java


示例9: xtestParseGenerateV5

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
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);
}
 
开发者ID:rometools,项目名称:rome,代码行数:23,代码来源:SSEParserTest.java


示例10: testFile

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
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());
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:25,代码来源:ITunesGeneratorTest.java


示例11: testGenerate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * 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));
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:20,代码来源:GeneratorTest.java


示例12: testParse

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * @throws Exception if file not found or not accessible
 */
public void testParse() throws Exception {
    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 = getSyndFeed(files[j]);
        final List<SyndEntry> entries = feed.getEntries();
        final SyndFeedOutput output = new SyndFeedOutput();
        output.output(feed, 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("" + entries.get(i).getModule(MediaModule.URI));
            b.close();
            b = new BufferedWriter(new FileWriter("target/" + j + "b.txt"));
            b.write("" + feed2.getEntries().get(i).getModule(MediaModule.URI));
            b.close();
            assertEquals(entries.get(i).getModule(MediaModule.URI), feed2.getEntries().get(i).getModule(MediaModule.URI));
        }
    }
}
 
开发者ID:rometools,项目名称:rome-modules,代码行数:27,代码来源:MediaModuleTest.java


示例13: testCreate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
public void testCreate() throws Exception {

        final SyndFeed feed = new SyndFeedImpl();
        final String feedType = "rss_2.0";
        feed.setFeedType(feedType);
        feed.setLanguage("en-us");
        feed.setTitle("sales.com on the Radio!");
        feed.setDescription("sales.com radio shows in MP3 format");
        feed.setLink("http://foo/rss/podcasts.rss");

        final FeedInformation fi = new FeedInformationImpl();
        fi.setOwnerName("sales.com");
        fi.getCategories().add(new Category("Shopping"));
        fi.setOwnerEmailAddress("[email protected]");
        feed.getModules().add(fi);

        final SyndFeedOutput output = new SyndFeedOutput();
        final StringWriter writer = new StringWriter();
        output.output(feed, writer);
        LOG.debug("{}", writer);

    }
 
开发者ID:rometools,项目名称:rome-modules,代码行数:23,代码来源:ITunesGeneratorTest.java


示例14: doGet

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
@Override
protected void doGet () throws ServletException, IOException {
	super.doGet();

	Property generateRss = PropertyServiceProvider.provide()
			.getNamedProperty(PropertyHelper.GENERATE_RSS_FEED);

	if (PropertyHelper.isEmpty(generateRss)
			|| Boolean.valueOf(generateRss.value).booleanValue()) {

		HttpServletRequest request = REQUEST.get();
		HttpServletResponse response = RESPONSE.get();

		try {
			SyndFeed feed = getFeed(request);

			String feedType = request.getParameter(FEED_TYPE);
			feedType = (feedType != null) ? feedType : defaultFeedType;
			feed.setFeedType(feedType);

			response.setContentType(MIME_TYPE);
			SyndFeedOutput output = new SyndFeedOutput();
			output.output(feed, response.getWriter());
		} catch (FeedException ex) {
			response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
					"Could not generate feed");
		}
	}
}
 
开发者ID:billy1380,项目名称:blogwt,代码行数:30,代码来源:FeedServlet.java


示例15: writeRevisionsFeed

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
private void writeRevisionsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws IOException, FeedException, ServiceException, PublicInterfaceNotFoundException {
	long poid = Long.parseLong(request.getParameter("poid"));
	SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid);

	SyndFeed feed = new SyndFeedImpl();
	feed.setFeedType(FEED_TYPE);

	feed.setTitle("BIMserver.org revisions feed for project '" + sProject.getName() + "'");
	feed.setLink(request.getContextPath());
	feed.setDescription("This feed represents all the revisions of project '" + sProject.getName() + "'");

	List<SyndEntry> entries = new ArrayList<SyndEntry>();
	try {
		List<SRevision> allRevisionsOfProject = serviceMap.getServiceInterface().getAllRevisionsOfProject(poid);
		Collections.sort(allRevisionsOfProject, new SRevisionIdComparator(false));
		for (SRevision sVirtualRevision : allRevisionsOfProject) {
			SUser user = serviceMap.getServiceInterface().getUserByUoid(sVirtualRevision.getUserId());
			SyndEntry entry = new SyndEntryImpl();
			entry.setTitle("Revision " + sVirtualRevision.getOid());
			entry.setLink(request.getContextPath() + "/revision.jsp?poid=" + sVirtualRevision.getOid() + "&roid=" + sVirtualRevision.getOid());
			entry.setPublishedDate(sVirtualRevision.getDate());
			SyndContent description = new SyndContentImpl();
			description.setType("text/html");
			description.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Comment</td><td>" + sVirtualRevision.getComment()
					+ "</td></tr></table>");
			entry.setDescription(description);
			entries.add(entry);
		}
	} catch (ServiceException e) {
		LOGGER.error("", e);
	}
	feed.setEntries(entries);
	SyndFeedOutput output = new SyndFeedOutput();
	output.output(feed, response.getWriter());
}
 
开发者ID:opensourceBIM,项目名称:BIMserver,代码行数:36,代码来源:SyndicationServlet.java


示例16: writeCheckoutsFeed

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
private void writeCheckoutsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws ServiceException, IOException, FeedException, PublicInterfaceNotFoundException {
	long poid = Long.parseLong(request.getParameter("poid"));
	SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid);

	SyndFeed feed = new SyndFeedImpl();
	feed.setFeedType(FEED_TYPE);

	feed.setTitle("BIMserver.org checkouts feed for project '" + sProject.getName() + "'");
	feed.setLink(request.getContextPath());
	feed.setDescription("This feed represents all the checkouts of project '" + sProject.getName() + "'");

	List<SyndEntry> entries = new ArrayList<SyndEntry>();
	try {
		List<SCheckout> allCheckoutsOfProject = serviceMap.getServiceInterface().getAllCheckoutsOfProjectAndSubProjects(poid);
		for (SCheckout sCheckout : allCheckoutsOfProject) {
			SRevision revision = serviceMap.getServiceInterface().getRevision(sCheckout.getRevision().getOid());
			SProject project = serviceMap.getServiceInterface().getProjectByPoid(sCheckout.getProjectId());
			SUser user = serviceMap.getServiceInterface().getUserByUoid(sCheckout.getUserId());
			SyndEntry entry = new SyndEntryImpl();
			entry.setTitle("Checkout on " + project.getName() + ", revision " + revision.getId());
			entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid());
			entry.setPublishedDate(sCheckout.getDate());
			SyndContent description = new SyndContentImpl();
			description.setType("text/plain");
			description
					.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Revision</td><td>" + sCheckout.getRevision().getOid() + "</td></tr></table>");
			entry.setDescription(description);
			entries.add(entry);
		}
	} catch (UserException e) {
		LOGGER.error("", e);
	}
	feed.setEntries(entries);
	SyndFeedOutput output = new SyndFeedOutput();
	output.output(feed, response.getWriter());
}
 
开发者ID:opensourceBIM,项目名称:BIMserver,代码行数:37,代码来源:SyndicationServlet.java


示例17: initializeForSorting

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * This method will take a SyndFeed object with a SimpleListExtension on it and populate the
 * entries with current SleEntry values for sorting and grouping. <b>NB</b>: This basically does
 * this by re-generating the XML for all the entries then re-parsing them into the SLE data
 * structures. It is a very heavy operation and should not be called frequently!
 */
public static void initializeForSorting(final SyndFeed feed) throws FeedException {
    // TODO: the null parameter below will break delegating parsers and generators
    // final ModuleGenerators g = new ModuleGenerators(feed.getFeedType() +
    // ITEM_MODULE_GENERATORS_POSFIX_KEY, null);
    final SyndFeedOutput output = new SyndFeedOutput();
    final Document document = output.outputJDom(feed);
    final SyndFeed copy = new SyndFeedInput().build(document);
    feed.copyFrom(copy);
}
 
开发者ID:rometools,项目名称:rome,代码行数:16,代码来源:SleUtility.java


示例18: testGenerate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * Test of generate method, of class com.totsp.xml.syndication.base.io.GoogleBaseGenerator.
 */
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]);
        try {
            output.output(feed, new File("target/" + testFiles[h].getName()));
        } catch (final Exception e) {
            throw new RuntimeException(testFiles[h].getAbsolutePath(), e);
        }
        final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName()));
        for (int i = 0; i < feed.getEntries().size(); i++) {
            final SyndEntry entry = feed.getEntries().get(i);
            final SyndEntry entry2 = feed2.getEntries().get(i);
            final GoogleBase base = (GoogleBase) entry.getModule(GoogleBase.URI);
            final GoogleBase base2 = (GoogleBase) entry2.getModule(GoogleBase.URI);
            Assert.assertEquals(testFiles[h].getName(), base, base2);
        }
    }

}
 
开发者ID:rometools,项目名称:rome,代码行数:32,代码来源:GoogleBaseGeneratorTest.java


示例19: testFile

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
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(feed.getAbsolutePath() + ".output");
    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));
        LOG.debug(entry.getModule(AbstractITunesObject.URI).toString());
        LOG.debug("-----------------------------------------");
        LOG.debug(check.getModule(AbstractITunesObject.URI).toString());
        assertEquals("Entry Level: ", entry.getModule(AbstractITunesObject.URI).toString(), check.getModule(AbstractITunesObject.URI).toString());
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:28,代码来源:ITunesGeneratorTest.java


示例20: testGenerate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
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());
}
 
开发者ID:rometools,项目名称:rome,代码行数:40,代码来源:ThreadingModuleTest.java



注:本文中的com.rometools.rome.io.SyndFeedOutput类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FakeTicker类代码示例发布时间:2022-05-22
下一篇:
Java SecurityManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap