poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1691843 [29/30] - in /poi/branches/common_sl: ./ .settings/ legal/ osgi/ osgi/src/ src/examples/src/org/apache/poi/hpsf/examples/ src/examples/src/org/apache/poi/hssf/usermodel/examples/ src/examples/src/org/apache/poi/ss/examples/ src/exa...
Date Sun, 19 Jul 2015 19:00:38 GMT
Modified: poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java Sun Jul 19 19:00:32 2015
@@ -20,6 +20,7 @@ package org.apache.poi.poifs.filesystem;
 import static org.hamcrest.core.IsCollectionContaining.hasItem;
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
@@ -935,27 +936,27 @@ public final class TestNPOIFSFileSystem
       DocumentEntry miniDoc;
       DocumentEntry normDoc;
       
-      // Initially has a BAT but not SBAT
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
+      // Initially has Properties + BAT but not SBAT
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(2));
       
       // Check that the SBAT is empty
       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
       
-      // Check that no properties table has been written yet
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs._get_property_table().getStartBlock());
+      // Check that properties table was given block 0
+      assertEquals(0, fs._get_property_table().getStartBlock());
 
       // Write and read it
       fs = writeOutAndReadBack(fs);
       
-      // Property table entries have been added to the blocks 
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
-      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(3));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
-      assertEquals(2, fs._get_property_table().getStartBlock());
+      // No change, SBAT remains empty 
+      assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+      assertEquals(POIFSConstants.UNUSED_BLOCK,     fs.getNextBlock(2));
+      assertEquals(POIFSConstants.UNUSED_BLOCK,     fs.getNextBlock(3));
+      assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getRoot().getProperty().getStartBlock());
+      assertEquals(0, fs._get_property_table().getStartBlock());
 
       
       // Put everything within a new directory
@@ -967,19 +968,19 @@ public final class TestNPOIFSFileSystem
       main4096[4095] = -11;
       testDir.createDocument("Normal4096", new ByteArrayInputStream(main4096));
 
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
+      assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+      assertEquals(3, fs.getNextBlock(2));
       assertEquals(4, fs.getNextBlock(3));
       assertEquals(5, fs.getNextBlock(4));
       assertEquals(6, fs.getNextBlock(5));
       assertEquals(7, fs.getNextBlock(6));
       assertEquals(8, fs.getNextBlock(7));
       assertEquals(9, fs.getNextBlock(8));
-      assertEquals(10, fs.getNextBlock(9));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(10));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(10));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(11));
-      
+      // SBAT still unused
       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
 
       
@@ -989,18 +990,18 @@ public final class TestNPOIFSFileSystem
       main5124[5123] = -33;
       testDir.createDocument("Normal5124", new ByteArrayInputStream(main5124));
 
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
+      assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+      assertEquals(3, fs.getNextBlock(2));
       assertEquals(4, fs.getNextBlock(3));
       assertEquals(5, fs.getNextBlock(4));
       assertEquals(6, fs.getNextBlock(5));
       assertEquals(7, fs.getNextBlock(6));
       assertEquals(8, fs.getNextBlock(7));
       assertEquals(9, fs.getNextBlock(8));
-      assertEquals(10, fs.getNextBlock(9));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(10));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9));
 
+      assertEquals(11, fs.getNextBlock(10));
       assertEquals(12, fs.getNextBlock(11));
       assertEquals(13, fs.getNextBlock(12));
       assertEquals(14, fs.getNextBlock(13));
@@ -1010,8 +1011,8 @@ public final class TestNPOIFSFileSystem
       assertEquals(18, fs.getNextBlock(17));
       assertEquals(19, fs.getNextBlock(18));
       assertEquals(20, fs.getNextBlock(19));
-      assertEquals(21, fs.getNextBlock(20));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(20));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(21));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(22));
 
       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
@@ -1022,18 +1023,18 @@ public final class TestNPOIFSFileSystem
       testDir.createDocument("Mini", new ByteArrayInputStream(mini));
       
       // Mini stream will get one block for fat + one block for data
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
+      assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+      assertEquals(3, fs.getNextBlock(2));
       assertEquals(4, fs.getNextBlock(3));
       assertEquals(5, fs.getNextBlock(4));
       assertEquals(6, fs.getNextBlock(5));
       assertEquals(7, fs.getNextBlock(6));
       assertEquals(8, fs.getNextBlock(7));
       assertEquals(9, fs.getNextBlock(8));
-      assertEquals(10, fs.getNextBlock(9));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(10));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9));
 
+      assertEquals(11, fs.getNextBlock(10));
       assertEquals(12, fs.getNextBlock(11));
       assertEquals(13, fs.getNextBlock(12));
       assertEquals(14, fs.getNextBlock(13));
@@ -1043,15 +1044,14 @@ public final class TestNPOIFSFileSystem
       assertEquals(18, fs.getNextBlock(17));
       assertEquals(19, fs.getNextBlock(18));
       assertEquals(20, fs.getNextBlock(19));
-      assertEquals(21, fs.getNextBlock(20));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(20));
       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21));
       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23));
-      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(23));
 
       // Check the mini stream location was set
-      // (22 is mini fat, 23 is first mini stream block)
-      assertEquals(23, fs.getRoot().getProperty().getStartBlock());
+      // (21 is mini fat, 22 is first mini stream block)
+      assertEquals(22, fs.getRoot().getProperty().getStartBlock());
       
       
       // Write and read back
@@ -1060,28 +1060,28 @@ public final class TestNPOIFSFileSystem
       
       // Check the header has the right points in it
       assertEquals(1, header.getBATCount());
-      assertEquals(0, header.getBATArray()[0]);
-      assertEquals(2, header.getPropertyStart());
+      assertEquals(1, header.getBATArray()[0]);
+      assertEquals(0, header.getPropertyStart());
       assertEquals(1, header.getSBATCount());
-      assertEquals(22, header.getSBATStart());
-      assertEquals(23, fs._get_property_table().getRoot().getStartBlock());
+      assertEquals(21, header.getSBATStart());
+      assertEquals(22, fs._get_property_table().getRoot().getStartBlock());
       
       // Block use should be almost the same, except the properties
       //  stream will have grown out to cover 2 blocks
       // Check the block use is all unchanged
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
-      assertEquals(24, fs.getNextBlock(2)); // Properties now extends over 2 blocks
+      assertEquals(23, fs.getNextBlock(0)); // Properties now extends over 2 blocks
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
       
+      assertEquals(3, fs.getNextBlock(2));
       assertEquals(4, fs.getNextBlock(3));
       assertEquals(5, fs.getNextBlock(4));
       assertEquals(6, fs.getNextBlock(5));
       assertEquals(7, fs.getNextBlock(6));
       assertEquals(8, fs.getNextBlock(7));
       assertEquals(9, fs.getNextBlock(8));
-      assertEquals(10, fs.getNextBlock(9));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(10)); // End of normal4096
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9)); // End of normal4096
 
+      assertEquals(11, fs.getNextBlock(10));
       assertEquals(12, fs.getNextBlock(11));
       assertEquals(13, fs.getNextBlock(12));
       assertEquals(14, fs.getNextBlock(13));
@@ -1091,13 +1091,12 @@ public final class TestNPOIFSFileSystem
       assertEquals(18, fs.getNextBlock(17));
       assertEquals(19, fs.getNextBlock(18));
       assertEquals(20, fs.getNextBlock(19));
-      assertEquals(21, fs.getNextBlock(20));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21)); // End of normal5124 
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(20)); // End of normal5124 
       
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22)); // Mini Stream FAT
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23)); // Mini Stream data
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(24)); // Properties #2
-      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(25));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21)); // Mini Stream FAT
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22)); // Mini Stream data
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23)); // Properties #2
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24));
 
       
       // Check some data
@@ -1123,19 +1122,19 @@ public final class TestNPOIFSFileSystem
       // Check - will have un-used sectors now
       fs = writeOutAndReadBack(fs);
       
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2)); // Props back in 1 block
+      assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0)); // Props back in 1 block
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
       
+      assertEquals(3, fs.getNextBlock(2));
       assertEquals(4, fs.getNextBlock(3));
       assertEquals(5, fs.getNextBlock(4));
       assertEquals(6, fs.getNextBlock(5));
       assertEquals(7, fs.getNextBlock(6));
       assertEquals(8, fs.getNextBlock(7));
       assertEquals(9, fs.getNextBlock(8));
-      assertEquals(10, fs.getNextBlock(9));
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(10)); // End of normal4096
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9)); // End of normal4096
 
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(10));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(11));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(12));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(13));
@@ -1146,11 +1145,11 @@ public final class TestNPOIFSFileSystem
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(18));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(19));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(20));
-      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(21));
       
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22)); // Mini Stream FAT
-      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23)); // Mini Stream data
-      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24)); // Properties gone
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21)); // Mini Stream FAT
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22)); // Mini Stream data
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(23)); // Properties gone
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24));
       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(25));
       
       // All done
