コード例 #1
0
  @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"));
  }
コード例 #2
0
 @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);
 }
コード例 #3
0
  @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);
  }
コード例 #4
0
 @Test
 public void testInvalidPath() throws Exception {
   try {
     bridgeUnderTest.set(testFieldName, "/foo", testDocument, options);
   } catch (SearchException e) {
     assertTrue("Wrong error type", e.getMessage().startsWith("HSEARCH000152"));
   }
 }
コード例 #5
0
 @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());
 }
コード例 #6
0
 @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());
   }
 }
コード例 #7
0
 @Test(expected = IllegalArgumentException.class)
 public void testNullDataThrowsException() {
   bridgeUnderTest.set(testFieldName, null, testDocument, options);
 }