You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Hudson (Jira)" <ji...@apache.org> on 2021/03/16 15:45:00 UTC

[jira] [Commented] (TIKA-3323) FileCommandDetectorTest incocnistent results depending on platform

    [ https://issues.apache.org/jira/browse/TIKA-3323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17302634#comment-17302634 ] 

Hudson commented on TIKA-3323:
------------------------------

SUCCESS: Integrated in Jenkins build Tika ยป tika-branch1x-jdk8 #100 (See [https://ci-builds.apache.org/job/Tika/job/tika-branch1x-jdk8/100/])
TIKA-3323 -- allow flexibility for 'file' command output on different operating systems (tallison: [https://github.com/apache/tika/commit/2e5b822526244a15d9f49bc5c1d063e6ed50d1b2])
* (edit) tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java


> FileCommandDetectorTest incocnistent results depending on platform
> ------------------------------------------------------------------
>
>                 Key: TIKA-3323
>                 URL: https://issues.apache.org/jira/browse/TIKA-3323
>             Project: Tika
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.25
>            Reporter: Andrew Pavlin
>            Assignee: Tim Allison
>            Priority: Major
>             Fix For: 1.26
>
>
> The unit test for org.apache.tika.detect.FileCommandDetector fails on some platforms due to inconsistent return values from the operating system's "file --mime" command. For example, on Fedora Core 32 and Mint 19, the test case returns "text/xml". However, on Oracle Enterprise Linux 6, the test case returns "application/xml", which is equally valid but causes the unit test case to fail. When the unit test case fails, it is impossible to build Tika.
> The unit test program should be fixed to accept either answer so all dialects of the file command work successfully. A proposed patch is included below:
> diff --git a/tika-1.25/tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java b/tika-1.25/tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java
> index 21a24ab..1911e05 100644
> --- a/tika-1.25/tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java
> +++ b/tika-1.25/tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java
> @@ -44,9 +44,11 @@ public class FileCommandDetectorTest {
>  assumeTrue(FileCommandDetector.checkHasFile());
>  
>  try (InputStream is = getClass().getResourceAsStream("/test-documents/basic_embedded.xml")) {
> - assertEquals(MediaType.text("xml"), DETECTOR.detect(is, new Metadata()));
> + MediaType answer = DETECTOR.detect(is, new Metadata()));
> + assert(MediaType.text("xml").equals(answer) || MediaType.application("xml").equals(answer));
>  //make sure that the detector is resetting the stream
> - assertEquals(MediaType.text("xml"), DETECTOR.detect(is, new Metadata()));
> + answer = DETECTOR.detect(is, new Metadata()));
> + assert(MediaType.text("xml").equals(answer) || MediaType.application("xml").equals(answer));
>  }
>  
>  //now try with TikaInputStream



--
This message was sent by Atlassian Jira
(v8.3.4#803005)