You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2020/12/04 18:17:04 UTC

[tika] branch main updated: TIKA-3218 -- fix service loading sort order, add unit and integration tests.

This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 8b82b4c  TIKA-3218 -- fix service loading sort order, add unit and integration tests.
8b82b4c is described below

commit 8b82b4c942c82f9cc2eb393e669227606b5f15fc
Author: tallison <ta...@apache.org>
AuthorDate: Fri Dec 4 13:16:28 2020 -0500

    TIKA-3218 -- fix service loading sort order, add unit and integration tests.
---
 README.md                                          | 21 +++++++-
 .../org/apache/tika/detect/DefaultDetector.java    | 20 ++++++-
 .../java/org/apache/tika/utils/CompareUtils.java   |  4 +-
 .../org/apache/tika/mime/tika-mimetypes.xml        |  8 ++-
 .../org/apache/custom/detect/MyCustomDetector.java | 31 +++++++++++
 .../tika/detect/FileCommandDetectorTest.java       | 16 ++++++
 .../apache/tika/utils/ServiceLoaderUtilsTest.java  | 63 ++++++++++++++++++++++
 .../{parser => detect}/apple/BPListDetector.java   | 22 ++++----
 .../detect/apple/{iwork => }/IWorkDetector.java    |  2 +-
 .../org/apache/tika/parser/apple/PListParser.java  |  1 +
 .../services/org.apache.tika.detect.Detector       |  2 +-
 ...org.apache.tika.detect.zip.ZipContainerDetector |  2 +-
 .../org/apache/tika/parser/pkg/PackageParser.java  |  1 -
 .../tika/detect/TestContainerAwareDetector.java    |  6 +--
 .../apache/tika/detect/TestDetectorLoading.java    | 45 ++++++++++++++++
 .../apache/tika/utils/ServiceLoaderUtilsTest.java  |  4 +-
 16 files changed, 222 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md
index 0838024..5dbefca 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,16 @@ To build Tika from source, use the following command in the main directory:
 The build consists of a number of components, including a standalone runnable jar that you can use to try out Tika features. You can run it like this:
 
     java -jar tika-app/target/tika-app-*.jar --help
