Преглед изворни кода

More 0 byte stream tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1681754 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_13_BETA1
Nick Burch пре 9 година
родитељ
комит
e191e05045

+ 8
- 3
src/java/org/apache/poi/poifs/property/DirectoryProperty.java Прегледај датотеку



/** /**
* Directory property * 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 */ /** List of Property instances */
private List<Property> _children; private List<Property> _children;
{ {
return _children.iterator(); 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 * Add a new child to the collection of children

+ 0
- 2
src/java/org/apache/poi/poifs/property/RootProperty.java Прегледај датотеку



/** /**
* Root property * Root property
*
* @author Marc Johnson (mjohnson at apache dot org)
*/ */
public final class RootProperty extends DirectoryProperty { public final class RootProperty extends DirectoryProperty {
private static final String NAME = "Root Entry"; private static final String NAME = "Root Entry";

+ 32
- 0
src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java Прегледај датотеку

import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import org.apache.poi.poifs.property.RootProperty; import org.apache.poi.poifs.property.RootProperty;
import org.apache.poi.poifs.storage.HeaderBlock; import org.apache.poi.poifs.storage.HeaderBlock;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;


/** /**
assertContentsMatches(main4106, normDoc); assertContentsMatches(main4106, normDoc);
} }
@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 @Test
public void writeZeroLengthEntries() throws Exception { public void writeZeroLengthEntries() throws Exception {
NPOIFSFileSystem fs = new NPOIFSFileSystem(); NPOIFSFileSystem fs = new NPOIFSFileSystem();

BIN
test-data/poifs/only-zero-byte-streams.ole2 Прегледај датотеку


Loading…
Откажи
Сачувај