@Test
  public void testIndexingMetadata() {
    bridgeUnderTest.setMetadataProcessorClass(CustomTikaMetadataProcessor.class);
    bridgeUnderTest.set(testFieldName, PATH_TO_TEST_DOCUMENT_PDF, testDocument, options);

    assertEquals(
        "The content type should have been indexed", "application/pdf", testDocument.get("type"));
  }
 @Test
 public void testPrepareMetadata() {
   bridgeUnderTest.setMetadataProcessorClass(CustomTikaMetadataProcessor.class);
   bridgeUnderTest.set(testFieldName, PATH_TO_TEST_DOCUMENT_PDF, testDocument, options);
   assertEquals(
       "The set method of the custom metadata processor should have been called",
       1,
       CustomTikaMetadataProcessor.invocationCount);
 }
  @Test
  public void testCustomTikaParseContextProvider() throws Exception {
    bridgeUnderTest.setParseContextProviderClass(CustomTikaParseContextProvider.class);
    bridgeUnderTest.set(testFieldName, PATH_TO_TEST_DOCUMENT_PDF, testDocument, options);

    assertEquals(
        "The getParseContext method of the custom parse context provider should have been called",
        1,
        CustomTikaParseContextProvider.invocationCount);
  }
 @Test
 public void testInvalidPath() throws Exception {
   try {
     bridgeUnderTest.set(testFieldName, "/foo", testDocument, options);
   } catch (SearchException e) {
     assertTrue("Wrong error type", e.getMessage().startsWith("HSEARCH000152"));
   }
 }
 @Test
 public void testPdfToString() throws Exception {
   URI pdfUri = TikaBridgeTest.class.getResource(TEST_DOCUMENT_PDF).toURI();
   bridgeUnderTest.set(testFieldName, pdfUri, testDocument, options);
   assertEquals(
       "Wrong extracted text",
       "Hibernate Search pdf test document",
       testDocument.get(testFieldName).trim());
 }
 @Test
 public void testUnknownTikaMetadataProcessor() throws Exception {
   try {
     bridgeUnderTest.setMetadataProcessorClass(this.getClass());
     fail();
   } catch (SearchException e) {
     assertEquals(
         "Wrong error message",
         "Wrong configuration of Tika parse context provider: class org.hibernate.search.test.bridge.builtin.TikaBridgeTest does not implement interface org.hibernate.search.bridge.TikaMetadataProcessor",
         e.getMessage());
   }
 }
 @Test(expected = IllegalArgumentException.class)
 public void testNullDataThrowsException() {
   bridgeUnderTest.set(testFieldName, null, testDocument, options);
 }