diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java index c875c5299..044542290 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java @@ -17,6 +17,7 @@ package org.apache.poi.poifs.filesystem; +import java.io.ByteArrayInputStream; import java.nio.ByteBuffer; import java.util.Iterator; @@ -332,4 +333,51 @@ public final class TestNPOIFSMiniStore extends TestCase { fs.close(); } + + public void testCreateMiniStoreFirst() throws Exception { + NPOIFSFileSystem fs = new NPOIFSFileSystem(); + NPOIFSMiniStore ministore = fs.getMiniStore(); + + // Initially has BAT + Properties but nothing else + assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0)); + assertEquals(POIFSConstants.END_OF_CHAIN, 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