Add common code for writing out and reading NPOIFS again, and add a disabled roundtrip test (currently failing...)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1589895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1fc66d1f71
commit
a4c8f4f1c9
@ -83,6 +83,13 @@ public final class TestNPOIFSFileSystem {
|
||||
return header;
|
||||
}
|
||||
|
||||
protected static NPOIFSFileSystem writeOutAndReadBack(NPOIFSFileSystem original) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
original.writeFilesystem(baos);
|
||||
original.close();
|
||||
return new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicOpen() throws Exception {
|
||||
NPOIFSFileSystem fsA, fsB;
|
||||
@ -521,11 +528,9 @@ public final class TestNPOIFSFileSystem {
|
||||
|
||||
|
||||
// Now, write it out, and read it back in again fully
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
fs.writeFilesystem(baos);
|
||||
fs = writeOutAndReadBack(fs);
|
||||
|
||||
// Check that it is seen correctly
|
||||
fs = new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
|
||||
assertBATCount(fs, 237, 2);
|
||||
|
||||
assertEquals(false, fs.getBATBlockAndIndex(236*128-1).getBlock().hasFreeSectors());
|
||||
@ -670,9 +675,7 @@ public final class TestNPOIFSFileSystem {
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
|
||||
|
||||
// Write and read it
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
fs.writeFilesystem(baos);
|
||||
fs = new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
|
||||
fs = writeOutAndReadBack(fs);
|
||||
|
||||
// Property table entries have been added to the blocks
|
||||
assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
|
||||
@ -795,7 +798,55 @@ public final class TestNPOIFSFileSystem {
|
||||
|
||||
|
||||
// Write and read back
|
||||
fs = writeOutAndReadBack(fs);
|
||||
|
||||
// Check it's all unchanged
|
||||
// TODO Fix it so that it is....
|
||||
if (1==0) {
|
||||
assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
|
||||
if (fs.getBigBlockSize() == POIFSConstants.SMALLER_BIG_BLOCK_SIZE) {
|
||||
assertEquals(4, fs.getNextBlock(3));
|
||||
assertEquals(5, fs.getNextBlock(4));
|
||||
assertEquals(6, fs.getNextBlock(5));
|
||||
assertEquals(7, fs.getNextBlock(6));
|
||||
assertEquals(8, fs.getNextBlock(7));
|
||||
assertEquals(9, fs.getNextBlock(8));
|
||||
assertEquals(10, fs.getNextBlock(9));
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(10));
|
||||
|
||||
assertEquals(12, fs.getNextBlock(11));
|
||||
assertEquals(13, fs.getNextBlock(12));
|
||||
assertEquals(14, fs.getNextBlock(13));
|
||||
assertEquals(15, fs.getNextBlock(14));
|
||||
assertEquals(16, fs.getNextBlock(15));
|
||||
assertEquals(17, fs.getNextBlock(16));
|
||||
assertEquals(18, fs.getNextBlock(17));
|
||||
assertEquals(19, fs.getNextBlock(18));
|
||||
assertEquals(20, fs.getNextBlock(19));
|
||||
assertEquals(21, fs.getNextBlock(20));
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21));
|
||||
assertEquals(23, fs.getNextBlock(22));
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23));
|
||||
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24));
|
||||
} else {
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(3));
|
||||
assertEquals(5, fs.getNextBlock(4));
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(5));
|
||||
assertEquals(7, fs.getNextBlock(6));
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(7));
|
||||
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(8));
|
||||
}
|
||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
|
||||
}
|
||||
|
||||
// Check some data
|
||||
// TODO
|
||||
|
||||
|
||||
// All done
|
||||
fs.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user