1   package com.atlassian.bonnie.search.extractor;
2   
3   import com.atlassian.bonnie.search.Extractor;
4   import com.atlassian.bonnie.search.MockSearchableAttachment;
5   
6   import java.io.IOException;
7   
8   public class TestPdfContentExtractor extends BaseAttachmentContentExtractorTest
9   {
10      public Extractor getExtractor()
11      {
12          return new PdfContentExtractor();
13      }
14  
15  	public void testSimplePdf()
16  	{
17  		assertOnExtractedTextOf(createSearchableAttachment("test-attachment-search.pdf", "application/pdf"), new String[]{"feature"}, new String[]{"apples"});
18  	}
19  
20      public void testExtractorExceptionThrownOnError() throws IOException
21      {
22          MockSearchableAttachment attachment = createSearchableAttachment("test-attachment-search.txt", "text/plain");
23          attachment.setContentType("application/pdf");
24          try
25          {
26              ((PdfContentExtractor) extractor).extractText(attachment.getContentsAsStream(), attachment);
27              fail("Exception expected");
28          }
29          catch (ExtractorException e)
30          {
31              // pass - exception expected
32          }
33      }
34  }