4141 * @author Hardy Ferentschik
4242 */
4343public class TikaBridgeInputTypeTest extends SearchTestBase {
44- private static final String TEST_DOCUMENT_PDF = "/org/hibernate/search/test/bridge/tika/test-document-1.pdf" ;
44+
45+ private static final String TEST_DOCUMENT_PDF_1 = "/org/hibernate/search/test/bridge/tika/test-document-1.pdf" ;
46+ private static final String TEST_DOCUMENT_PDF_2 = "/org/hibernate/search/test/bridge/tika/test-document-2.pdf" ;
47+
48+ @ Rule
49+ public ClasspathResourceAsFile testDocumentPdf1 = new ClasspathResourceAsFile ( getClass (), TEST_DOCUMENT_PDF_1 );
4550
4651 @ Rule
47- public ClasspathResourceAsFile testDocumentPdf = new ClasspathResourceAsFile ( getClass (), TEST_DOCUMENT_PDF );
52+ public ClasspathResourceAsFile testDocumentPdf2 = new ClasspathResourceAsFile ( getClass (), TEST_DOCUMENT_PDF_2 );
53+
54+ @ Test
55+ public void testDefaultTikaBridgeWithListOfString () throws Exception {
56+ try ( Session session = openSession () ) {
57+ String content1 = testDocumentPdf1 .get ().getAbsolutePath ();
58+ String content2 = testDocumentPdf2 .get ().getAbsolutePath ();
59+
60+ persistBook ( session , new Book ( content1 , content2 ) );
61+
62+ indexBook ( session );
63+
64+ List <Book > resultWithLucene = search ( session , "contentAsListOfString" , "Lucene" );
65+ assertEquals ( "there should be a match" , 1 , resultWithLucene .size () );
66+
67+ List <Book > resultWithTika = search ( session , "contentAsListOfString" , "Tika" );
68+ assertEquals ( "there should be a match" , 1 , resultWithTika .size () );
69+ }
70+ }
71+
72+ private List <Book > search (Session session , String field , String keyword ) throws ParseException {
73+ FullTextSession fullTextSession = Search .getFullTextSession ( session );
74+ Transaction transaction = fullTextSession .beginTransaction ();
75+ QueryParser parser = new QueryParser ( field , TestConstants .standardAnalyzer );
76+ Query query = parser .parse ( keyword );
77+ @ SuppressWarnings ("unchecked" )
78+ List <Book > result = fullTextSession .createFullTextQuery ( query ).list ();
79+ transaction .commit ();
80+ fullTextSession .clear ();
81+ return result ;
82+ }
4883
4984 @ Test
5085 public void testDefaultTikaBridgeWithBlob () throws Exception {
5186 try ( Session session = openSession () ) {
52- Blob content = dataAsBlob ( testDocumentPdf .get (), session );
87+ Blob content = dataAsBlob ( testDocumentPdf1 .get (), session );
5388
5489 persistBook ( session , new Book ( content ) );
5590 persistBook ( session , new Book () );
@@ -64,7 +99,7 @@ public void testDefaultTikaBridgeWithBlob() throws Exception {
6499 @ Test
65100 public void testDefaultTikaBridgeWithByteArray () throws Exception {
66101 try ( Session session = openSession () ) {
67- byte [] content = dataAsBytes ( testDocumentPdf .get () );
102+ byte [] content = dataAsBytes ( testDocumentPdf1 .get () );
68103
69104 persistBook ( session , new Book ( content ) );
70105 persistBook ( session , new Book () );
@@ -77,7 +112,7 @@ public void testDefaultTikaBridgeWithByteArray() throws Exception {
77112 @ Test
78113 public void testDefaultTikaBridgeWithURI () throws Exception {
79114 try ( Session session = openSession () ) {
80- URI content = testDocumentPdf .get ().toURI ();
115+ URI content = testDocumentPdf1 .get ().toURI ();
81116
82117 persistBook ( session , new Book ( content ) );
83118 persistBook ( session , new Book () );
0 commit comments