/** * Verify the given buffers of data and checksums, and throw an exception * if any checksum is invalid. The buffers given to this function should * have their position initially at the start of the data, and their limit * set at the end of the data. The position, limit, and mark are not * modified. * * @param bytesPerSum the chunk size (eg 512 bytes) * @param checksumType the DataChecksum type constant * @param sums the DirectByteBuffer pointing at the beginning of the * stored checksums * @param data the DirectByteBuffer pointing at the beginning of the * data to check * @param basePos the position in the file where the data buffer starts * @param fileName the name of the file being verified * @throws ChecksumException if there is an invalid checksum */ public static void verifyChunkedSums(int bytesPerSum, int checksumType, ByteBuffer sums, ByteBuffer data, String fileName, long basePos) throws ChecksumException { nativeVerifyChunkedSums(bytesPerSum, checksumType, sums, sums.position(), data, data.position(), data.remaining(), fileName, basePos); }
@Test @SuppressWarnings("deprecation") public void testNativeVerifyChunkedSumsSuccess() throws ChecksumException { allocateDirectByteBuffers(); fillDataAndValidChecksums(); NativeCrc32.nativeVerifyChunkedSums(bytesPerChecksum, checksumType.id, checksums, checksums.position(), data, data.position(), data.remaining(), fileName, BASE_POSITION); }
@Test @SuppressWarnings("deprecation") public void testNativeVerifyChunkedSumsSuccess() throws ChecksumException { allocateDirectByteBuffers(); fillDataAndValidChecksums(); NativeCrc32.nativeVerifyChunkedSums(bytesPerChecksum, checksumType.id, checksums, checksums.position(), data, data.position(), data.remaining(), fileName, BASE_POSITION); }
@Test @SuppressWarnings("deprecation") public void testNativeVerifyChunkedSumsFail() throws ChecksumException { allocateDirectByteBuffers(); fillDataAndInvalidChecksums(); exception.expect(ChecksumException.class); NativeCrc32.nativeVerifyChunkedSums(bytesPerChecksum, checksumType.id, checksums, checksums.position(), data, data.position(), data.remaining(), fileName, BASE_POSITION); }
@Test @SuppressWarnings("deprecation") public void testNativeVerifyChunkedSumsFail() throws ChecksumException { allocateDirectByteBuffers(); fillDataAndInvalidChecksums(); exception.expect(ChecksumException.class); NativeCrc32.nativeVerifyChunkedSums(bytesPerChecksum, checksumType.id, checksums, checksums.position(), data, data.position(), data.remaining(), fileName, BASE_POSITION); }