public virtual void TestVerifyChecksum() { Path testPath = new Path(TestRootDir, "testPath"); Path testPath11 = new Path(TestRootDir, "testPath11"); FSDataOutputStream fout = localFs.Create(testPath); fout.Write(Runtime.GetBytesForString("testing")); fout.Close(); fout = localFs.Create(testPath11); fout.Write(Runtime.GetBytesForString("testing you")); fout.Close(); // Exercise some boundary cases - a divisor of the chunk size // the chunk size, 2x chunk size, and +/-1 around these. FileSystemTestHelper.ReadFile(localFs, testPath, 128); FileSystemTestHelper.ReadFile(localFs, testPath, 511); FileSystemTestHelper.ReadFile(localFs, testPath, 512); FileSystemTestHelper.ReadFile(localFs, testPath, 513); FileSystemTestHelper.ReadFile(localFs, testPath, 1023); FileSystemTestHelper.ReadFile(localFs, testPath, 1024); FileSystemTestHelper.ReadFile(localFs, testPath, 1025); localFs.Delete(localFs.GetChecksumFile(testPath), true); Assert.True("checksum deleted", !localFs.Exists(localFs.GetChecksumFile (testPath))); //copying the wrong checksum file FileUtil.Copy(localFs, localFs.GetChecksumFile(testPath11), localFs, localFs.GetChecksumFile (testPath), false, true, localFs.GetConf()); Assert.True("checksum exists", localFs.Exists(localFs.GetChecksumFile (testPath))); bool errorRead = false; try { FileSystemTestHelper.ReadFile(localFs, testPath, 1024); } catch (ChecksumException) { errorRead = true; } Assert.True("error reading", errorRead); //now setting verify false, the read should succeed localFs.SetVerifyChecksum(false); string str = FileSystemTestHelper.ReadFile(localFs, testPath, 1024).ToString(); Assert.True("read", "testing".Equals(str)); }