// Inject blocks
// Now reset fsdataset with an initial block report (Use the blocks we got above)
SimulatedFSDataset sfsdataset = new SimulatedFSDataset(conf);
sfsdataset.injectBlocks(blockReport);
blockReport = sfsdataset.getBlockReport();
assertEquals(NUMBLOCKS, blockReport.length);
for (Block b: blockReport) {
assertNotNull(b);
assertEquals(blockIdToLen(b.blkid), b.len);
assertEquals(blockIdToLen(b.blkid), sfsdataset.getLength(b));
}
assertEquals(bytesAdded, sfsdataset.getDfsUsed());
assertEquals(sfsdataset.getCapacity()-bytesAdded, sfsdataset.getRemaining());
// Now test that the dataset cannot be created if it does not have sufficient cap
conf.setLong(SimulatedFSDataset.CONFIG_PROPERTY_CAPACITY, 10);
try {
sfsdataset = new SimulatedFSDataset(conf);
sfsdataset.injectBlocks(blockReport);
assertTrue("Expected an IO exception", false);
} catch (IOException e) {
// ok - as expected
}