### Question:
ZeroBuffer { public static void put(ByteBuffer dst) { put(dst, dst.remaining()); }  static void put(ByteBuffer dst); static void put(ByteBuffer dst, int length); static ByteBuffer readOnlyBuffer(int length);  }### Answer:
@Test public void testPut() { ByteBuffer testBuffer; byte[] testBufferArray; Random rand = new Random(); testBuffer = ByteBuffer.allocate(5); testBufferArray = testBuffer.array(); testBufferArray[4] = 7; Assert.assertFalse("Test1 - It is supposed to contain non-zero byte", isFilledWithZeros(testBufferArray, 0, 5)); ZeroBuffer.put(testBuffer); Assert.assertTrue("Test1 - After calling, ZeroBuffer.put There aren't supposed to be non-zero bytes", isFilledWithZeros(testBufferArray, 0, 5)); testBuffer = ByteBuffer.allocate(64 * 1024); testBufferArray = testBuffer.array(); rand.nextBytes(testBufferArray); Assert.assertFalse("Test2 - It is supposed to contain random non-zero bytes", isFilledWithZeros(testBufferArray, 0, 64 * 1024)); ZeroBuffer.put(testBuffer); Assert.assertTrue("Test2 - After calling, ZeroBuffer.put There aren't supposed to be non-zero bytes", isFilledWithZeros(testBufferArray, 0, 64 * 1024)); testBuffer = ByteBuffer.allocate(256 * 1024); testBufferArray = testBuffer.array(); rand.nextBytes(testBufferArray); Assert.assertFalse("Test3 - It is supposed to contain random non-zero bytes", isFilledWithZeros(testBufferArray, 64 * 1024, 64 * 1024)); testBuffer.position(64 * 1024); ZeroBuffer.put(testBuffer, 64 * 1024); Assert.assertTrue( "Test3 - After calling, ZeroBuffer.put There aren't supposed to be non-zero bytes " + "in the particular section", isFilledWithZeros(testBufferArray, 64 * 1024, 64 * 1024)); Assert.assertFalse("Test3 - After calling, ZeroBuffer.put other sections shouldnt be touched", isFilledWithZeros(testBufferArray, 0, 64 * 1024)); Assert.assertFalse("Test3 - After calling, ZeroBuffer.put other sections shouldnt be touched", isFilledWithZeros(testBufferArray, 128 * 1024, 128 * 1024)); }