@Test
public void writeTest() throws Exception
{
IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
fs.create(0);
fs.open();
ArrayList<Block> blocks = new ArrayList<Block>();
ArrayList<BlockId> blockIds = new ArrayList<BlockId>();
String testStr = "<test> <content> Hello world! </content> </test>";
byte[] content = testStr.getBytes();
for (int i = 0; i < 200; i++) {
Block b = new Block(new BlockId(0));
b.setBytes(content);
blocks.add(b);
BlockId bid = fs.append(b, false);
blockIds.add(bid);
}
String newTestStr = "<test> <content> Hello world, again! </content> </test>";
byte[] newContent = newTestStr.getBytes();
Block b = new Block(blockIds.get(78));
b.setBytes(newContent);
fs.write(b);
Block rB = fs.read(blockIds.get(78));
assertEquals(newTestStr, new String(rB.getBytes()).substring(0, newTestStr.length()));
}