Integer.valueOf(this.dataFile.getBlockSizeBytes()) ) ); elems.add(new StatElement<Integer>( "Number Of Blocks", Integer.valueOf(this.dataFile.getNumberOfBlocks()) ) ); elems.add(new StatElement<Long>( "Average Put Size Bytes", Long.valueOf(this.dataFile.getAveragePutSizeBytes()) ) );
Integer.valueOf(this.dataFile.getBlockSizeBytes()) ) ); elems.add(new StatElement<Integer>( "Number Of Blocks", Integer.valueOf(this.dataFile.getNumberOfBlocks()) ) ); elems.add(new StatElement<Long>( "Average Put Size Bytes", Long.valueOf(this.dataFile.getAveragePutSizeBytes()) ) );
/** * Test writing a null object within a single block size. * <p> * @throws Exception */ public void testWrite_NullBlockElement() throws Exception { // SETUP String fileName = "testWrite_NullBlockElement"; File file = new File( rafDir, fileName + ".data" ); file.delete(); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK int[] blocks = disk.write( null ); // VERIFY assertEquals( "Wrong number of blocks recorded.", 1, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", 1, blocks.length ); assertEquals( "Wrong block returned.", 0, blocks[0] ); }
/** * Test writing an element within a single block size. * <p> * @throws Exception */ public void testWrite_SingleBlockElement() throws Exception { // SETUP String fileName = "testWrite_SingleBlockElement"; File file = new File( rafDir, fileName + ".data" ); file.delete(); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK int bytes = 1 * 1024; int[] blocks = disk.write( new byte[bytes] ); // VERIFY assertEquals( "Wrong number of blocks recorded.", 1, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", 1, blocks.length ); assertEquals( "Wrong block returned.", 0, blocks[0] ); }
/** * Test writing a null object within a single block size. * <p> * @throws Exception */ public void testWrite_NullBlockElement() throws Exception { // SETUP String fileName = "testWrite_NullBlockElement"; File file = new File( rafDir, fileName + ".data" ); file.delete(); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK int[] blocks = disk.write( null ); // VERIFY assertEquals( "Wrong number of blocks recorded.", 1, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", 1, blocks.length ); assertEquals( "Wrong block returned.", 0, blocks[0] ); }
/** * Test writing an element within a single block size. * <p> * @throws Exception */ public void testWrite_SingleBlockElement() throws Exception { // SETUP String fileName = "testWrite_SingleBlockElement"; File file = new File( rafDir, fileName + ".data" ); file.delete(); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK int bytes = 1 * 1024; int[] blocks = disk.write( new byte[bytes] ); // VERIFY assertEquals( "Wrong number of blocks recorded.", 1, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", 1, blocks.length ); assertEquals( "Wrong block returned.", 0, blocks[0] ); }
assertEquals( "Wrong number of elements. "+disk, numBlocksPerElement * numElements, disk.getNumberOfBlocks() );
assertEquals( "Wrong number of elements. "+disk, numBlocksPerElement * numElements, disk.getNumberOfBlocks() );
/** * Test writing two elements that each fit within a single block size. * <p> * @throws Exception */ public void testWrite_TwoSingleBlockElements() throws Exception { // SETUP String fileName = "testWrite_TwoSingleBlockElements"; File file = new File( rafDir, fileName + ".data" ); file.delete(); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK int bytes = 1 * 1024; int[] blocks1 = disk.write( new byte[bytes] ); int[] blocks2 = disk.write( new byte[bytes] ); // VERIFY assertEquals( "Wrong number of blocks recorded.", 2, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", 1, blocks1.length ); assertEquals( "Wrong block returned.", 0, blocks1[0] ); assertEquals( "Wrong number of blocks returned.", 1, blocks2.length ); assertEquals( "Wrong block returned.", 1, blocks2[0] ); }
/** * Test writing two elements that each fit within a single block size. * <p> * @throws Exception */ public void testWrite_TwoSingleBlockElements() throws Exception { // SETUP String fileName = "testWrite_TwoSingleBlockElements"; File file = new File( rafDir, fileName + ".data" ); file.delete(); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK int bytes = 1 * 1024; int[] blocks1 = disk.write( new byte[bytes] ); int[] blocks2 = disk.write( new byte[bytes] ); // VERIFY assertEquals( "Wrong number of blocks recorded.", 2, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", 1, blocks1.length ); assertEquals( "Wrong block returned.", 0, blocks1[0] ); assertEquals( "Wrong number of blocks returned.", 1, blocks2.length ); assertEquals( "Wrong block returned.", 1, blocks2[0] ); }
/** * Test writing an element that takes 128 blocks. There was a byte in a for loop that limited the number to 127. I fixed this. * <p> * @throws Exception */ public void testWrite_128BlockElement() throws Exception { // SETUP int numBlocks = 128; String fileName = "testWrite_128BlockElement"; File file = new File( rafDir, fileName + ".data" ); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK // byte arrays encur 27 bytes of serialization overhead. int bytes = getBytesForBlocksOfByteArrays( disk.getBlockSizeBytes(), numBlocks ); int[] blocks = disk.write( new byte[bytes] ); // VERIFY assertEquals( "Wrong number of blocks recorded.", numBlocks, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", numBlocks, blocks.length ); assertEquals( "Wrong block returned.", 0, blocks[0] ); }
/** * Test writing an element that takes two blocks. * <p> * @throws Exception */ public void testWrite_DoubleBlockElement() throws Exception { // SETUP String fileName = "testWriteDoubleBlockElement"; File file = new File( rafDir, fileName + ".data" ); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK // byte arrays encur 27 bytes of serialization overhead. int bytes = getBytesForBlocksOfByteArrays( disk.getBlockSizeBytes(), 2 ); int[] blocks = disk.write( new byte[bytes] ); // VERIFY assertEquals( "Wrong number of blocks recorded.", 2, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", 2, blocks.length ); assertEquals( "Wrong block returned.", 0, blocks[0] ); }
/** * Test writing an element that takes two blocks. * <p> * @throws Exception */ public void testWrite_DoubleBlockElement() throws Exception { // SETUP String fileName = "testWriteDoubleBlockElement"; File file = new File( rafDir, fileName + ".data" ); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK // byte arrays encur 27 bytes of serialization overhead. int bytes = getBytesForBlocksOfByteArrays( disk.getBlockSizeBytes(), 2 ); int[] blocks = disk.write( new byte[bytes] ); // VERIFY assertEquals( "Wrong number of blocks recorded.", 2, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", 2, blocks.length ); assertEquals( "Wrong block returned.", 0, blocks[0] ); }
/** * Test writing an element that takes 128 blocks. There was a byte in a for loop that limited the number to 127. I fixed this. * <p> * @throws Exception */ public void testWrite_128BlockElement() throws Exception { // SETUP int numBlocks = 128; String fileName = "testWrite_128BlockElement"; File file = new File( rafDir, fileName + ".data" ); BlockDisk disk = new BlockDisk( file, new StandardSerializer() ); // DO WORK // byte arrays encur 27 bytes of serialization overhead. int bytes = getBytesForBlocksOfByteArrays( disk.getBlockSizeBytes(), numBlocks ); int[] blocks = disk.write( new byte[bytes] ); // VERIFY assertEquals( "Wrong number of blocks recorded.", numBlocks, disk.getNumberOfBlocks() ); assertEquals( "Wrong number of blocks returned.", numBlocks, blocks.length ); assertEquals( "Wrong block returned.", 0, blocks[0] ); }