Author: nick
Date: Wed Apr 12 09:31:34 2006
New Revision: 393497

URL: http://svn.apache.org/viewcvs?rev=393497&view=rev
Log:
Add a check that just opening a usermodel slidesheet on it doesn't break things

Modified:
    
jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java

Modified: 
jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java
URL: 
http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java?rev=393497&r1=393496&r2=393497&view=diff
==============================================================================
--- 
jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java 
(original)
+++ 
jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java 
Wed Apr 12 09:31:34 2006
@@ -22,6 +22,8 @@
 
 import junit.framework.TestCase;
 import java.io.*;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
 import org.apache.poi.poifs.filesystem.*;
 
 /**
@@ -32,22 +34,56 @@
  */
 public class TestReWrite extends TestCase {
        // HSLFSlideShow primed on the test data
-       private HSLFSlideShow ss;
+       private HSLFSlideShow hss;
        // POIFS primed on the test data
        private POIFSFileSystem pfs;
 
-    public TestReWrite() throws Exception {
+    public void setUp() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                FileInputStream fis = new FileInputStream(filename);
                pfs = new POIFSFileSystem(fis);
-               ss = new HSLFSlideShow(pfs);
+               hss = new HSLFSlideShow(pfs);
     }
 
     public void testWritesOutTheSame() throws Exception {
                // Write out to a byte array
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-               ss.write(baos);
+               hss.write(baos);
+
+               // Build an input stream of it
+               ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());
+
+               // Use POIFS to query that lot
+               POIFSFileSystem npfs = new POIFSFileSystem(bais);
+
+               // Check that the "PowerPoint Document" sections have the same 
size
+               DocumentEntry oProps = 
(DocumentEntry)pfs.getRoot().getEntry("PowerPoint Document");
+               DocumentEntry nProps = 
(DocumentEntry)npfs.getRoot().getEntry("PowerPoint Document");
+               assertEquals(oProps.getSize(),nProps.getSize());
+
+               // Check that they contain the same data
+               byte[] _oData = new byte[oProps.getSize()];
+               byte[] _nData = new byte[nProps.getSize()];
+               pfs.createDocumentInputStream("PowerPoint 
Document").read(_oData);
+               npfs.createDocumentInputStream("PowerPoint 
Document").read(_nData);
+               for(int i=0; i<_oData.length; i++) {
+                       System.out.println(i + "\t" + Integer.toHexString(i));
+                       assertEquals(_oData[i], _nData[i]);
+               }
+       }
+
+    /**
+     * Ensure that simply opening a slideshow (usermodel) view of it
+     *  doesn't change things 
+     */
+    public void testSlideShowWritesOutTheSame() throws Exception {
+       // Create a slideshow covering it
+       SlideShow ss = new SlideShow(hss);
+       
+               // Now write out to a byte array
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               hss.write(baos);
 
                // Build an input stream of it
                ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to