DocumentEntry miniDoc;
DocumentEntry normDoc;
- // Initially has a BAT but not SBAT
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
+ // Initially has Properties + BAT but not SBAT
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(2));
// Check that the SBAT is empty
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
- // Check that no properties table has been written yet
- assertEquals(POIFSConstants.END_OF_CHAIN, fs._get_property_table().getStartBlock());
+ // Check that properties table was given block 0
+ assertEquals(0, fs._get_property_table().getStartBlock());
// Write and read it
fs = writeOutAndReadBack(fs);
- // Property table entries have been added to the blocks
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
- assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(3));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
- assertEquals(2, fs._get_property_table().getStartBlock());
+ // No change, SBAT remains empty
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(2));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(3));
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
+ assertEquals(0, fs._get_property_table().getStartBlock());
// Put everything within a new directory
main4096[4095] = -11;
testDir.createDocument("Normal4096", new ByteArrayInputStream(main4096));
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+ assertEquals(3, fs.getNextBlock(2));
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(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(10));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(11));
-
+ // SBAT still unused
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
main5124[5123] = -33;
testDir.createDocument("Normal5124", new ByteArrayInputStream(main5124));
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+ assertEquals(3, fs.getNextBlock(2));
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(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9));
+ assertEquals(11, fs.getNextBlock(10));
assertEquals(12, fs.getNextBlock(11));
assertEquals(13, fs.getNextBlock(12));
assertEquals(14, fs.getNextBlock(13));
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(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(20));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(21));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(22));
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getRoot().getProperty().getStartBlock());
testDir.createDocument("Mini", new ByteArrayInputStream(mini));
// Mini stream will get one block for fat + one block for data
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+ assertEquals(3, fs.getNextBlock(2));
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(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9));
+ assertEquals(11, fs.getNextBlock(10));
assertEquals(12, fs.getNextBlock(11));
assertEquals(13, fs.getNextBlock(12));
assertEquals(14, fs.getNextBlock(13));
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(20));
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21));
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23));
- assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(23));
// Check the mini stream location was set
- // (22 is mini fat, 23 is first mini stream block)
- assertEquals(23, fs.getRoot().getProperty().getStartBlock());
+ // (21 is mini fat, 22 is first mini stream block)
+ assertEquals(22, fs.getRoot().getProperty().getStartBlock());
// Write and read back
// Check the header has the right points in it
assertEquals(1, header.getBATCount());
- assertEquals(0, header.getBATArray()[0]);
- assertEquals(2, header.getPropertyStart());
+ assertEquals(1, header.getBATArray()[0]);
+ assertEquals(0, header.getPropertyStart());
assertEquals(1, header.getSBATCount());
- assertEquals(22, header.getSBATStart());
- assertEquals(23, fs._get_property_table().getRoot().getStartBlock());
+ assertEquals(21, header.getSBATStart());
+ assertEquals(22, fs._get_property_table().getRoot().getStartBlock());
// Block use should be almost the same, except the properties
// stream will have grown out to cover 2 blocks
// Check the block use is all unchanged
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
- assertEquals(24, fs.getNextBlock(2)); // Properties now extends over 2 blocks
+ assertEquals(23, fs.getNextBlock(0)); // Properties now extends over 2 blocks
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+ assertEquals(3, fs.getNextBlock(2));
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)); // End of normal4096
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9)); // End of normal4096
+ assertEquals(11, fs.getNextBlock(10));
assertEquals(12, fs.getNextBlock(11));
assertEquals(13, fs.getNextBlock(12));
assertEquals(14, fs.getNextBlock(13));
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)); // End of normal5124
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(20)); // End of normal5124
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22)); // Mini Stream FAT
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23)); // Mini Stream data
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(24)); // Properties #2
- assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(25));
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21)); // Mini Stream FAT
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22)); // Mini Stream data
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23)); // Properties #2
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24));
// Check some data
// Check - will have un-used sectors now
fs = writeOutAndReadBack(fs);
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2)); // Props back in 1 block
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0)); // Props back in 1 block
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
+ assertEquals(3, fs.getNextBlock(2));
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)); // End of normal4096
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(9)); // End of normal4096
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(10));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(11));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(12));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(13));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(18));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(19));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(20));
- assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(21));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22)); // Mini Stream FAT
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(23)); // Mini Stream data
- assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24)); // Properties gone
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(21)); // Mini Stream FAT
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(22)); // Mini Stream data
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(23)); // Properties gone
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(24));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(25));
// All done
DocumentEntry normDoc;
HeaderBlock hdr;
- // Initially has BAT + Properties but nothing else
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
+ // Initially has Properties + BAT but nothing else
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(2));
hdr = writeOutAndReadHeader(fs);
// No mini stream, and no xbats
// Will have fat then properties stream
assertEquals(1, hdr.getBATCount());
- assertEquals(0, hdr.getBATArray()[0]);
- assertEquals(2, hdr.getPropertyStart());
+ assertEquals(1, hdr.getBATArray()[0]);
+ assertEquals(0, hdr.getPropertyStart());
assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getSBATStart());
assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getXBATIndex());
- assertEquals(POIFSConstants.SMALLER_BIG_BLOCK_SIZE*4, fs.size());
+ assertEquals(POIFSConstants.SMALLER_BIG_BLOCK_SIZE*3, fs.size());
// Get a clean filesystem to start with
// Check the mini stream was added, then the main stream
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2)); // Mini Fat
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(3)); // Mini Stream
assertEquals(5, fs.getNextBlock(4)); // Main Stream
// Check the header details - will have the sbat near the start,
// then the properties at the end
assertEquals(1, hdr.getBATCount());
- assertEquals(0, hdr.getBATArray()[0]);
+ assertEquals(1, hdr.getBATArray()[0]);
assertEquals(2, hdr.getSBATStart());
- assertEquals(12, hdr.getPropertyStart());
+ assertEquals(0, hdr.getPropertyStart());
assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getXBATIndex());
// Check the block allocation is unchanged, other than
// the properties stream going in at the end
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(1));
+ assertEquals(12, fs.getNextBlock(0)); // Properties
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(1));
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(3));
assertEquals(5, fs.getNextBlock(4));
assertEquals(10, fs.getNextBlock(9));
assertEquals(11, fs.getNextBlock(10));
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(11));
- assertEquals(13, fs.getNextBlock(12));
- assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(13));
- assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(14));
- assertEquals(POIFSConstants.SMALLER_BIG_BLOCK_SIZE*15, fs.size());
+ assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(12));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(13));
+ assertEquals(POIFSConstants.SMALLER_BIG_BLOCK_SIZE*14, fs.size());
// Check the data
NPOIFSFileSystem fs = new NPOIFSFileSystem();
NPOIFSStream stream = new NPOIFSStream(fs);
- // Check our filesystem has a BAT and the Properties
+ // Check our filesystem has Properties then BAT
assertEquals(2, fs.getFreeBlock());
BATBlock bat = fs.getBATBlockAndIndex(0).getBlock();
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
- assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(2));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(2));
// Check the stream as-is
assertEquals(POIFSConstants.END_OF_CHAIN, stream.getStartBlock());
// Check now
assertEquals(4, fs.getFreeBlock());
bat = fs.getBATBlockAndIndex(0).getBlock();
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
- assertEquals(3, bat.getValueAt(2));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3));
- assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(4));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
+ assertEquals(3, bat.getValueAt(2));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(4));
Iterator<ByteBuffer> it = stream.getBlockIterator();
public void testWriteThenReplace() throws Exception {
NPOIFSFileSystem fs = new NPOIFSFileSystem();
- // Starts empty
+ // Starts empty, other that Properties and BAT
BATBlock bat = fs.getBATBlockAndIndex(0).getBlock();
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
- assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(2));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(2));
// Write something that uses a main stream
byte[] main4106 = new byte[4106];
"Normal", new ByteArrayInputStream(main4106));
// Should have used 9 blocks
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
assertEquals(3, bat.getValueAt(2));
assertEquals(4, bat.getValueAt(3));
assertEquals(5, bat.getValueAt(4));
nout.close();
// Will have dropped to 8
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
assertEquals(3, bat.getValueAt(2));
assertEquals(4, bat.getValueAt(3));
assertEquals(5, bat.getValueAt(4));
fs = writeOutAndReadBack(fs);
bat = fs.getBATBlockAndIndex(0).getBlock();
- // Will have properties, but otherwise the same
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+ // No change after write
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0)); // Properties
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
assertEquals(3, bat.getValueAt(2));
assertEquals(4, bat.getValueAt(3));
assertEquals(5, bat.getValueAt(4));
assertEquals(8, bat.getValueAt(7));
assertEquals(9, bat.getValueAt(8));
assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(9)); // End of Normal
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
+ assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(10));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11));
normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
assertEquals(4096, ((DocumentNode)normal).getProperty().getSize());
- // Make longer, take 1 block after the properties too
+ // Make longer, take 1 block at the end
normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
nout = new NDocumentOutputStream(normal);
nout.write(main4106);
nout.close();
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK,bat.getValueAt(1));
assertEquals(3, bat.getValueAt(2));
assertEquals(4, bat.getValueAt(3));
assertEquals(5, bat.getValueAt(4));
assertEquals(7, bat.getValueAt(6));
assertEquals(8, bat.getValueAt(7));
assertEquals(9, bat.getValueAt(8));
- assertEquals(11, bat.getValueAt(9));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(11)); // Normal
+ assertEquals(10, bat.getValueAt(9));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Normal
+ assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12));
normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
nout.write(mini);
nout.close();
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(1));
assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(2)); // SBAT
assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3)); // Mini Stream
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(4));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(7));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(8));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(9));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
+ assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(10));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12));
nout.close();
// Will keep the mini stream, now empty
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(1));
assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(2)); // SBAT
assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3)); // Mini Stream
assertEquals(5, bat.getValueAt(4));
assertEquals(7, bat.getValueAt(6));
assertEquals(8, bat.getValueAt(7));
assertEquals(9, bat.getValueAt(8));
- assertEquals(11, bat.getValueAt(9));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
- assertEquals(12, bat.getValueAt(11));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(12));
+ assertEquals(10, bat.getValueAt(9));
+ assertEquals(11, bat.getValueAt(10));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(11));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(13));
normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
fs = writeOutAndReadBack(fs);
bat = fs.getBATBlockAndIndex(0).getBlock();
- assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(0));
+ assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(1));
assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(2)); // SBAT
assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3)); // Mini Stream
assertEquals(5, bat.getValueAt(4));
assertEquals(7, bat.getValueAt(6));
assertEquals(8, bat.getValueAt(7));
assertEquals(9, bat.getValueAt(8));
- assertEquals(11, bat.getValueAt(9));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); // Props
- assertEquals(12, bat.getValueAt(11));
- assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(12));
+ assertEquals(10, bat.getValueAt(9));
+ assertEquals(11, bat.getValueAt(10));
+ assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(11));
+ assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12));
assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(13));
normal = (DocumentEntry)fs.getRoot().getEntry("Normal");