Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

fix for NUTCH-767 : reverted original expected values for test + treat text/plain as a default mime-type from Tika

Julien Niochebcfba15e0719
diff --git a/src/java/org/apache/nutch/util/MimeUtil.java b/src/java/org/apache/nutch/util/MimeUtil.java
index faf8a6103..08fe070fb 100644
--- a/src/java/org/apache/nutch/util/MimeUtil.java
+++ b/src/java/org/apache/nutch/util/MimeUtil.java
@@ -159,6 +159,7 @@ public final class MimeUtil {
if (this.mimeMagic) {
MimeType magicType = this.mimeTypes.getMimeType(data);
if (magicType != null && !magicType.getName().equals(MimeTypes.OCTET_STREAM)
+ && !magicType.getName().equals(MimeTypes.PLAIN_TEXT)
&& type != null && !type.getName().equals(magicType.getName())) {
// If magic enabled and the current mime type differs from that of the
// one returned from the magic, take the magic mimeType
diff --git a/src/test/org/apache/nutch/protocol/TestContent.java b/src/test/org/apache/nutch/protocol/TestContent.java
index fb4706e04..d8cba56c9 100644
--- a/src/test/org/apache/nutch/protocol/TestContent.java
+++ b/src/test/org/apache/nutch/protocol/TestContent.java
@@ -63,28 +63,19 @@ public class TestContent extends TestCase {
"http://www.foo.com/",
"".getBytes("UTF8"),
"text/html; charset=UTF-8", p, conf);
- // TODO check potential Tika issue and
- // revert the expected value to text/html
- // see https://issues.apache.org/jira/browse/NUTCH-767
- assertEquals("text/plain", c.getContentType());
+ assertEquals("text/html", c.getContentType());
c = new Content("http://www.foo.com/foo.html",
"http://www.foo.com/",
"".getBytes("UTF8"),
"", p, conf);
- // TODO check potential Tika issue and
- // revert the expected value to text/html
- // see https://issues.apache.org/jira/browse/NUTCH-767
- assertEquals("text/plain", c.getContentType());
+ assertEquals("text/html", c.getContentType());
c = new Content("http://www.foo.com/foo.html",
"http://www.foo.com/",
"".getBytes("UTF8"),
null, p, conf);
- // TODO check potential Tika issue and
- // revert the expected value to text/html
- // see https://issues.apache.org/jira/browse/NUTCH-767
- assertEquals("text/plain", c.getContentType());
+ assertEquals("text/html", c.getContentType());
c = new Content("http://www.foo.com/",
"http://www.foo.com/",
@@ -108,10 +99,7 @@ public class TestContent extends TestCase {
"http://www.foo.com/",
"".getBytes("UTF8"),
"", p, conf);
- // TODO check that Tika returns the right value and
- // revert to the default type
- // see https://issues.apache.org/jira/browse/NUTCH-767
- assertEquals("text/plain", c.getContentType());
+ assertEquals(MimeTypes.OCTET_STREAM, c.getContentType());
c = new Content("http://www.foo.com/",
"http://www.foo.com/",