You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ni...@apache.org on 2018/10/17 16:43:25 UTC
[tika] 03/03: Use the new RSS 2.0 file in tests too,
alongside the current 0.91 one
This is an automated email from the ASF dual-hosted git repository.
nick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tika.git
commit a0546b6cb98c949bb747b2e0e8d5675f651f6a16
Author: Nick Burch <ni...@gagravarr.org>
AuthorDate: Wed Oct 17 17:43:12 2018 +0100
Use the new RSS 2.0 file in tests too, alongside the current 0.91 one
---
.../java/org/apache/tika/mime/TestMimeTypes.java | 3 ++
.../apache/tika/parser/feed/FeedParserTest.java | 38 +++++++++++++---------
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java b/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java
index bfb4c62..a527d4e 100644
--- a/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java
+++ b/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java
@@ -387,9 +387,12 @@ public class TestMimeTypes {
@Test
public void testFeedsDetection() throws Exception {
assertType("application/rss+xml", "rsstest_091.rss");
+ assertType("application/rss+xml", "rsstest_20.rss");
assertType("application/atom+xml", "testATOM.atom");
assertTypeByData("application/rss+xml", "rsstest_091.rss");
assertTypeByName("application/rss+xml", "rsstest_091.rss");
+ assertTypeByData("application/rss+xml", "rsstest_20.rss");
+ assertTypeByName("application/rss+xml", "rsstest_20.rss");
assertTypeByData("application/atom+xml", "testATOM.atom");
assertTypeByName("application/atom+xml", "testATOM.atom");
}
diff --git a/tika-parsers/src/test/java/org/apache/tika/parser/feed/FeedParserTest.java b/tika-parsers/src/test/java/org/apache/tika/parser/feed/FeedParserTest.java
index d7e7c76..1a5c293 100644
--- a/tika-parsers/src/test/java/org/apache/tika/parser/feed/FeedParserTest.java
+++ b/tika-parsers/src/test/java/org/apache/tika/parser/feed/FeedParserTest.java
@@ -31,22 +31,28 @@ import org.xml.sax.ContentHandler;
public class FeedParserTest {
@Test
public void testRSSParser() throws Exception {
- try (InputStream input = FeedParserTest.class.getResourceAsStream(
- "/test-documents/rsstest_091.rss")) {
- Metadata metadata = new Metadata();
- ContentHandler handler = new BodyContentHandler();
- ParseContext context = new ParseContext();
-
- new FeedParser().parse(input, handler, metadata, context);
-
- String content = handler.toString();
- assertFalse(content == null);
-
- assertEquals("Sample RSS File for Junit test",
- metadata.get(TikaCoreProperties.DESCRIPTION));
- assertEquals("TestChannel", metadata.get(TikaCoreProperties.TITLE));
-
- // TODO find a way of testing the paragraphs and anchors
+ // These RSS files should have basically the same contents,
+ // represented in the various RSS format versions
+ for (String rssFile : new String[] {
+ "/test-documents/rsstest_091.rss",
+ "/test-documents/rsstest_20.rss"
+ }) {
+ try (InputStream input = FeedParserTest.class.getResourceAsStream(rssFile)) {
+ Metadata metadata = new Metadata();
+ ContentHandler handler = new BodyContentHandler();
+ ParseContext context = new ParseContext();
+
+ new FeedParser().parse(input, handler, metadata, context);
+
+ String content = handler.toString();
+ assertFalse(content == null);
+
+ assertEquals("Sample RSS File for Junit test",
+ metadata.get(TikaCoreProperties.DESCRIPTION));
+ assertEquals("TestChannel", metadata.get(TikaCoreProperties.TITLE));
+
+ // TODO find a way of testing the paragraphs and anchors
+ }
}
}