You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2011/05/19 13:54:29 UTC

svn commit: r1124693 - in /poi/trunk/src: java/org/apache/poi/poifs/property/NPropertyTable.java testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java

Author: nick
Date: Thu May 19 11:54:29 2011
New Revision: 1124693

URL: http://svn.apache.org/viewvc?rev=1124693&view=rev
Log:
Add some more NPOIFS write related tests, some of which is disabled as the functionality isn't quite there yet

Modified:
    poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java
    poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java

Modified: poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java?rev=1124693&r1=1124692&r2=1124693&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/property/NPropertyTable.java Thu May 19 11:54:29 2011
@@ -116,7 +116,9 @@ public final class NPropertyTable extend
        // TODO - Use a streaming write
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        for(Property property : _properties) {
-          property.writeData(baos);
+          if(property != null) {
+             property.writeData(baos);
+          }
        }
        stream.updateContents(baos.toByteArray());
        

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java?rev=1124693&r1=1124692&r2=1124693&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java Thu May 19 11:54:29 2011
@@ -32,6 +32,7 @@ import org.apache.poi.poifs.common.POIFS
 import org.apache.poi.poifs.property.NPropertyTable;
 import org.apache.poi.poifs.property.Property;
 import org.apache.poi.poifs.property.RootProperty;
+import org.apache.poi.poifs.storage.HeaderBlock;
 
 /**
  * Tests for the new NIO POIFSFileSystem implementation
@@ -437,16 +438,41 @@ public final class TestNPOIFSFileSystem 
          assertEquals(false, fs.getBATBlockAndIndex(237*128).getBlock().hasFreeSectors());
          fail("Should only be 237 BATs");
       } catch(IndexOutOfBoundsException e) {}
+      
+      
+      // Check the counts
+      int numBATs = 0;
+      int numXBATs = 0;
+      for(int i=0; i<237*128; i++) {
+         if(fs.getNextBlock(i) == POIFSConstants.FAT_SECTOR_BLOCK) {
+            numBATs++;
+         }
+         if(fs.getNextBlock(i) == POIFSConstants.DIFAT_SECTOR_BLOCK) {
+            numXBATs++;
+         }
+      }
+      if(1==2) {
+      // TODO Fix this
+      assertEquals(237, numBATs);
+      assertEquals(2, numXBATs);
+      }
 
       
-      // Write it out and read it back in again
-      // TODO
+      // Write it out
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      fs.writeFilesystem(baos);
       
       // Check the header is correct
-      // TODO
+      HeaderBlock header = new HeaderBlock(new ByteArrayInputStream(baos.toByteArray()));
+      if(1==2) {
+      // TODO Fix this
+      assertEquals(237, header.getBATCount());
+      assertEquals(2, header.getXBATCount());
       
       // Now check the filesystem sees it correct too
+      fs = new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
       // TODO
+      }
    }
    
    /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org