From de97868d2fc75855befb3653684dd1edfe02c82d Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 11 May 2015 15:20:42 +0000 Subject: [PATCH] More NPOIFS ministore tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1678767 13f79535-47bb-0310-9956-ffa450edef68 --- .../poifs/filesystem/TestNPOIFSMiniStore.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java index c875c52997..0445422907 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