aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-05-26 13:56:40 +0000
committerNick Burch <nick@apache.org>2015-05-26 13:56:40 +0000
commit76b49ec06d6eb8fd0b32c29e24396e8af7c60259 (patch)
treeae68fd95f4111e9ead930c1463d8740e8963ac42 /src/testcases
parentbe1cb0c59cde0140caca43a93832866a993ddbf3 (diff)
downloadpoi-76b49ec06d6eb8fd0b32c29e24396e8af7c60259.tar.gz
poi-76b49ec06d6eb8fd0b32c29e24396e8af7c60259.zip
Fix testing for NPOIFS zero-length stream writing
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1681762 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r--src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
index 69c6cacf68..75161b9f83 100644
--- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
+++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
@@ -1336,8 +1336,6 @@ public final class TestNPOIFSFileSystem {
}
}
- // TODO Should these have a mini-sbat entry or not?
- // TODO Is the reading of zero-length properties exactly correct?
@Test
public void writeZeroLengthEntries() throws Exception {
NPOIFSFileSystem fs = new NPOIFSFileSystem();
@@ -1378,6 +1376,37 @@ public final class TestNPOIFSFileSystem {
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();