### Question:
TikaSearchProvider extends LuceneSearchProvider { @Override protected String getAttachmentContent( final Attachment att ) { final AttachmentManager mgr = getEngine().getManager( AttachmentManager.class ); final StringBuilder out = new StringBuilder(); try( final InputStream attStream = mgr.getAttachmentStream( att ) ) { final Metadata metadata = new Metadata(); metadata.set( TikaMetadataKeys.RESOURCE_NAME_KEY, att.getFileName() ); final ContentHandler handler = new BodyContentHandler(-1 ); parser.parse( attStream, handler, metadata ); out.append( handler.toString() ); final String[] names = metadata.names(); for( final String name : names ) { if( textualMetadataFields.contains( name ) ) { out.append( " " ).append( metadata.get( name ) ); } } } catch( final TikaException | SAXException e ) { LOG.error( "Attachment cannot be parsed", e ); } catch( final ProviderException | IOException e ) { LOG.error( "Attachment cannot be loaded", e ); } return out.toString(); } TikaSearchProvider();   }### Answer:
@Test void testGetAttachmentContent() throws Exception { engine.saveText( "Test-tika", "blablablabla" ); final byte[] filePdf = Files.readAllBytes( Paths.get( TikaSearchProviderTest.class.getClassLoader().getResource( "aaa-diagram.pdf" ).toURI() ) ); final byte[] filePng = Files.readAllBytes( Paths.get( TikaSearchProviderTest.class.getClassLoader().getResource( "favicon.png" ).toURI() ) ); engine.addAttachment( "Test-tika", "aaa-diagram.pdf", filePdf ); engine.addAttachment( "Test-tika", "favicon.png", filePng ); final TikaSearchProvider tsp = ( TikaSearchProvider )engine.getManager( SearchManager.class ).getSearchEngine(); final Attachment attPdf = engine.getManager( AttachmentManager.class ).getAttachmentInfo( "Test-tika/aaa-diagram.pdf" ); final String pdfIndexed = tsp.getAttachmentContent( attPdf ); Assertions.assertTrue( pdfIndexed.contains( "aaa-diagram.pdf" ) ); Assertions.assertTrue( pdfIndexed.contains( "WebContainerAuthorizer" ) ); final Attachment attPng = engine.getManager( AttachmentManager.class ).getAttachmentInfo( "Test-tika/favicon.png" ); final String pngIndexed = tsp.getAttachmentContent( attPng ); Assertions.assertTrue( pngIndexed.contains( "favicon.png" ) ); }