PageRenderTime 88ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/java/org/blackbeanbag/recipe/poi/WordDocPoiTest.java

https://github.com/pperalta/recipe-index
Java | 35 lines | 22 code | 7 blank | 6 comment | 0 complexity | dc90b2b1ca11297965721e9231c845d0 MD5 | raw file
  1. package org.blackbeanbag.recipe.poi;
  2. import static org.junit.Assert.*;
  3. import java.io.FileInputStream;
  4. import java.io.FileNotFoundException;
  5. import java.io.IOException;
  6. import org.apache.poi.hwpf.extractor.WordExtractor;
  7. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  8. import org.junit.Test;
  9. /**
  10. * Test case for asserting the Apache POI functionality.
  11. *
  12. * @author pperalta
  13. *
  14. */
  15. public class WordDocPoiTest {
  16. @Test
  17. public void readFirstLine() throws FileNotFoundException, IOException {
  18. POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(
  19. "data/Arroz con Gandules Recipe.doc"));
  20. assertNotNull(fs);
  21. WordExtractor extractor = new WordExtractor(fs);
  22. assertNotNull(extractor);
  23. String[] paragraphs = extractor.getParagraphText();
  24. assertNotNull(paragraphs);
  25. String title = paragraphs[0].trim();
  26. assertEquals("Document title match", "Arroz con Gandules Recipe", title);
  27. }
  28. }