Package org.apache.poi

Examples of org.apache.poi.POIDataSamples


   * Check that we do the right thing when the list of which
   *  sectors are BAT blocks points off the list of
   *  sectors that exist in the file.
   */
  public void testFATandDIFATsectors() throws Exception {
      POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
     
      // Open the file up
      try {
         POIFSFileSystem fs = new POIFSFileSystem(
             _samples.openResourceAsStream("ReferencesInvalidSectors.mpp")
         );
         fail("File is corrupt and shouldn't have been opened");
      } catch(IOException e) {
         String msg = e.getMessage();
         assertTrue(msg.startsWith("Your file contains 695 sectors"));
View Full Code Here


  /**
   * Most OLE2 files use 512byte blocks. However, a small number
   *  use 4k blocks. Check that we can open these.
   */
  public void test4KBlocks() throws Exception {
      POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
     InputStream inp = _samples.openResourceAsStream("BlockSize4096.zvi");
    
     // First up, check that we can process the header properly
      HeaderBlockReader header_block_reader = new HeaderBlockReader(inp);
      POIFSBigBlockSize bigBlockSize = header_block_reader.getBigBlockSize();
      assertEquals(4096, bigBlockSize.getBigBlockSize());
     
      // Check the fat info looks sane
      assertEquals(109, header_block_reader.getBATArray().length);
      assertTrue(header_block_reader.getBATCount() > 0);
      assertEquals(0, header_block_reader.getXBATCount());
     
      // Now check we can get the basic fat
      RawDataBlockList data_blocks = new RawDataBlockList(inp, bigBlockSize);

    
     // Now try and open properly
     POIFSFileSystem fs = new POIFSFileSystem(
           _samples.openResourceAsStream("BlockSize4096.zvi")
     );
     assertTrue(fs.getRoot().getEntryCount() > 3);
    
     // Check we can get at all the contents
     checkAllDirectoryContents(fs.getRoot());
    
    
     // Finally, check we can do a similar 512byte one too
     fs = new POIFSFileSystem(
            _samples.openResourceAsStream("BlockSize512.zvi")
      );
      assertTrue(fs.getRoot().getEntryCount() > 3);
      checkAllDirectoryContents(fs.getRoot());
  }
View Full Code Here

    protected void setUp() throws Exception {
    super.setUp();

    // Find a real RecordContainer record
        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
    HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));

    Record[] r = hss.getRecords();
    for(int i=0; i<r.length; i++) {
      if(r[i] instanceof RecordContainer) {
        recordContainer = (RecordContainer)r[i];
View Full Code Here

      assertEquals(data_a[i],b[i]);
    }
  }

  public void testRealFile() throws Exception {
        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
    HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt"));
    SlideShow ss = new SlideShow(hss);

    // Get the document
    Document doc = ss.getDocumentRecord();
    // Get the ExObjList
View Full Code Here

  private HSLFSlideShow ss;
  // POIFS primed on the test data
  private POIFSFileSystem pfs;

  public TestDocument() throws Exception {
        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
    pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
    ss = new HSLFSlideShow(pfs);
  }
View Full Code Here

*
* @author Nick Burch (nick at torchbox dot com)
*/
public class TestExObjList extends TestCase {
  public void testRealFile() throws Exception {
        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
    HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt"));
    SlideShow ss = new SlideShow(hss);

    // Get the document
    Document doc = ss.getDocumentRecord();
    // Get the ExObjList
View Full Code Here

   */
  public void setUp() throws Exception {
    hss_empty = HSLFSlideShow.create();
    ss_empty = new SlideShow(hss_empty);

        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();

    hss_one = new HSLFSlideShow(slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
    ss_one = new SlideShow(hss_one);

    hss_two = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
    ss_two = new SlideShow(hss_two);
  }
View Full Code Here

        assertEquals(1, s3.length);
    }


    public void test47261() throws Exception {
        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
        SlideShow ppt = new SlideShow(slTests.openResourceAsStream("47261.ppt"));
        Slide[] slides = ppt.getSlides();
        Document doc = ppt.getDocumentRecord();
        assertNotNull(doc.getSlideSlideListWithText());
        assertEquals(14, ppt.getSlides().length);
        int notesId = slides[0].getSlideRecord().getSlideAtom().getNotesID();
View Full Code Here

    "This is the title on page 2",
    "This is page two\nIt has several blocks of text\nNone of them have formatting",
  };

    public TestCruddyExtractor() throws Exception {
        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
    te = new QuickButCruddyTextExtractor(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
    }
View Full Code Here

   *            file name of the slide show to assert
   * @param titles
   *            array of reference slide titles
   */
  protected void assertSlideOrdering(String filename, String[] titles) throws Exception {
        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();

        SlideShow ppt = new SlideShow(slTests.openResourceAsStream(filename));
    Slide[] slide = ppt.getSlides();

    assertEquals(titles.length, slide.length);
    for (int i = 0; i < slide.length; i++) {
      String title = slide[i].getTitle();
View Full Code Here

TOP

Related Classes of org.apache.poi.POIDataSamples

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.