aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/poifs
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-05-26 13:41:29 +0000
committerNick Burch <nick@apache.org>2015-05-26 13:41:29 +0000
commite191e05045b990625a144bf5ff9c088051260a42 (patch)
tree57f00a9ef024abfce9bb88c59d1e51569fe689c1 /src/testcases/org/apache/poi/poifs
parente15c254996d209fca3614f037242510ad6c361e9 (diff)
downloadpoi-e191e05045b990625a144bf5ff9c088051260a42.tar.gz
poi-e191e05045b990625a144bf5ff9c088051260a42.zip
More 0 byte stream tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1681754 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/poifs')
-rw-r--r--src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java32
1 files changed, 32 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 1444374833..69c6cacf68 100644
--- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
+++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
@@ -21,6 +21,7 @@ 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.assertThat;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
@@ -41,6 +42,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;
/**
@@ -1307,6 +1309,36 @@ public final class TestNPOIFSFileSystem {
}
@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());
+ }
+ }
+
+ // 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();
DirectoryNode testDir = fs.getRoot();