@@ -1164,20 +1163,20 @@ public final class TestNPOIFSFileSystem
        DocumentEntry normDoc;
        HeaderBlock hdr;
        
-       // Initially has BAT + Properties but nothing else
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
+       // Initially has Properties + BAT but nothing else
+       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
        assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(2));
        
        hdr = writeOutAndReadHeader(fs);
        // No mini stream, and no xbats
        // Will have fat then properties stream
        assertEquals(1, hdr.getBATCount());
-       assertEquals(0, hdr.getBATArray()[0]);
-       assertEquals(2, hdr.getPropertyStart());
+       assertEquals(1, hdr.getBATArray()[0]);
+       assertEquals(0, hdr.getPropertyStart());
        assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getSBATStart());
        assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getXBATIndex());
-       assertEquals(POIFSConstants.SMALLER_BIG_BLOCK_SIZE*4, fs.size());
+       assertEquals(POIFSConstants.SMALLER_BIG_BLOCK_SIZE*3, fs.size());
        
        
        // Get a clean filesystem to start with
@@ -1200,8 +1199,8 @@ public final class TestNPOIFSFileSystem
 
        
        // Check the mini stream was added, then the main stream
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1)); 
+       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1)); 
        assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2)); // Mini Fat
        assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(3)); // Mini Stream
        assertEquals(5,                           fs.getNextBlock(4)); // Main Stream
@@ -1231,15 +1230,15 @@ public final class TestNPOIFSFileSystem
        // Check the header details - will have the sbat near the start,
        //  then the properties at the end
        assertEquals(1, hdr.getBATCount());
-       assertEquals(0, hdr.getBATArray()[0]);
+       assertEquals(1, hdr.getBATArray()[0]);
        assertEquals(2, hdr.getSBATStart());
-       assertEquals(12, hdr.getPropertyStart());
+       assertEquals(0, hdr.getPropertyStart());
        assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getXBATIndex());
        
        // Check the block allocation is unchanged, other than
        //  the properties stream going in at the end
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
+       assertEquals(12,                          fs.getNextBlock(0)); // Properties
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
        assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
        assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(3));
        assertEquals(5,                           fs.getNextBlock(4));
@@ -1250,10 +1249,9 @@ public final class TestNPOIFSFileSystem
        assertEquals(10,                          fs.getNextBlock(9));
        assertEquals(11,                          fs.getNextBlock(10));
        assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(11));
-       assertEquals(13,                          fs.getNextBlock(12));
-       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(13));
-       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(14));
-       assertEquals(POIFSConstants.SMALLER_BIG_BLOCK_SIZE*15, fs.size());
+       assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(12));
+       assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(13));
+       assertEquals(POIFSConstants.SMALLER_BIG_BLOCK_SIZE*14, fs.size());
        
        
        // Check the data
@@ -1304,6 +1302,138 @@ public final class TestNPOIFSFileSystem
 
        normDoc = (DocumentEntry)testDir.getEntry("Normal4106");
        assertContentsMatches(main4106, normDoc);
+       
+       // All done
+       fs.close();
+   }
+   
+   @Test
+   public void readZeroLengthEntries() throws Exception {
+       NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("only-zero-byte-streams.ole2"));
+       DirectoryNode testDir = fs.getRoot();
+       assertEquals(3, testDir.getEntryCount());
+       DocumentEntry entry;
+       
+       entry = (DocumentEntry)testDir.getEntry("test-zero-1");
+       assertNotNull(entry);
+       assertEquals(0, entry.getSize());
+       
+       entry = (DocumentEntry)testDir.getEntry("test-zero-2");
+       assertNotNull(entry);
+       assertEquals(0, entry.getSize());
+       
+       entry = (DocumentEntry)testDir.getEntry("test-zero-3");
+       assertNotNull(entry);
+       assertEquals(0, entry.getSize());
+       
+       // Check properties, all have zero length, no blocks
+       NPropertyTable props = fs._get_property_table();
+       assertEquals(POIFSConstants.END_OF_CHAIN, props.getRoot().getStartBlock());
+       for (Property prop : props.getRoot()) {
+           assertEquals("test-zero-", prop.getName().substring(0, 10));
+           assertEquals(POIFSConstants.END_OF_CHAIN, prop.getStartBlock());
+       }
+       
+       // All done
+       fs.close();
+   }
+   
+   @Test
+   public void writeZeroLengthEntries() throws Exception {
+       NPOIFSFileSystem fs = new NPOIFSFileSystem();
+       DirectoryNode testDir = fs.getRoot();
+       DocumentEntry miniDoc;
+       DocumentEntry normDoc;
+       DocumentEntry emptyDoc;
+       
+       // Add mini and normal sized entries to start
+       byte[] mini2 = new byte[] { -42, 0, -1, -2, -3, -4, -42 };
+       testDir.createDocument("Mini2", new ByteArrayInputStream(mini2));
+       
+       // Add to the main stream
+       byte[] main4106 = new byte[4106];
+       main4106[0] = 41;
+       main4106[4105] = 42;
+       testDir.createDocument("Normal4106", new ByteArrayInputStream(main4106));
+       
+       // Now add some empty ones
+       byte[] empty = new byte[0];
+       testDir.createDocument("empty-1", new ByteArrayInputStream(empty));
+       testDir.createDocument("empty-2", new ByteArrayInputStream(empty));
+       testDir.createDocument("empty-3", new ByteArrayInputStream(empty));
+       
+       // Check
+       miniDoc = (DocumentEntry)testDir.getEntry("Mini2");
+       assertContentsMatches(mini2, miniDoc);
+
+       normDoc = (DocumentEntry)testDir.getEntry("Normal4106");
+       assertContentsMatches(main4106, normDoc);
+       
+       emptyDoc = (DocumentEntry)testDir.getEntry("empty-1");
+       assertContentsMatches(empty, emptyDoc);
+       
+       emptyDoc = (DocumentEntry)testDir.getEntry("empty-2");
+       assertContentsMatches(empty, emptyDoc);
+       
+       emptyDoc = (DocumentEntry)testDir.getEntry("empty-3");
+       assertContentsMatches(empty, emptyDoc);
+       
+       // Look at the properties entry, and check the empty ones
+       //  have zero size and no start block
+       NPropertyTable props = fs._get_property_table();
+       Iterator<Property> propsIt = props.getRoot().getChildren();
+       
+       Property prop = propsIt.next();
+       assertEquals("Mini2", prop.getName());
+       assertEquals(0, prop.getStartBlock());
+       assertEquals(7, prop.getSize());
+       
+       prop = propsIt.next();
+       assertEquals("Normal4106", prop.getName());
+       assertEquals(4, prop.getStartBlock()); // BAT, Props, SBAT, MIni
+       assertEquals(4106, prop.getSize());
+       
+       prop = propsIt.next();
+       assertEquals("empty-1", prop.getName());
+       assertEquals(POIFSConstants.END_OF_CHAIN, prop.getStartBlock());
+       assertEquals(0, prop.getSize());
+       
+       prop = propsIt.next();
+       assertEquals("empty-2", prop.getName());
+       assertEquals(POIFSConstants.END_OF_CHAIN, prop.getStartBlock());
+       assertEquals(0, prop.getSize());
+       
+       prop = propsIt.next();
+       assertEquals("empty-3", prop.getName());
+       assertEquals(POIFSConstants.END_OF_CHAIN, prop.getStartBlock());
+       assertEquals(0, prop.getSize());
+       
+       
+       // Save and re-check
+       fs = writeOutAndReadBack(fs);
+       testDir = fs.getRoot();
+       
+       miniDoc = (DocumentEntry)testDir.getEntry("Mini2");
+       assertContentsMatches(mini2, miniDoc);
+
+       normDoc = (DocumentEntry)testDir.getEntry("Normal4106");
+       assertContentsMatches(main4106, normDoc);
+       
+       emptyDoc = (DocumentEntry)testDir.getEntry("empty-1");
+       assertContentsMatches(empty, emptyDoc);
+       
+       emptyDoc = (DocumentEntry)testDir.getEntry("empty-2");
+       assertContentsMatches(empty, emptyDoc);
+       
+       emptyDoc = (DocumentEntry)testDir.getEntry("empty-3");
+       assertContentsMatches(empty, emptyDoc);
+       
+       // Check that a mini-stream was assigned, with one block used
+       assertEquals(3, testDir.getProperty().getStartBlock()); 
+       assertEquals(64, testDir.getProperty().getSize()); 
+       
+       // All done
+       fs.close();
    }
 
    /**

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java Sun Jul 19 19:00:32 2015
@@ -17,18 +17,19 @@
 
 package org.apache.poi.poifs.filesystem;
 
+import java.io.ByteArrayInputStream;
 import java.nio.ByteBuffer;
 import java.util.Iterator;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.POIDataSamples;
+import org.apache.poi.POITestCase;
 import org.apache.poi.poifs.common.POIFSConstants;
+import org.apache.poi.util.IOUtils;
 
 /**
  * Tests for the Mini Store in the NIO POIFS
  */
