aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-05-11 15:27:59 +0000
committerNick Burch <nick@apache.org>2015-05-11 15:27:59 +0000
commit1d484efbbb5ad3ce74c82eebf03e1111216f904e (patch)
tree30c83f97c80e153ad72ea05b41728e17b24e5739
parentde97868d2fc75855befb3653684dd1edfe02c82d (diff)
downloadpoi-1d484efbbb5ad3ce74c82eebf03e1111216f904e.tar.gz
poi-1d484efbbb5ad3ce74c82eebf03e1111216f904e.zip
Disabled NPOIFS unit test - problem with 0 length entries discovered working on #56791
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1678769 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
index b5793a266f..b4e3b79af4 100644
--- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
+++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
@@ -41,6 +41,7 @@ import org.apache.poi.poifs.property.Property;
import org.apache.poi.poifs.property.RootProperty;
import org.apache.poi.poifs.storage.HeaderBlock;
import org.apache.poi.util.IOUtils;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -1305,6 +1306,66 @@ public final class TestNPOIFSFileSystem {
normDoc = (DocumentEntry)testDir.getEntry("Normal4106");
assertContentsMatches(main4106, normDoc);
}
+
+ @Ignore
+ @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);
+
+ // Save and re-check
+ fs = writeOutAndReadBack(fs);
+
+ 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);
+ }
/**
* Test that we can read a file with NPOIFS, create a new NPOIFS instance,