Ejemplo n.º 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"));
  }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
  }
Ejemplo n.º 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"));
   }
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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());
   }
 }
Ejemplo n.º 7
0
 @Test(expected = IllegalArgumentException.class)
 public void testNullDataThrowsException() {
   bridgeUnderTest.set(testFieldName, null, testDocument, options);
 }