public void testTitle() throws Exception { Feed feed = (Feed) getWireFeed(); assertEquals("1", feed.getId()); assertEquals("xxx1", feed.getOtherLinks().get(0).getRel()); assertEquals("xxx2", feed.getOtherLinks().get(1).getRel()); assertEquals("xxx11", feed.getOtherLinks().get(0).getType()); assertEquals("xxx22", feed.getOtherLinks().get(1).getType()); assertEquals("http://foo.com/1", feed.getOtherLinks().get(0).getHref()); assertEquals("http://foo.com/2", feed.getOtherLinks().get(1).getHref()); }
@SuppressWarnings("unchecked") private void addLink(Feed feed, String url, String rel) { Link link = new Link(); link.setHref(url); link.setRel(rel); feed.getOtherLinks().add(link); }
protected void populateFeedHeader(Feed feed, Element eFeed) throws FeedException { if (feed.getTitleEx() != null) { Element titleElement = new Element("title", getFeedNamespace()); fillContentElement(titleElement, feed.getTitleEx()); eFeed.addContent(titleElement); } List links = feed.getAlternateLinks(); if (links != null) for (int i = 0; i < links.size(); i++) { eFeed.addContent(generateLinkElement((Link) links.get(i))); } links = feed.getOtherLinks(); if (links != null) for (int j = 0; j < links.size(); j++) { eFeed.addContent(generateLinkElement((Link) links.get(j))); } List cats = feed.getCategories(); if (cats != null) for (Iterator iter = cats.iterator(); iter.hasNext(); ) { eFeed.addContent(generateCategoryElement((Category) iter.next())); } List authors = feed.getAuthors(); if (authors != null && authors.size() > 0) { for (int i = 0; i < authors.size(); i++) { Element authorElement = new Element("author", getFeedNamespace()); fillPersonElement(authorElement, (Person) feed.getAuthors().get(i)); eFeed.addContent(authorElement); } } List contributors = feed.getContributors(); if (contributors != null && contributors.size() > 0) { for (int i = 0; i < contributors.size(); i++) { Element contributorElement = new Element("contributor", getFeedNamespace()); fillPersonElement(contributorElement, (Person) contributors.get(i)); eFeed.addContent(contributorElement); } } if (feed.getSubtitle() != null) { Element subtitleElement = new Element("subtitle", getFeedNamespace()); fillContentElement(subtitleElement, feed.getSubtitle()); eFeed.addContent(subtitleElement); } if (feed.getId() != null) { eFeed.addContent(generateSimpleElement("id", feed.getId())); } if (feed.getGenerator() != null) { eFeed.addContent(generateGeneratorElement(feed.getGenerator())); } if (feed.getRights() != null) { eFeed.addContent(generateSimpleElement("rights", feed.getRights())); } if (feed.getIcon() != null) { eFeed.addContent(generateSimpleElement("icon", feed.getIcon())); } if (feed.getLogo() != null) { eFeed.addContent(generateSimpleElement("logo", feed.getLogo())); } if (feed.getUpdated() != null) { Element updatedElement = new Element("updated", getFeedNamespace()); updatedElement.addContent(DateParser.formatW3CDateTime(feed.getUpdated())); eFeed.addContent(updatedElement); } }