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

Bob Paulin commented on TIKA-1501:
----------------------------------

[[email protected]] The code you've cited above obtains a reference to the 
service that is instantiated in the tika-bunlde in the 
org.apache.tika.parser.internal.Activator which sets the tika-bundle's 
classloader as the classloader for the ServiceLoader and registered the 
DefaultDetector object as a service with the framework.  The tika-bundle has 
it's own classloader within OSGi (as all bundles do) and the 
ServiceLoader.identifyStaticServiceProviders code looks for 
META-INF/services/org.apache.tika.detect.Detector which only exists in the 
tika-bundle classloader (this file is generated during the build).  So when you 
look at the detectorService object from the code you cite above it has a number 
of detectors.  However when you instantiate DefaultDetector in the test code 
(for example in testBundleDetectors()) you are not in the tika-bundle so it 
can't see META-INF/services/org.apache.tika.detect.Detector.  This accounts for 
why you see 

org.apache.tika.parser.microsoft.POIFSContainerDetector
org.apache.tika.parser.pkg.ZipContainerDetector

in the detectorService but not in the DefaultDetector you instantiate in the 
test.  This is why I really was not clear on what was being tested since it 
appears that there are in fact different expectations inside and outside of the 
OSGi environment for this class.

> Fix the disabled Tika Bundle OSGi related unit tests
> ----------------------------------------------------
>
>                 Key: TIKA-1501
>                 URL: https://issues.apache.org/jira/browse/TIKA-1501
>             Project: Tika
>          Issue Type: Improvement
>          Components: packaging
>    Affects Versions: 1.6, 1.7
>            Reporter: Nick Burch
>         Attachments: TIKA-1501-trunk.patch, TIKA-1501-trunkv2.patch, 
> TIKA-1501.patch
>
>
> Currently, the unit tests for the Tika Bundle contain several bits like:
> {code}
> @Ignore // TODO Fix this test
> {code}
> We should really fix these unit tests so they work, and re-enable them



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to