Add some more NPOIFS write related tests, some of which is disabled as the functionality isn't quite there yet

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1124693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2011-05-19 11:54:29 +00:00
parent 4f62006ae3
commit 76b3d98c0c
2 changed files with 32 additions and 4 deletions

View File

@ -116,7 +116,9 @@ public final class NPropertyTable extends PropertyTableBase {
// TODO - Use a streaming write // TODO - Use a streaming write
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
for(Property property : _properties) { for(Property property : _properties) {
property.writeData(baos); if(property != null) {
property.writeData(baos);
}
} }
stream.updateContents(baos.toByteArray()); stream.updateContents(baos.toByteArray());

View File

@ -32,6 +32,7 @@ import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.poifs.property.NPropertyTable; import org.apache.poi.poifs.property.NPropertyTable;
import org.apache.poi.poifs.property.Property; import org.apache.poi.poifs.property.Property;
import org.apache.poi.poifs.property.RootProperty; import org.apache.poi.poifs.property.RootProperty;
import org.apache.poi.poifs.storage.HeaderBlock;
/** /**
* Tests for the new NIO POIFSFileSystem implementation * Tests for the new NIO POIFSFileSystem implementation
@ -439,14 +440,39 @@ public final class TestNPOIFSFileSystem extends TestCase {
} catch(IndexOutOfBoundsException e) {} } catch(IndexOutOfBoundsException e) {}
// Write it out and read it back in again // Check the counts
// TODO int numBATs = 0;
int numXBATs = 0;
for(int i=0; i<237*128; i++) {
if(fs.getNextBlock(i) == POIFSConstants.FAT_SECTOR_BLOCK) {
numBATs++;
}
if(fs.getNextBlock(i) == POIFSConstants.DIFAT_SECTOR_BLOCK) {
numXBATs++;
}
}
if(1==2) {
// TODO Fix this
assertEquals(237, numBATs);
assertEquals(2, numXBATs);
}
// Write it out
ByteArrayOutputStream baos = new ByteArrayOutputStream();
fs.writeFilesystem(baos);
// Check the header is correct // Check the header is correct
// TODO HeaderBlock header = new HeaderBlock(new ByteArrayInputStream(baos.toByteArray()));
if(1==2) {
// TODO Fix this
assertEquals(237, header.getBATCount());
assertEquals(2, header.getXBATCount());
// Now check the filesystem sees it correct too // Now check the filesystem sees it correct too
fs = new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
// TODO // TODO
}
} }
/** /**