-public final class TestNPOIFSMiniStore extends TestCase {
+public final class TestNPOIFSMiniStore extends POITestCase {
    private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance();
    
    /**
@@ -332,4 +333,130 @@ public final class TestNPOIFSMiniStore e
       
       fs.close();
    }
+   
+   public void testCreateMiniStoreFirst() throws Exception {
+       NPOIFSFileSystem fs = new NPOIFSFileSystem();
+       NPOIFSMiniStore ministore = fs.getMiniStore();
+       DocumentInputStream dis;
+       DocumentEntry entry;
+
+       // Initially has Properties + BAT but nothing else
+       assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+       assertEquals(POIFSConstants.UNUSED_BLOCK,     fs.getNextBlock(2));
+       // Ministore has no blocks, so can't iterate until used
+       try {
+           ministore.getNextBlock(0);
+       } catch (IndexOutOfBoundsException e) {}
+       
+       // Write a very small new document, will populate the ministore for us
+       byte[] data = new byte[8];
+       for (int i=0; i<data.length; i++) {
+           data[i] = (byte)(i+42);
+       }
+       fs.getRoot().createDocument("mini", new ByteArrayInputStream(data));
+       
+       // Should now have a mini-fat and a mini-stream
+       assertEquals(POIFSConstants.END_OF_CHAIN,    fs.getNextBlock(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,fs.getNextBlock(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN,    fs.getNextBlock(2));
+       assertEquals(POIFSConstants.END_OF_CHAIN,    fs.getNextBlock(3));
+       assertEquals(POIFSConstants.UNUSED_BLOCK,    fs.getNextBlock(4));
+       assertEquals(POIFSConstants.END_OF_CHAIN,    ministore.getNextBlock(0));
+       assertEquals(POIFSConstants.UNUSED_BLOCK,    ministore.getNextBlock(1));
+       
+       // Re-fetch the mini store, and add it a second time
+       ministore = fs.getMiniStore();
+       fs.getRoot().createDocument("mini2", new ByteArrayInputStream(data));
+       
+       // Main unchanged, ministore has a second
+       assertEquals(POIFSConstants.END_OF_CHAIN,    fs.getNextBlock(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,fs.getNextBlock(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN,    fs.getNextBlock(2));
+       assertEquals(POIFSConstants.END_OF_CHAIN,    fs.getNextBlock(3));
+       assertEquals(POIFSConstants.UNUSED_BLOCK,    fs.getNextBlock(4));
+       assertEquals(POIFSConstants.END_OF_CHAIN,    ministore.getNextBlock(0));
+       assertEquals(POIFSConstants.END_OF_CHAIN,    ministore.getNextBlock(1));
+       assertEquals(POIFSConstants.UNUSED_BLOCK,    ministore.getNextBlock(2));
+       
+       // Check the data is unchanged and the right length
+       entry = (DocumentEntry)fs.getRoot().getEntry("mini");
+       assertEquals(data.length, entry.getSize());
+       byte[] rdata = new byte[data.length];
+       dis = new DocumentInputStream(entry);
+       IOUtils.readFully(dis, rdata);
+       assertEquals(data, rdata);
+       dis.close();
+       
+       entry = (DocumentEntry)fs.getRoot().getEntry("mini2");
+       assertEquals(data.length, entry.getSize());
+       rdata = new byte[data.length];
+       dis = new DocumentInputStream(entry);
+       IOUtils.readFully(dis, rdata);
+       assertEquals(data, rdata);
+       dis.close();
+
+       // Done
+       fs.close();
+   }
+   
+   public void testMultiBlockStream() throws Exception {
+       byte[] data1B = new byte[63];
+       byte[] data2B = new byte[64+14];
+       for (int i=0; i<data1B.length; i++) {
+           data1B[i] = (byte)(i+2);
+       }
+       for (int i=0; i<data2B.length; i++) {
+           data2B[i] = (byte)(i+4);
+       }
+       
+       // New filesystem and store to use
+       NPOIFSFileSystem fs = new NPOIFSFileSystem();
+       NPOIFSMiniStore ministore = fs.getMiniStore();
+
+       // Initially has Properties + BAT but nothing else
+       assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+       assertEquals(POIFSConstants.UNUSED_BLOCK,     fs.getNextBlock(2));
+       
+       // Store the 2 block one, should use 2 mini blocks, and request
+       // the use of 2 big blocks
+       ministore = fs.getMiniStore();
+       fs.getRoot().createDocument("mini2", new ByteArrayInputStream(data2B));
+       
+       // Check
+       assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(2)); // SBAT
+       assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(3)); // Mini
+       assertEquals(POIFSConstants.UNUSED_BLOCK,     fs.getNextBlock(4));
+       
+       // First 2 Mini blocks will be used
+       assertEquals(2, ministore.getFreeBlock());
+       
+       // Add one more mini-stream, and check
+       fs.getRoot().createDocument("mini1", new ByteArrayInputStream(data1B));
+       
+       assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(2)); // SBAT
+       assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(3)); // Mini
+       assertEquals(POIFSConstants.UNUSED_BLOCK,     fs.getNextBlock(4));
+       
+       // One more mini-block will be used
+       assertEquals(3, ministore.getFreeBlock());
+       
+       // Check the contents too
+       byte[] r1 = new byte[data1B.length];
+       DocumentInputStream dis = fs.createDocumentInputStream("mini1");
+       IOUtils.readFully(dis, r1);
+       dis.close();
+       assertEquals(data1B, r1);
+       
+       byte[] r2 = new byte[data2B.length];
+       dis = fs.createDocumentInputStream("mini2");
+       IOUtils.readFully(dis, r2);
+       dis.close();
+       assertEquals(data2B, r2);
+   }
 }

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java Sun Jul 19 19:00:32 2015
@@ -860,12 +860,12 @@ public final class TestNPOIFSStream exte
       NPOIFSFileSystem fs = new NPOIFSFileSystem();
       NPOIFSStream stream = new NPOIFSStream(fs);
       
-      // Check our filesystem has a BAT and the Properties
+      // Check our filesystem has Properties then BAT
       assertEquals(2, fs.getFreeBlock());
       BATBlock bat = fs.getBATBlockAndIndex(0).getBlock();
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
-      assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(2));
+      assertEquals(POIFSConstants.END_OF_CHAIN,    bat.getValueAt(0));
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
+      assertEquals(POIFSConstants.UNUSED_BLOCK,    bat.getValueAt(2));
       
       // Check the stream as-is
       assertEquals(POIFSConstants.END_OF_CHAIN, stream.getStartBlock());
@@ -887,11 +887,11 @@ public final class TestNPOIFSStream exte
       // Check now
       assertEquals(4, fs.getFreeBlock());
       bat = fs.getBATBlockAndIndex(0).getBlock();
-      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-      assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
-      assertEquals(3,                           bat.getValueAt(2));
-      assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3));
-      assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(4));
+      assertEquals(POIFSConstants.END_OF_CHAIN,    bat.getValueAt(0));
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
+      assertEquals(3,                              bat.getValueAt(2));
+      assertEquals(POIFSConstants.END_OF_CHAIN,    bat.getValueAt(3));
+      assertEquals(POIFSConstants.UNUSED_BLOCK,    bat.getValueAt(4));
       
       
       Iterator<ByteBuffer> it = stream.getBlockIterator();
@@ -927,11 +927,11 @@ public final class TestNPOIFSStream exte
    public void testWriteThenReplace() throws Exception {
        NPOIFSFileSystem fs = new NPOIFSFileSystem();
 
-       // Starts empty
+       // Starts empty, other that Properties and BAT
        BATBlock bat = fs.getBATBlockAndIndex(0).getBlock();
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
-       assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(2));
+       assertEquals(POIFSConstants.END_OF_CHAIN,    bat.getValueAt(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
+       assertEquals(POIFSConstants.UNUSED_BLOCK,    bat.getValueAt(2));
 
        // Write something that uses a main stream
        byte[] main4106 = new byte[4106];
@@ -941,8 +941,8 @@ public final class TestNPOIFSStream exte
                "Normal", new ByteArrayInputStream(main4106));
        
        // Should have used 9 blocks
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
        assertEquals(3,                           bat.getValueAt(2));
        assertEquals(4,                           bat.getValueAt(3));
        assertEquals(5,                           bat.getValueAt(4));
@@ -969,8 +969,8 @@ public final class TestNPOIFSStream exte
        nout.close();
        
        // Will have dropped to 8
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
        assertEquals(3,                           bat.getValueAt(2));
        assertEquals(4,                           bat.getValueAt(3));
        assertEquals(5,                           bat.getValueAt(4));
@@ -991,9 +991,9 @@ public final class TestNPOIFSStream exte
        fs = writeOutAndReadBack(fs);
        bat = fs.getBATBlockAndIndex(0).getBlock();
        
-       // Will have properties, but otherwise the same
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+       // No change after write
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0)); // Properties
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
        assertEquals(3,                           bat.getValueAt(2));
        assertEquals(4,                           bat.getValueAt(3));
        assertEquals(5,                           bat.getValueAt(4));
@@ -1002,7 +1002,7 @@ public final class TestNPOIFSStream exte
        assertEquals(8,                           bat.getValueAt(7));
        assertEquals(9,                           bat.getValueAt(8));
        assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(9)); // End of Normal
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
+       assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(10));
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11));
        
        normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
@@ -1010,14 +1010,14 @@ public final class TestNPOIFSStream exte
        assertEquals(4096, ((DocumentNode)normal).getProperty().getSize());
        
        
-       // Make longer, take 1 block after the properties too
+       // Make longer, take 1 block at the end
        normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
        nout = new NDocumentOutputStream(normal);
        nout.write(main4106);
        nout.close();
 
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
        assertEquals(3,                           bat.getValueAt(2));
        assertEquals(4,                           bat.getValueAt(3));
        assertEquals(5,                           bat.getValueAt(4));
@@ -1025,9 +1025,9 @@ public final class TestNPOIFSStream exte
        assertEquals(7,                           bat.getValueAt(6));
        assertEquals(8,                           bat.getValueAt(7));
        assertEquals(9,                           bat.getValueAt(8));
-       assertEquals(11,                          bat.getValueAt(9));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(11)); // Normal
+       assertEquals(10,                          bat.getValueAt(9));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Normal
+       assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11));
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12));
        
        normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
@@ -1042,8 +1042,8 @@ public final class TestNPOIFSStream exte
        nout.write(mini);
        nout.close();
        
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(1));
        assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(2)); // SBAT
        assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3)); // Mini Stream
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(4));
@@ -1052,7 +1052,7 @@ public final class TestNPOIFSStream exte
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(7));
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(8));
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(9));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
+       assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(10));
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11));
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12));
        
@@ -1067,8 +1067,8 @@ public final class TestNPOIFSStream exte
        nout.close();
        
        // Will keep the mini stream, now empty
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(1));
        assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(2)); // SBAT
        assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3)); // Mini Stream
        assertEquals(5,                           bat.getValueAt(4));
@@ -1076,10 +1076,10 @@ public final class TestNPOIFSStream exte
        assertEquals(7,                           bat.getValueAt(6));
        assertEquals(8,                           bat.getValueAt(7));
        assertEquals(9,                           bat.getValueAt(8));
-       assertEquals(11,                          bat.getValueAt(9));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
-       assertEquals(12,                          bat.getValueAt(11));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(12));
+       assertEquals(10,                          bat.getValueAt(9));
+       assertEquals(11,                          bat.getValueAt(10));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(11));
+       assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12));
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(13));
        
        normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
@@ -1091,8 +1091,8 @@ public final class TestNPOIFSStream exte
        fs = writeOutAndReadBack(fs);
        bat = fs.getBATBlockAndIndex(0).getBlock();
        
-       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+       assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(1));
        assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(2)); // SBAT
        assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3)); // Mini Stream
        assertEquals(5,                           bat.getValueAt(4));
@@ -1100,10 +1100,10 @@ public final class TestNPOIFSStream exte
        assertEquals(7,                           bat.getValueAt(6));
        assertEquals(8,                           bat.getValueAt(7));
        assertEquals(9,                           bat.getValueAt(8));
-       assertEquals(11,                          bat.getValueAt(9));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
-       assertEquals(12,                          bat.getValueAt(11));
-       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(12));
+       assertEquals(10,                          bat.getValueAt(9));
+       assertEquals(11,                          bat.getValueAt(10));
+       assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(11));
+       assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12));
        assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(13));
        
        normal = (DocumentEntry)fs.getRoot().getEntry("Normal");

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java Sun Jul 19 19:00:32 2015
@@ -22,7 +22,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
-import java.util.Iterator;
 
 import junit.framework.TestCase;
 
@@ -36,13 +35,10 @@ import org.apache.poi.poifs.storage.Head
 import org.apache.poi.poifs.storage.RawDataBlockList;
 
 /**
- * Tests for POIFSFileSystem
- *
- * @author Josh Micich
+ * Tests for the older OPOIFS-based POIFSFileSystem
  */
 public final class TestPOIFSFileSystem extends TestCase {
    private POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
-   
 
 	/**
 	 * Mock exception used to ensure correct error handling
@@ -108,7 +104,7 @@ public final class TestPOIFSFileSystem e
 		// Normal case - read until EOF and close
 		testIS = new TestIS(openSampleStream("13224.xls"), -1);
 		try {
-			new POIFSFileSystem(testIS);
+			new OPOIFSFileSystem(testIS);
 		} catch (IOException e) {
 			throw new RuntimeException(e);
 		}
@@ -117,7 +113,7 @@ public final class TestPOIFSFileSystem e
 		// intended to crash after reading 10000 bytes
 		testIS = new TestIS(openSampleStream("13224.xls"), 10000);
 		try {
-			new POIFSFileSystem(testIS);
+			new OPOIFSFileSystem(testIS);
 			fail("ex should have been thrown");
 		} catch (IOException e) {
 			throw new RuntimeException(e);
@@ -145,7 +141,7 @@ public final class TestPOIFSFileSystem e
 
 		for(int i=0; i<files.length; i++) {
 			// Open the file up
-			POIFSFileSystem fs = new POIFSFileSystem(
+			OPOIFSFileSystem fs = new OPOIFSFileSystem(
 			    _samples.openResourceAsStream(files[i])
 			);
 
@@ -167,7 +163,7 @@ public final class TestPOIFSFileSystem e
         try {
             InputStream stream = _samples.openResourceAsStream("ReferencesInvalidSectors.mpp");
             try {
-                new POIFSFileSystem(stream);
+                new OPOIFSFileSystem(stream);
                 fail("File is corrupt and shouldn't have been opened");
             } finally {
                 stream.close();
@@ -186,7 +182,7 @@ public final class TestPOIFSFileSystem e
 	 */
 	public void testBATandXBAT() throws Exception {
 	   byte[] hugeStream = new byte[8*1024*1024];
-	   POIFSFileSystem fs = new POIFSFileSystem();
+	   OPOIFSFileSystem fs = new OPOIFSFileSystem();
 	   fs.getRoot().createDocument(
 	         "BIG", new ByteArrayInputStream(hugeStream)
 	   );
@@ -230,7 +226,7 @@ public final class TestPOIFSFileSystem e
       
 	   // Now load it and check
 	   fs = null;
-	   fs = new POIFSFileSystem(
+	   fs = new OPOIFSFileSystem(
 	         new ByteArrayInputStream(fsData)
 	   );
 	   
@@ -264,7 +260,7 @@ public final class TestPOIFSFileSystem e
             assertEquals(15, data_blocks.blockCount());
 
             // Now try and open properly
-            POIFSFileSystem fs = new POIFSFileSystem(
+            OPOIFSFileSystem fs = new OPOIFSFileSystem(
                     _samples.openResourceAsStream("BlockSize4096.zvi"));
             assertTrue(fs.getRoot().getEntryCount() > 3);
 
@@ -272,7 +268,7 @@ public final class TestPOIFSFileSystem e
             checkAllDirectoryContents(fs.getRoot());
 
             // Finally, check we can do a similar 512byte one too
-            fs = new POIFSFileSystem(
+            fs = new OPOIFSFileSystem(
                     _samples.openResourceAsStream("BlockSize512.zvi"));
             assertTrue(fs.getRoot().getEntryCount() > 3);
             checkAllDirectoryContents(fs.getRoot());
@@ -297,43 +293,6 @@ public final class TestPOIFSFileSystem e
 	      }
 	   }
 	}
-	
-	/**
-	 * Test that we can open files that come via Lotus notes.
-	 * These have a top level directory without a name....
-	 */
-	public void testNotesOLE2Files() throws Exception {
-      POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
-      
-      // Open the file up
-      POIFSFileSystem fs = new POIFSFileSystem(
-          _samples.openResourceAsStream("Notes.ole2")
-      );
-      
-      // Check the contents
-      assertEquals(1, fs.getRoot().getEntryCount());
-      
-      Entry entry = fs.getRoot().getEntries().next();
-      assertTrue(entry.isDirectoryEntry());
-      assertTrue(entry instanceof DirectoryEntry);
-      
-      // The directory lacks a name!
-      DirectoryEntry dir = (DirectoryEntry)entry;
-      assertEquals("", dir.getName());
-      
-      // Has two children
-      assertEquals(2, dir.getEntryCount());
-      
-      // Check them
-      Iterator<Entry> it = dir.getEntries();
-      entry = it.next();
-      assertEquals(true, entry.isDocumentEntry());
-      assertEquals("\u0001Ole10Native", entry.getName());
-      
-      entry = it.next();
-      assertEquals(true, entry.isDocumentEntry());
-      assertEquals("\u0001CompObj", entry.getName());
-	}
 
 	private static InputStream openSampleStream(String sampleFileName) {
 		return HSSFTestDataSamples.openSampleFileStream(sampleFileName);

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestBATBlock.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestBATBlock.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestBATBlock.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestBATBlock.java Sun Jul 19 19:00:32 2015
@@ -26,6 +26,7 @@ import java.util.List;
 
 import junit.framework.TestCase;
 
+import org.apache.poi.poifs.common.POIFSBigBlockSize;
 import org.apache.poi.poifs.common.POIFSConstants;
 
 /**
@@ -283,6 +284,59 @@ public final class TestBATBlock extends
        );
     }
     
+    public void testUsedSectors() throws Exception {
+        POIFSBigBlockSize b512 = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS;
+        POIFSBigBlockSize b4096 = POIFSConstants.LARGER_BIG_BLOCK_SIZE_DETAILS;
+        
+        // Try first with 512 block sizes, which can hold 128 entries
+        BATBlock block512 = BATBlock.createEmptyBATBlock(b512, false);
+        assertEquals(true, block512.hasFreeSectors());
+        assertEquals(0, block512.getUsedSectors(false));
+
+        // Allocate a few
+        block512.setValueAt(0, 42);
+        block512.setValueAt(10, 42);
+        block512.setValueAt(20, 42);
+        assertEquals(true, block512.hasFreeSectors());
+        assertEquals(3, block512.getUsedSectors(false));
+        
+        // Allocate all
+        for (int i=0; i<b512.getBATEntriesPerBlock(); i++) {
+            block512.setValueAt(i, 82);
+        }
+        // Check
+        assertEquals(false, block512.hasFreeSectors());
+        assertEquals(128, block512.getUsedSectors(false));
+        assertEquals(127, block512.getUsedSectors(true));
+        
+        // Release one
+        block512.setValueAt(10, POIFSConstants.UNUSED_BLOCK);
+        assertEquals(true, block512.hasFreeSectors());
+        assertEquals(127, block512.getUsedSectors(false));
+        assertEquals(126, block512.getUsedSectors(true));
+        
+        
+        // Now repeat with 4096 block sizes
+        BATBlock block4096 = BATBlock.createEmptyBATBlock(b4096, false);
+        assertEquals(true, block4096.hasFreeSectors());
+        assertEquals(0, block4096.getUsedSectors(false));
+        
+        block4096.setValueAt(0, 42);
+        block4096.setValueAt(10, 42);
+        block4096.setValueAt(20, 42);
+        assertEquals(true, block4096.hasFreeSectors());
+        assertEquals(3, block4096.getUsedSectors(false));
+        
+        // Allocate all
+        for (int i=0; i<b4096.getBATEntriesPerBlock(); i++) {
+            block4096.setValueAt(i, 82);
+        }
+        // Check
+        assertEquals(false, block4096.hasFreeSectors());
+        assertEquals(1024, block4096.getUsedSectors(false));
+        assertEquals(1023, block4096.getUsedSectors(true));
+    }
+    
     public void testGetBATBlockAndIndex() throws Exception {
        HeaderBlock header = new HeaderBlock(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS);
        List<BATBlock> blocks = new ArrayList<BATBlock>();

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestSmallBlockTableWriter.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestSmallBlockTableWriter.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestSmallBlockTableWriter.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestSmallBlockTableWriter.java Sun Jul 19 19:00:32 2015
@@ -25,7 +25,7 @@ import java.util.List;
 import junit.framework.TestCase;
 
 import org.apache.poi.poifs.common.POIFSConstants;
-import org.apache.poi.poifs.filesystem.POIFSDocument;
+import org.apache.poi.poifs.filesystem.OPOIFSDocument;
 import org.apache.poi.poifs.property.PropertyTable;
 import org.apache.poi.poifs.property.RootProperty;
 
@@ -37,43 +37,43 @@ import org.apache.poi.poifs.property.Roo
 public final class TestSmallBlockTableWriter extends TestCase {
 
     public void testWritingConstructor() throws IOException {
-        List<POIFSDocument> documents = new ArrayList<POIFSDocument>();
+        List<OPOIFSDocument> documents = new ArrayList<OPOIFSDocument>();
 
         documents.add(
-            new POIFSDocument(
+            new OPOIFSDocument(
                 "doc340", new ByteArrayInputStream(new byte[ 340 ])));
         documents.add(
-            new POIFSDocument(
+            new OPOIFSDocument(
                 "doc5000", new ByteArrayInputStream(new byte[ 5000 ])));
         documents
-            .add(new POIFSDocument("doc0",
+            .add(new OPOIFSDocument("doc0",
                                    new ByteArrayInputStream(new byte[ 0 ])));
         documents
-            .add(new POIFSDocument("doc1",
+            .add(new OPOIFSDocument("doc1",
                                    new ByteArrayInputStream(new byte[ 1 ])));
         documents
-            .add(new POIFSDocument("doc2",
+            .add(new OPOIFSDocument("doc2",
                                    new ByteArrayInputStream(new byte[ 2 ])));
         documents
-            .add(new POIFSDocument("doc3",
+            .add(new OPOIFSDocument("doc3",
                                    new ByteArrayInputStream(new byte[ 3 ])));
         documents
-            .add(new POIFSDocument("doc4",
+            .add(new OPOIFSDocument("doc4",
                                    new ByteArrayInputStream(new byte[ 4 ])));
         documents
-            .add(new POIFSDocument("doc5",
+            .add(new OPOIFSDocument("doc5",
                                    new ByteArrayInputStream(new byte[ 5 ])));
         documents
-            .add(new POIFSDocument("doc6",
+            .add(new OPOIFSDocument("doc6",
                                    new ByteArrayInputStream(new byte[ 6 ])));
         documents
-            .add(new POIFSDocument("doc7",
+            .add(new OPOIFSDocument("doc7",
                                    new ByteArrayInputStream(new byte[ 7 ])));
         documents
-            .add(new POIFSDocument("doc8",
+            .add(new OPOIFSDocument("doc8",
                                    new ByteArrayInputStream(new byte[ 8 ])));
         documents
-            .add(new POIFSDocument("doc9",
+            .add(new OPOIFSDocument("doc9",
                                    new ByteArrayInputStream(new byte[ 9 ])));
         
         HeaderBlock              header = new HeaderBlock(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS);

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java Sun Jul 19 19:00:32 2015
@@ -21,13 +21,12 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
-import org.apache.poi.poifs.common.POIFSConstants;
-
 import junit.framework.TestCase;
 
+import org.apache.poi.poifs.common.POIFSConstants;
+
 /**
  * Class to test SmallDocumentBlock functionality
  *
@@ -53,7 +52,7 @@ public final class TestSmallDocumentBloc
         throws IOException
     {
         ByteArrayInputStream stream    = new ByteArrayInputStream(_testdata);
-        List                 documents = new ArrayList();
+        List<DocumentBlock> documents  = new ArrayList<DocumentBlock>();
 
         while (true)
         {
@@ -66,9 +65,8 @@ public final class TestSmallDocumentBloc
             }
         }
         SmallDocumentBlock[] results =
-            SmallDocumentBlock
-                .convert(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS,( BlockWritable [] ) documents
-                    .toArray(new DocumentBlock[ 0 ]), _testdata_size);
+            SmallDocumentBlock.convert(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS,
+                          documents.toArray(new DocumentBlock[ 0 ]), _testdata_size);
 
         assertEquals("checking correct result size: ",
                      (_testdata_size + 63) / 64, results.length);
@@ -142,20 +140,20 @@ public final class TestSmallDocumentBloc
     {
         for (int j = 0; j <= 8; j++)
         {
-            List foo = new ArrayList();
+            List<SmallDocumentBlock> blocks = new ArrayList<SmallDocumentBlock>();
 
             for (int k = 0; k < j; k++)
             {
-                foo.add(new Object());
+                blocks.add(new SmallDocumentBlock(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS));
             }
-            int result = SmallDocumentBlock.fill(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS,foo);
+            int result = SmallDocumentBlock.fill(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, blocks);
 
             assertEquals("correct big block count: ", (j + 7) / 8, result);
             assertEquals("correct small block count: ", 8 * result,
-                         foo.size());
-            for (int m = j; m < foo.size(); m++)
+                         blocks.size());
+            for (int m = j; m < blocks.size(); m++)
             {
-                BlockWritable         block  = ( BlockWritable ) foo.get(m);
+                BlockWritable         block  = blocks.get(m);
                 ByteArrayOutputStream stream = new ByteArrayOutputStream();
 
                 block.writeBlocks(stream);
@@ -208,13 +206,12 @@ public final class TestSmallDocumentBloc
         {
             new RawDataBlock(new ByteArrayInputStream(data))
         };
-        List           output = SmallDocumentBlock.extract(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS,blocks);
-        Iterator       iter   = output.iterator();
+        List<SmallDocumentBlock> output = SmallDocumentBlock.extract(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS,blocks);
 
         offset = 0;
-        while (iter.hasNext())
+        for (SmallDocumentBlock block : output)
         {
-            byte[] out_data = (( SmallDocumentBlock ) iter.next()).getData();
+            byte[] out_data = block.getData();
 
             assertEquals("testing block at offset " + offset, 64,
                          out_data.length);

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java Sun Jul 19 19:00:32 2015
@@ -516,6 +516,7 @@ public final class ExcelFileFormatDocFun
 		ps.println("#Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote )");
 		ps.println("");
 		try {
+		    // can't use ZipHelper here, because its in a different module
 			ZipFile zf = new ZipFile(effDocFile);
 			InputStream is = zf.getInputStream(zf.getEntry("content.xml"));
 			extractFunctionData(new FunctionDataCollector(ps), is);

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/functions/TestSumif.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/functions/TestSumif.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/functions/TestSumif.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/functions/TestSumif.java Sun Jul 19 19:00:32 2015
@@ -21,6 +21,8 @@ import junit.framework.AssertionFailedEr
 import junit.framework.TestCase;
 
 import org.apache.poi.ss.formula.eval.AreaEval;
+import org.apache.poi.ss.formula.eval.BlankEval;
+import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.NumericValueEval;
 import org.apache.poi.ss.formula.eval.StringEval;
@@ -107,4 +109,11 @@ public final class TestSumif extends Tes
 
 		confirmDouble(60, ve);
 	}
+
+	public void testEvaluateException() {
+	    assertEquals(ErrorEval.VALUE_INVALID, invokeSumif(-1, -1, BlankEval.instance, new NumberEval(30.0)));
+        assertEquals(ErrorEval.VALUE_INVALID, invokeSumif(-1, -1, BlankEval.instance, new NumberEval(30.0), new NumberEval(30.0)));
+        assertEquals(ErrorEval.VALUE_INVALID, invokeSumif(-1, -1, new NumberEval(30.0), BlankEval.instance, new NumberEval(30.0)));
+        assertEquals(ErrorEval.VALUE_INVALID, invokeSumif(-1, -1, new NumberEval(30.0), new NumberEval(30.0), BlankEval.instance));
+	}
 }

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/functions/TestSumifs.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/functions/TestSumifs.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/functions/TestSumifs.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/ss/formula/functions/TestSumifs.java Sun Jul 19 19:00:32 2015
@@ -21,6 +21,7 @@ package org.apache.poi.ss.formula.functi
 
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
+
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.formula.OperationEvaluationContext;
@@ -264,4 +265,84 @@ public final class TestSumifs extends Te
         assertEquals(625000., ex5cell.getNumericCellValue());
 
     }
+    
+    public void testBug56655() {
+        ValueEval[] a2a9 = new ValueEval[] {
+                new NumberEval(5),
+                new NumberEval(4),
+                new NumberEval(15),
+                new NumberEval(3),
+                new NumberEval(22),
+                new NumberEval(12),
+                new NumberEval(10),
+                new NumberEval(33)
+        };
+
+        ValueEval[] args = new ValueEval[]{
+                EvalFactory.createAreaEval("A2:A9", a2a9),
+                ErrorEval.VALUE_INVALID,
+                new StringEval("A*"),
+        };
+        
+        ValueEval result = invokeSumifs(args, EC);
+        assertTrue("Expect to have an error when an input is an invalid value, but had: " + result.getClass(), result instanceof ErrorEval);
+
+        args = new ValueEval[]{
+                EvalFactory.createAreaEval("A2:A9", a2a9),
+                EvalFactory.createAreaEval("A2:A9", a2a9),
+                ErrorEval.VALUE_INVALID,
+        };
+        
+        result = invokeSumifs(args, EC);
+        assertTrue("Expect to have an error when an input is an invalid value, but had: " + result.getClass(), result instanceof ErrorEval);
+    }
+
+    public void testBug56655b() {
+/*
+        setCellFormula(sheet, 0, 0, "B1*C1");
+        sheet.getRow(0).createCell(1).setCellValue("A");
+        setCellFormula(sheet, 1, 0, "B1*C1");
+        sheet.getRow(1).createCell(1).setCellValue("A");
+        setCellFormula(sheet, 0, 3, "SUMIFS(A:A,A:A,A2)");
+ */
+    	ValueEval[] a0a1 = new ValueEval[] {
+                NumberEval.ZERO,
+                NumberEval.ZERO
+        };
+
+        ValueEval[] args = new ValueEval[]{
+                EvalFactory.createAreaEval("A0:A1", a0a1),
+                EvalFactory.createAreaEval("A0:A1", a0a1),
+                ErrorEval.VALUE_INVALID
+        };
+        
+        ValueEval result = invokeSumifs(args, EC);
+        assertTrue("Expect to have an error when an input is an invalid value, but had: " + result.getClass(), result instanceof ErrorEval);
+        assertEquals(ErrorEval.VALUE_INVALID, result);
+    }
+
+
+    public void testBug56655c() {
+/*
+        setCellFormula(sheet, 0, 0, "B1*C1");
+        sheet.getRow(0).createCell(1).setCellValue("A");
+        setCellFormula(sheet, 1, 0, "B1*C1");
+        sheet.getRow(1).createCell(1).setCellValue("A");
+        setCellFormula(sheet, 0, 3, "SUMIFS(A:A,A:A,A2)");
+ */
+        ValueEval[] a0a1 = new ValueEval[] {
+                NumberEval.ZERO,
+                NumberEval.ZERO
+        };
+
+        ValueEval[] args = new ValueEval[]{
+                EvalFactory.createAreaEval("A0:A1", a0a1),
+                EvalFactory.createAreaEval("A0:A1", a0a1),
+                ErrorEval.NAME_INVALID
+        };
+        
+        ValueEval result = invokeSumifs(args, EC);
+        assertTrue("Expect to have an error when an input is an invalid value, but had: " + result.getClass(), result instanceof ErrorEval);
+        assertEquals(ErrorEval.NAME_INVALID, result);
+    }
 }

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Sun Jul 19 19:00:32 2015
@@ -18,9 +18,12 @@
 package org.apache.poi.ss.usermodel;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -29,6 +32,9 @@ import org.apache.poi.hssf.util.PaneInfo
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.SheetUtil;
+import org.junit.Assume;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -120,7 +126,7 @@ public abstract class BaseTestBugzillaIs
      * Merged regions were being removed from the parent in cloned sheets
      */
     @Test
-    public final void bug22720() {
+    public void bug22720() {
        Workbook workBook = _testDataProvider.createWorkbook();
        workBook.createSheet("TEST");
        Sheet template = workBook.getSheetAt(0);
@@ -244,7 +250,7 @@ public abstract class BaseTestBugzillaIs
     }
 
     @Test
-    public final void bug18800() {
+    public void bug18800() {
        Workbook book = _testDataProvider.createWorkbook();
        book.createSheet("TEST");
        Sheet sheet = book.cloneSheet(0);
@@ -273,7 +279,7 @@ public abstract class BaseTestBugzillaIs
     }
 
     @Test
-    public final void bug43093() {
+    public void bug43093() {
         Workbook xlw = _testDataProvider.createWorkbook();
 
         addNewSheetWithCellsA1toD4(xlw, 1);
@@ -293,7 +299,7 @@ public abstract class BaseTestBugzillaIs
     }
 
     @Test
-    public final void bug46729_testMaxFunctionArguments(){
+    public void bug46729_testMaxFunctionArguments(){
         String[] func = {"COUNT", "AVERAGE", "MAX", "MIN", "OR", "SUBTOTAL", "SKEW"};
 
         SpreadsheetVersion ssVersion = _testDataProvider.getSpreadsheetVersion();
@@ -332,7 +338,7 @@ public abstract class BaseTestBugzillaIs
     }
 
     @Test
-    public final void bug506819_testAutoSize() {
+    public final void bug50681_testAutoSize() {
         Workbook wb = _testDataProvider.createWorkbook();
         BaseTestSheetAutosizeColumn.fixFonts(wb);
         Sheet sheet = wb.createSheet("Sheet1");
@@ -348,7 +354,26 @@ public abstract class BaseTestBugzillaIs
 
         cell0.setCellValue(longValue);
 
+        // autoSize will fail if required fonts are not installed, skip this test then
+        Font font = wb.getFontAt(cell0.getCellStyle().getFontIndex());
+        Assume.assumeTrue("Cannot verify auoSizeColumn() because the necessary Fonts are not installed on this machine: " + font, 
+                SheetUtil.canComputeColumnWidht(font));
+        
+        assertEquals("Expecting no indentation in this test",
+                0, cell0.getCellStyle().getIndention());
+
+        double width = SheetUtil.getColumnWidth(sheet, 0, false);
+        assertTrue("Expected to have column width > 0 BEFORE auto-size, but had " + width, width > 0);
+        width = SheetUtil.getCellWidth(cell0, 8, null, false);
+        assertTrue("Expected to have cell width > 0 BEFORE auto-size, but had " + width, width > 0);
+
         sheet.autoSizeColumn(0);
+        
+        width = SheetUtil.getColumnWidth(sheet, 0, false);
+        assertTrue("Expected to have column width > 0 AFTER auto-size, but had " + width, width > 0);
+        width = SheetUtil.getCellWidth(cell0, 8, null, false);
+        assertTrue("Expected to have cell width > 0 AFTER auto-size, but had " + width, width > 0);
+        
         assertEquals(255*256, sheet.getColumnWidth(0)); // maximum column width is 255 characters
         sheet.setColumnWidth(0, sheet.getColumnWidth(0)); // Bug 506819 reports exception at this point
     }
@@ -416,16 +441,16 @@ public abstract class BaseTestBugzillaIs
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet sheet = wb.createSheet("My sheet");
 
-        Row row = sheet.createRow( 0 );
-        Cell cell = row.createCell( 0 );
+        Row row = sheet.createRow(0);
+        Cell cell = row.createCell(0);
         cell.setCellFormula(hyperlinkF);
         
         assertEquals(hyperlinkF, cell.getCellFormula());
 
         wb = _testDataProvider.writeOutAndReadBack(wb);
         sheet = wb.getSheet("My Sheet");
-        row = sheet.getRow( 0 );
-        cell = row.getCell( 0 );
+        row = sheet.getRow(0);
+        cell = row.getCell(0);
         
         assertEquals(hyperlinkF, cell.getCellFormula());
     }
@@ -531,7 +556,7 @@ public abstract class BaseTestBugzillaIs
         assertAlmostEquals(1950, s.getColumnWidth(10), fontAccuracy);
         assertAlmostEquals(2225, s.getColumnWidth(11), fontAccuracy);
     }
-    
+
     /**
      * =ISNUMBER(SEARCH("AM",A1)) evaluation 
      */
@@ -637,7 +662,7 @@ public abstract class BaseTestBugzillaIs
         // Next up, SEARCH on its own
         cf.setCellFormula("SEARCH(\"am\", A1)");
         cf = evaluateCell(wb, cf);
-        assertEquals(ErrorConstants.ERROR_VALUE, cf.getErrorCellValue());
+        assertEquals(FormulaError.VALUE.getCode(), cf.getErrorCellValue());
         
         cf.setCellFormula("SEARCH(\"am\", B1)");
         cf = evaluateCell(wb, cf);
@@ -645,11 +670,11 @@ public abstract class BaseTestBugzillaIs
         
         cf.setCellFormula("SEARCH(\"am\", C1)");
         cf = evaluateCell(wb, cf);
-        assertEquals(ErrorConstants.ERROR_VALUE, cf.getErrorCellValue());
+        assertEquals(FormulaError.VALUE.getCode(), cf.getErrorCellValue());
         
         cf.setCellFormula("SEARCH(\"am\", D1)");
         cf = evaluateCell(wb, cf);
-        assertEquals(ErrorConstants.ERROR_VALUE, cf.getErrorCellValue());
+        assertEquals(FormulaError.VALUE.getCode(), cf.getErrorCellValue());
         
         
         // Finally, bring it all together
@@ -688,7 +713,8 @@ public abstract class BaseTestBugzillaIs
      * TODO Fix this to evaluate for XSSF
      * TODO Fix this to work at all for HSSF
      */
-//    @Test
+    @Ignore("Fix this to evaluate for XSSF, Fix this to work at all for HSSF")
+    @Test
     public void bug46670() throws Exception {
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet s = wb.createSheet();
@@ -727,7 +753,7 @@ public abstract class BaseTestBugzillaIs
         assertEquals(refHttp,  c2.getCellFormula());
 
         
-        // Try to evalutate, without giving a way to get at the other file
+        // Try to evaluate, without giving a way to get at the other file
         try {
             evaluateCell(wb, c1);
             fail("Shouldn't be able to evaluate without the other file");
@@ -757,4 +783,287 @@ public abstract class BaseTestBugzillaIs
         assertEquals(otherCellText, c1.getStringCellValue());
         assertEquals(otherCellText, c2.getStringCellValue());
     }
+
+    @Test
+    public void test56574OverwriteExistingRow() throws IOException {
+        Workbook wb = _testDataProvider.createWorkbook();
+        Sheet sheet = wb.createSheet();
+        
+        { // create the Formula-Cell
+            Row row = sheet.createRow(0);
+            Cell cell = row.createCell(0);
+            cell.setCellFormula("A2");
+        }
+        
+        { // check that it is there now
+            Row row = sheet.getRow(0);
+            
+           /* CTCell[] cArray = ((XSSFRow)row).getCTRow().getCArray();
+            assertEquals(1, cArray.length);*/
+
+            Cell cell = row.getCell(0);
+            assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
+        }
+        
+        { // overwrite the row
+            Row row = sheet.createRow(0);
+            assertNotNull(row);
+        }
+        
+        { // creating a row in place of another should remove the existing data,
+            // check that the cell is gone now
+            Row row = sheet.getRow(0);
+            
+            /*CTCell[] cArray = ((XSSFRow)row).getCTRow().getCArray();
+            assertEquals(0, cArray.length);*/
+
+            Cell cell = row.getCell(0);
+            assertNull(cell);
+        }
+        
+        // the calculation chain in XSSF is empty in a newly created workbook, so we cannot check if it is correctly updated
+        /*assertNull(((XSSFWorkbook)wb).getCalculationChain());
+        assertNotNull(((XSSFWorkbook)wb).getCalculationChain().getCTCalcChain());
+        assertNotNull(((XSSFWorkbook)wb).getCalculationChain().getCTCalcChain().getCArray());
+        assertEquals(0, ((XSSFWorkbook)wb).getCalculationChain().getCTCalcChain().getCArray().length);*/
+
+        wb.close();
+    }
+
+    /**
+     * With HSSF, if you create a font, don't change it, and
+     *  create a 2nd, you really do get two fonts that you 
+     *  can alter as and when you want.
+     * With XSSF, that wasn't the case, but this verfies
+     *  that it now is again
+     */
+    @Test
+    public void bug48718() throws Exception {
+        Workbook wb = _testDataProvider.createWorkbook();
+        int startingFonts = wb instanceof HSSFWorkbook ? 4 : 1;
+
+        assertEquals(startingFonts, wb.getNumberOfFonts());
+
+        // Get a font, and slightly change it
+        Font a = wb.createFont();
+        assertEquals(startingFonts+1, wb.getNumberOfFonts());
+        a.setFontHeightInPoints((short)23);
+        assertEquals(startingFonts+1, wb.getNumberOfFonts());
+
+        // Get two more, unchanged
+        /*Font b =*/ wb.createFont();
+        assertEquals(startingFonts+2, wb.getNumberOfFonts());
+        /*Font c =*/ wb.createFont();
+        assertEquals(startingFonts+3, wb.getNumberOfFonts());
+    }
+
+    @Test
+    public void bug57430() throws Exception {
+        Workbook wb = _testDataProvider.createWorkbook();
+        try {
+            wb.createSheet("Sheet1");
+
+            Name name1 = wb.createName();
+            name1.setNameName("FMLA");
+            name1.setRefersToFormula("Sheet1!$B$3");
+        } finally {
+            wb.close();
+        }
+    }
+
+    @Test
+    public void bug56981() throws IOException {
+        Workbook wb = _testDataProvider.createWorkbook();
+        CellStyle vertTop = wb.createCellStyle();
+        vertTop.setVerticalAlignment(CellStyle.VERTICAL_TOP);
+        CellStyle vertBottom = wb.createCellStyle();
+        vertBottom.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM);
+        Sheet sheet = wb.createSheet("Sheet 1");
+        Row row = sheet.createRow(0);
+        Cell top = row.createCell(0);
+        Cell bottom = row.createCell(1);
+        top.setCellValue("Top");
+        top.setCellStyle(vertTop); // comment this out to get all bottom-aligned
+                                   // cells
+        bottom.setCellValue("Bottom");
+        bottom.setCellStyle(vertBottom);
+        row.setHeightInPoints(85.75f); // make it obvious
+
+        /*FileOutputStream out = new FileOutputStream("c:\\temp\\56981.xlsx");
+        try {
+            wb.write(out);
+        } finally {
+            out.close();
+        }*/
+        
+        wb.close();
+    }
+
+    @Test
+    public void test57973() throws IOException {
+        Workbook wb = _testDataProvider.createWorkbook();
+
+        CreationHelper factory = wb.getCreationHelper();
+
+        Sheet sheet = wb.createSheet();
+        Drawing drawing = sheet.createDrawingPatriarch();
+        ClientAnchor anchor = factory.createClientAnchor();
+        
+        Cell cell0 = sheet.createRow(0).createCell(0);
+        cell0.setCellValue("Cell0");
+
+        Comment comment0 = drawing.createCellComment(anchor);
+        RichTextString str0 = factory.createRichTextString("Hello, World1!");
+        comment0.setString(str0);
+        comment0.setAuthor("Apache POI");
+        cell0.setCellComment(comment0);
+        
+        anchor = factory.createClientAnchor();
+        anchor.setCol1(1);
+        anchor.setCol2(1);
+        anchor.setRow1(1);
+        anchor.setRow2(1);
+        Cell cell1 = sheet.createRow(3).createCell(5);
+        cell1.setCellValue("F4");
+        Comment comment1 = drawing.createCellComment(anchor);
+        RichTextString str1 = factory.createRichTextString("Hello, World2!");
+        comment1.setString(str1);
+        comment1.setAuthor("Apache POI");
+        cell1.setCellComment(comment1);
+
+        Cell cell2 = sheet.createRow(2).createCell(2);
+        cell2.setCellValue("C3");
+
+        anchor = factory.createClientAnchor();
+        anchor.setCol1(2);
+        anchor.setCol2(2);
+        anchor.setRow1(2);
+        anchor.setRow2(2);
+
+        Comment comment2 = drawing.createCellComment(anchor);
+        RichTextString str2 = factory.createRichTextString("XSSF can set cell comments");
+        //apply custom font to the text in the comment
+        Font font = wb.createFont();
+        font.setFontName("Arial");
+        font.setFontHeightInPoints((short)14);
+        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
+        font.setColor(IndexedColors.RED.getIndex());
+        str2.applyFont(font);
+
+        comment2.setString(str2);
+        comment2.setAuthor("Apache POI");
+        comment2.setColumn(2);
+        comment2.setRow(2);
+
+        /*OutputStream out = new FileOutputStream("C:\\temp\\57973.xlsx");
+        try {
+            wb.write(out);
+        } finally {
+            out.close();
+        }*/
+        
+        wb.close();
+    }
+
+    /**
+     * Ensures that XSSF and HSSF agree with each other,
+     *  and with the docs on when fetching the wrong
+     *  kind of value from a Formula cell
+     */
+    @Test
+    public void bug47815() {
+        Workbook wb = _testDataProvider.createWorkbook();
+        Sheet s = wb.createSheet();
+        Row r = s.createRow(0);
+
+        // Setup
+        Cell cn = r.createCell(0, Cell.CELL_TYPE_NUMERIC);
+        cn.setCellValue(1.2);
+        Cell cs = r.createCell(1, Cell.CELL_TYPE_STRING);
+        cs.setCellValue("Testing");
+
+        Cell cfn = r.createCell(2, Cell.CELL_TYPE_FORMULA);
+        cfn.setCellFormula("A1");  
+        Cell cfs = r.createCell(3, Cell.CELL_TYPE_FORMULA);
+        cfs.setCellFormula("B1");
+
+        FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
+        assertEquals(Cell.CELL_TYPE_NUMERIC, fe.evaluate(cfn).getCellType());
+        assertEquals(Cell.CELL_TYPE_STRING, fe.evaluate(cfs).getCellType());
+        fe.evaluateFormulaCell(cfn);
+        fe.evaluateFormulaCell(cfs);
+
+        // Now test
+        assertEquals(Cell.CELL_TYPE_NUMERIC, cn.getCellType());
+        assertEquals(Cell.CELL_TYPE_STRING, cs.getCellType());
+        assertEquals(Cell.CELL_TYPE_FORMULA, cfn.getCellType());
+        assertEquals(Cell.CELL_TYPE_NUMERIC, cfn.getCachedFormulaResultType());
+        assertEquals(Cell.CELL_TYPE_FORMULA, cfs.getCellType());
+        assertEquals(Cell.CELL_TYPE_STRING, cfs.getCachedFormulaResultType());
+
+        // Different ways of retrieving
+        assertEquals(1.2, cn.getNumericCellValue(), 0);
+        try {
+            cn.getRichStringCellValue();
+            fail();
+        } catch(IllegalStateException e) {}
+
+        assertEquals("Testing", cs.getStringCellValue());
+        try {
+            cs.getNumericCellValue();
+            fail();
+        } catch(IllegalStateException e) {}
+
+        assertEquals(1.2, cfn.getNumericCellValue(), 0);
+        try {
+            cfn.getRichStringCellValue();
+            fail();
+        } catch(IllegalStateException e) {}
+
+        assertEquals("Testing", cfs.getStringCellValue());
+        try {
+            cfs.getNumericCellValue();
+            fail();
+        } catch(IllegalStateException e) {}
+    }
+    
+    @Test
+    public void test58113() {
+        Workbook wb = _testDataProvider.createWorkbook();
+        Sheet sheet = wb.createSheet( "Test" );
+
+        Row row = sheet.createRow(0);
+
+        Cell cell = row.createCell(0);
+        // verify that null-values can be set, this was possible up to 3.11, but broken in 3.12 
+        cell.setCellValue((String)null);
+        String value = cell.getStringCellValue();
+        assertTrue("HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value,
+                value == null || value.length() == 0);
+        
+        cell = row.createCell(1);
+        // also verify that setting formulas to null works  
+        cell.setCellType(Cell.CELL_TYPE_FORMULA);
+        cell.setCellValue((String)null);
+        
+        wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
+
+        value = cell.getStringCellValue();
+        assertTrue("HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value,
+                value == null || value.length() == 0);
+        
+        // set some value
+        cell.setCellType(Cell.CELL_TYPE_STRING);
+        cell.setCellValue("somevalue");
+
+        value = cell.getStringCellValue();
+        assertTrue("can set value afterwards: " + value,
+                value.equals("somevalue"));
+
+        // verify that the null-value is actually set even if there was some value in the cell before  
+        cell.setCellValue((String)null);
+        value = cell.getStringCellValue();
+        assertTrue("HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value,
+                value == null || value.length() == 0);
+    }
 }

Modified: poi/branches/common_sl/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java (original)
+++ poi/branches/common_sl/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Sun Jul 19 19:00:32 2015
@@ -25,6 +25,7 @@ import junit.framework.TestCase;
 
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.SpreadsheetVersion;
 
 /**
  * Common superclass for testing implementations of
@@ -695,4 +696,75 @@ public abstract class BaseTestCell exten
         
         wb.close();
     }
+
+	public void test57008() throws IOException {
+        Workbook wb = _testDataProvider.createWorkbook();
+		Sheet sheet = wb.createSheet();
+		
+		Row row0 = sheet.createRow(0);
+		Cell cell0 = row0.createCell(0);
+		cell0.setCellValue("row 0, cell 0 _x0046_ without changes");
+		
+		Cell cell1 = row0.createCell(1);
+		cell1.setCellValue("row 0, cell 1 _x005fx0046_ with changes");
+		
+		Cell cell2 = row0.createCell(2);
+		cell2.setCellValue("hgh_x0041_**_x0100_*_x0101_*_x0190_*_x0200_*_x0300_*_x0427_*");
+
+		checkUnicodeValues(wb);
+		
+//		String fname = "/tmp/Test_xNNNN_inCell" + (wb instanceof HSSFWorkbook ? ".xls" : ".xlsx");
+//		FileOutputStream out = new FileOutputStream(fname);
+//		try {
+//			wb.write(out);
+//		} finally {
+//			out.close();
+//		}
+		
+		Workbook wbBack = _testDataProvider.writeOutAndReadBack(wb);
+		checkUnicodeValues(wbBack);
+	}
+
+	private void checkUnicodeValues(Workbook wb) {
+		assertEquals((wb instanceof HSSFWorkbook ? "row 0, cell 0 _x0046_ without changes" : "row 0, cell 0 F without changes"), 
+				wb.getSheetAt(0).getRow(0).getCell(0).toString());
+		assertEquals((wb instanceof HSSFWorkbook ? "row 0, cell 1 _x005fx0046_ with changes" : "row 0, cell 1 _x005fx0046_ with changes"), 
+				wb.getSheetAt(0).getRow(0).getCell(1).toString());
+		assertEquals((wb instanceof HSSFWorkbook ? "hgh_x0041_**_x0100_*_x0101_*_x0190_*_x0200_*_x0300_*_x0427_*" : "hghA**\u0100*\u0101*\u0190*\u0200*\u0300*\u0427*"), 
+				wb.getSheetAt(0).getRow(0).getCell(2).toString());
+	}
+
+	/**
+	 *  The maximum length of cell contents (text) is 32,767 characters.
+	 * @throws IOException 
+	 */
+	public void testMaxTextLength() throws IOException{
+		Workbook wb = _testDataProvider.createWorkbook();
+        Sheet sheet = wb.createSheet();
+		Cell cell = sheet.createRow(0).createCell(0);
+
+		int maxlen = wb instanceof HSSFWorkbook ? 
+				SpreadsheetVersion.EXCEL97.getMaxTextLength()
+				: SpreadsheetVersion.EXCEL2007.getMaxTextLength();
+		assertEquals(32767, maxlen);
+
+		StringBuffer b = new StringBuffer() ;
+
+		// 32767 is okay
+		for( int i = 0 ; i < maxlen ; i++ )
+		{
+			b.append( "X" ) ;
+		}
+		cell.setCellValue(b.toString());
+
+		b.append("X");
+		// 32768 produces an invalid XLS file
+		try {
+			cell.setCellValue(b.toString());
+			fail("Expected exception");
+		} catch (IllegalArgumentException e){
+			assertEquals("The maximum length of cell contents (text) is 32,767 characters", e.getMessage());
+		}
+		wb.close();
+	}
 }



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


Mime
View raw message