You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2015/05/26 15:41:29 UTC
svn commit: r1681754 - in /poi/trunk: src/java/org/apache/poi/poifs/property/
src/testcases/org/apache/poi/poifs/filesystem/ test-data/poifs/
Author: nick
Date: Tue May 26 13:41:29 2015
New Revision: 1681754
URL: http://svn.apache.org/r1681754
Log:
More 0 byte stream tests
Added:
poi/trunk/test-data/poifs/only-zero-byte-streams.ole2 (with props)
Modified:
poi/trunk/src/java/org/apache/poi/poifs/property/DirectoryProperty.java
poi/trunk/src/java/org/apache/poi/poifs/property/RootProperty.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
Modified: poi/trunk/src/java/org/apache/poi/poifs/property/DirectoryProperty.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/property/DirectoryProperty.java?rev=1681754&r1=1681753&r2=1681754&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/property/DirectoryProperty.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/property/DirectoryProperty.java Tue May 26 13:41:29 2015
@@ -28,10 +28,8 @@ import java.util.Set;
/**
* Directory property
- *
- * @author Marc Johnson (mjohnson at apache dot org)
*/
-public class DirectoryProperty extends Property implements Parent { // TODO - fix instantiable superclass
+public class DirectoryProperty extends Property implements Parent, Iterable<Property> { // TODO - fix instantiable superclass
/** List of Property instances */
private List<Property> _children;
@@ -241,6 +239,13 @@ public class DirectoryProperty extends P
{
return _children.iterator();
}
+ /**
+ * Get an iterator over the children of this Parent, alias for
+ * {@link #getChildren()} which supports foreach use
+ */
+ public Iterator<Property> iterator() {
+ return getChildren();
+ }
/**
* Add a new child to the collection of children
Modified: poi/trunk/src/java/org/apache/poi/poifs/property/RootProperty.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/property/RootProperty.java?rev=1681754&r1=1681753&r2=1681754&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/property/RootProperty.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/property/RootProperty.java Tue May 26 13:41:29 2015
@@ -22,8 +22,6 @@ import org.apache.poi.poifs.storage.Smal
/**
* Root property
- *
- * @author Marc Johnson (mjohnson at apache dot org)
*/
public final class RootProperty extends DirectoryProperty {
private static final String NAME = "Root Entry";
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java?rev=1681754&r1=1681753&r2=1681754&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java Tue May 26 13:41:29 2015
@@ -21,6 +21,7 @@ import static org.hamcrest.core.IsCollec
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.Pro
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();
Added: poi/trunk/test-data/poifs/only-zero-byte-streams.ole2
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/poifs/only-zero-byte-streams.ole2?rev=1681754&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/poifs/only-zero-byte-streams.ole2
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org