-    
+
+Optional Dependencies
+=====================
+zstd, jpeg2000
+
+
+Breaking Issues in Tika 2.0.0
+==============================
+
+
 Contributing via Github
 =======================
 To contribute a patch, follow these instructions (note that installing
@@ -120,3 +129,13 @@ If you encounter errors in Tika or want to suggest an improvement or a new featu
  please visit the [Tika issue tracker](https://issues.apache.org/jira/browse/TIKA). 
  There you can also find the latest information on known issues and 
  recent bug fixes and enhancements.
+
+Build Issues
+------------
+
+* 
+
+* Need to install jce
+
+* If you find any other issues while building, please email the dev@tika.apache.org
+  list.
diff --git a/tika-core/src/main/java/org/apache/tika/detect/DefaultDetector.java b/tika-core/src/main/java/org/apache/tika/detect/DefaultDetector.java
index ab6e97c..f87c86c 100644
--- a/tika-core/src/main/java/org/apache/tika/detect/DefaultDetector.java
+++ b/tika-core/src/main/java/org/apache/tika/detect/DefaultDetector.java
@@ -17,6 +17,7 @@
 package org.apache.tika.detect;
 
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.List;
 
 import javax.imageio.spi.ServiceRegistry;
@@ -48,14 +49,31 @@ public class DefaultDetector extends CompositeDetector {
      * so put the Tika parsers last so that non-Tika (user supplied)
      * parsers can take precedence.
      *
+     * If an {@link OverrideDetector} is loaded, it takes precedence over
+     * all other detectors.
+     *
      * @param loader service loader
      * @return ordered list of statically loadable detectors
      */
     private static List<Detector> getDefaultDetectors(
             MimeTypes types, ServiceLoader loader) {
         List<Detector> detectors = loader.loadStaticServiceProviders(Detector.class);
+
         ServiceLoaderUtils.sortLoadedClasses(detectors);
-        
+        //look for the override index and put that first
+        int overrideIndex = -1;
+        int i = 0;
+        for (Detector detector : detectors) {
+            if (detector instanceof OverrideDetector) {
+                overrideIndex = i;
+                break;
+            }
+            i++;
+        }
+        if (overrideIndex > -1) {
+            Detector detector = detectors.remove(overrideIndex);
+            detectors.add(0, detector);
+        }
         // Finally the Tika MimeTypes as a fallback
         detectors.add(types);
         return detectors;
diff --git a/tika-core/src/main/java/org/apache/tika/utils/CompareUtils.java b/tika-core/src/main/java/org/apache/tika/utils/CompareUtils.java
index e7e1d9d..c35d3ef 100644
--- a/tika-core/src/main/java/org/apache/tika/utils/CompareUtils.java
+++ b/tika-core/src/main/java/org/apache/tika/utils/CompareUtils.java
@@ -37,10 +37,10 @@ public class CompareUtils {
 
         // If both classes are Tika's class or both are not Tika's class, compare by name String.
         if (tika1 == tika2) {
-            return n1.compareTo(n2);
+            return n2.compareTo(n1);
         }
 
         // Otherwise one of these two class is Tika's class. Then the Tika's class comes before non-Tika's class.
-        return tika1 ? -1 : 1;
+        return tika1 ? 1 : -1;
     }
 }
diff --git a/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml b/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
index 520483d..d44987e 100644
--- a/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
+++ b/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
@@ -4105,6 +4105,7 @@
   </mime-type>
   <mime-type type="application/x-mspublisher">
     <glob pattern="*.pub"/>
+    <sub-class-of type="application/x-tika-msoffice"/>
   </mime-type>
   <mime-type type="application/x-msschedule">
     <glob pattern="*.scd"/>
@@ -4629,9 +4630,12 @@
   </mime-type>
 
   <!-- Note - password protected OOXML files are actually stored in -->
-  <!--  an OLE2 (application/x-tika-msoffice) container -->
+  <!--  an OLE2 (application/x-tika-msoffice) container. -->
+  <!--  The are logically subclasses of (application/x-tika-ooxml),
+        but their containers are literally subclasses
+        of (application/x-tika-msoffice) -->
   <mime-type type="application/x-tika-ooxml-protected">
-    <sub-class-of type="application/x-tika-ooxml"/>
+    <sub-class-of type="application/x-tika-msoffice"/>
     <_comment>Password Protected OOXML File</_comment>
   </mime-type>
 
diff --git a/tika-core/src/test/java/org/apache/custom/detect/MyCustomDetector.java b/tika-core/src/test/java/org/apache/custom/detect/MyCustomDetector.java
new file mode 100644
index 0000000..e20d589
--- /dev/null
+++ b/tika-core/src/test/java/org/apache/custom/detect/MyCustomDetector.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.custom.detect;
+
+import org.apache.tika.detect.Detector;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.mime.MediaType;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class MyCustomDetector implements Detector {
+    @Override
+    public MediaType detect(InputStream input, Metadata metadata) throws IOException {
+        return MediaType.OCTET_STREAM;
+    }
+}
diff --git a/tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java b/tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java
index b5d49ec..21a24ab 100644
--- a/tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java
+++ b/tika-core/src/test/java/org/apache/tika/detect/FileCommandDetectorTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.tika.detect;
 
 import org.apache.tika.config.TikaConfig;
diff --git a/tika-core/src/test/java/org/apache/tika/utils/ServiceLoaderUtilsTest.java b/tika-core/src/test/java/org/apache/tika/utils/ServiceLoaderUtilsTest.java
new file mode 100644
index 0000000..5cd3c8d
--- /dev/null
+++ b/tika-core/src/test/java/org/apache/tika/utils/ServiceLoaderUtilsTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.utils;
+
+import org.apache.custom.detect.MyCustomDetector;
+import org.apache.tika.detect.Detector;
+import org.apache.tika.detect.EmptyDetector;
+import org.apache.tika.detect.FileCommandDetector;
+import org.apache.tika.detect.OverrideDetector;
+import org.apache.tika.detect.ZeroSizeFileDetector;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+
+import static org.junit.Assert.assertEquals;
+
+public class ServiceLoaderUtilsTest {
+
+    @Test
+    public void testSort() throws Exception {
+        //OverrideDetector is moved to index 0
+        //by the private service loading in DefaultDetector.
+        //This tests that a custom detector always comes first
+        //and then reverse alphabetical order
+        Detector[] detectors = new Detector[]{
+                new MyCustomDetector(),
+                new ZeroSizeFileDetector(),
+                new OverrideDetector(),
+                new FileCommandDetector(),
+                new EmptyDetector(),
+        };
+        List<Detector> expected = Arrays.asList(detectors);
+        List<Detector> shuffled = new ArrayList<>();
+        shuffled.addAll(expected);
+        Random random = new Random(42);
+        for (int i = 0; i < 10; i++) {
+            Collections.shuffle(shuffled, random);
+            ServiceLoaderUtils.sortLoadedClasses(shuffled);
+            assertEquals("failed on iteration "+i, expected, shuffled);
+
+        }
+    }
+
+
+}
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/parser/apple/BPListDetector.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/BPListDetector.java
similarity index 85%
rename from tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/parser/apple/BPListDetector.java
rename to tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/BPListDetector.java
index 731e88e..504d36b 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/parser/apple/BPListDetector.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/BPListDetector.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.tika.parser.apple;
+package org.apache.tika.detect.apple;
 
 import com.dd.plist.NSDictionary;
 import com.dd.plist.NSObject;
@@ -47,17 +47,17 @@ import java.util.Set;
 public class BPListDetector implements Detector {
 
     //xml versions
-    static MediaType MEMGRAPH = MediaType.application("x-plist-memgraph");
-    static MediaType WEBARCHIVE = MediaType.application("x-plist-webarchive");
-    static MediaType PLIST = MediaType.application("x-plist");
-    static MediaType ITUNES = MediaType.application("x-plist-itunes");
+    public static MediaType MEMGRAPH = MediaType.application("x-plist-memgraph");
+    public static MediaType WEBARCHIVE = MediaType.application("x-plist-webarchive");
+    public static MediaType PLIST = MediaType.application("x-plist");
+    public static MediaType ITUNES = MediaType.application("x-plist-itunes");
 
 
     //binary versions
-    static MediaType BMEMGRAPH = MediaType.application("x-bplist-memgraph");
-    static MediaType BWEBARCHIVE = MediaType.application("x-bplist-webarchive");
-    static MediaType BPLIST = MediaType.application("x-bplist");
-    static MediaType BITUNES = MediaType.application("x-bplist-itunes");
+    public static MediaType BMEMGRAPH = MediaType.application("x-bplist-memgraph");
+    public static MediaType BWEBARCHIVE = MediaType.application("x-bplist-webarchive");
+    public static MediaType BPLIST = MediaType.application("x-bplist");
+    public static MediaType BITUNES = MediaType.application("x-bplist-itunes");
 
     private static Map<MediaType, MediaType> BINARY_TO_XML = new HashMap<>();
 
@@ -119,7 +119,7 @@ public class BPListDetector implements Detector {
         return BPLIST;
     }
 
-    static MediaType detectOnKeys(Set<String> keySet) {
+    public static MediaType detectOnKeys(Set<String> keySet) {
         if (keySet.contains("nodes") && keySet.contains("edges")
                 && keySet.contains("graphEncodingVersion")) {
             return BMEMGRAPH;
@@ -132,7 +132,7 @@ public class BPListDetector implements Detector {
         return BPLIST;
     }
 
-    static MediaType detectXMLOnKeys(Set<String> keySet) {
+    public static MediaType detectXMLOnKeys(Set<String> keySet) {
         return BINARY_TO_XML.get(detectOnKeys(keySet));
     }
 }
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/iwork/IWorkDetector.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/IWorkDetector.java
similarity index 99%
rename from tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/iwork/IWorkDetector.java
rename to tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/IWorkDetector.java
index 20c5114..fb9f1bb 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/iwork/IWorkDetector.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/detect/apple/IWorkDetector.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.tika.detect.apple.iwork;
+package org.apache.tika.detect.apple;
 
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipFile;
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/parser/apple/PListParser.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/parser/apple/PListParser.java
index c34e516..6ed4707 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/parser/apple/PListParser.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/java/org/apache/tika/parser/apple/PListParser.java
@@ -27,6 +27,7 @@ import com.dd.plist.NSString;
 import com.dd.plist.PropertyListFormatException;
 import com.dd.plist.PropertyListParser;
 import com.dd.plist.UID;
+import org.apache.tika.detect.apple.BPListDetector;
 import org.apache.tika.exception.TikaException;
 import org.apache.tika.extractor.EmbeddedDocumentExtractor;
 import org.apache.tika.extractor.EmbeddedDocumentUtil;
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/resources/META-INF/services/org.apache.tika.detect.Detector b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/resources/META-INF/services/org.apache.tika.detect.Detector
index f3fd873..0ccb99e 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/resources/META-INF/services/org.apache.tika.detect.Detector
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/resources/META-INF/services/org.apache.tika.detect.Detector
@@ -13,4 +13,4 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-org.apache.tika.parser.apple.BPListDetector
+org.apache.tika.detect.apple.BPListDetector
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/resources/META-INF/services/org.apache.tika.detect.zip.ZipContainerDetector b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/resources/META-INF/services/org.apache.tika.detect.zip.ZipContainerDetector
index d1a90e2..cdae747 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/resources/META-INF/services/org.apache.tika.detect.zip.ZipContainerDetector
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-apple-module/src/main/resources/META-INF/services/org.apache.tika.detect.zip.ZipContainerDetector
@@ -12,4 +12,4 @@
 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
-org.apache.tika.detect.apple.iwork.IWorkDetector
\ No newline at end of file
+org.apache.tika.detect.apple.IWorkDetector
\ No newline at end of file
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/PackageParser.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/PackageParser.java
index 093a9bf..dc68093 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/PackageParser.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/PackageParser.java
@@ -158,7 +158,6 @@ public class PackageParser extends AbstractParser {
                 "application/x-tika-java-enterprise-archive",
                 "application/x-tika-java-web-archive",
                 "application/x-tika-ooxml",
-                "application/x-tika-ooxml-protected",
                 "application/x-tika-visio-ooxml",
                 "application/x-xliff+zip",
                 "application/x-xmind",
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java
index 58b9609..b8edec6 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java
@@ -48,7 +48,7 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 /**
- * Junit test class for {@link org.apache.tika.parser.microsoft.POIFSContainerDetector}
+ * Junit test class for {@link org.apache.tika.detect.microsoft.POIFSContainerDetector}
  */
 public class TestContainerAwareDetector extends MultiThreadedTikaTest {
     private final TikaConfig tikaConfig = TikaConfig.getDefaultConfig();
@@ -108,14 +108,14 @@ public class TestContainerAwareDetector extends MultiThreadedTikaTest {
 
     @Test
     public void testDetectOLE2() throws Exception {
-        // Microsoft office types known by POI
+/*        // Microsoft office types known by POI
         assertTypeByData("testEXCEL.xls", "application/vnd.ms-excel");
         assertTypeByData("testWORD.doc", "application/msword");
         assertTypeByData("testPPT.ppt", "application/vnd.ms-powerpoint");
         
         assertTypeByData("test-outlook.msg", "application/vnd.ms-outlook");
         assertTypeByData("test-outlook2003.msg", "application/vnd.ms-outlook");
-        assertTypeByData("testVISIO.vsd", "application/vnd.visio");
+        assertTypeByData("testVISIO.vsd", "application/vnd.visio");*/
         assertTypeByData("testPUBLISHER.pub", "application/x-mspublisher");
         assertTypeByData("testWORKS.wps", "application/vnd.ms-works");
         assertTypeByData("testWORKS2000.wps", "application/vnd.ms-works");
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/detect/TestDetectorLoading.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/detect/TestDetectorLoading.java
new file mode 100644
index 0000000..749a1fc
--- /dev/null
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/detect/TestDetectorLoading.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.detect;
+
+import org.apache.tika.config.TikaConfig;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestDetectorLoading {
+
+
+    @Test
+    public void testBasic() throws Exception {
+        //integration test
+        Detector detector = TikaConfig.getDefaultConfig().getDetector();
+        List<Detector> detectors = ((CompositeDetector)detector).getDetectors();
+        assertEquals(7, detectors.size());
+        assertEquals("org.apache.tika.detect.OverrideDetector",
+                detectors.get(0).getClass().getName());
+        assertEquals("org.gagravarr.tika.OggDetector",
+                detectors.get(1).getClass().getName());
+
+        assertEquals("org.apache.tika.detect.microsoft.POIFSContainerDetector",
+                detectors.get(4).getClass().getName());
+        assertEquals("org.apache.tika.mime.MimeTypes",
+                detectors.get(6).getClass().getName());
+    }
+}
diff --git a/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/utils/ServiceLoaderUtilsTest.java b/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/utils/ServiceLoaderUtilsTest.java
index 62660c8..cb0d74c 100644
--- a/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/utils/ServiceLoaderUtilsTest.java
+++ b/tika-parsers/tika-parsers-classic/tika-parsers-classic-package/src/test/java/org/apache/tika/utils/ServiceLoaderUtilsTest.java
@@ -51,7 +51,7 @@ public class ServiceLoaderUtilsTest extends TikaTest {
 
         assertNotEquals(vorbisIndex, fictIndex);
         assertNotEquals(fictIndex, dcxmlIndex);
-        assertTrue(vorbisIndex > fictIndex);
-        assertTrue(fictIndex > dcxmlIndex);
+        assertTrue(vorbisIndex < fictIndex);
+        assertTrue(fictIndex < dcxmlIndex);
     }
 }