HADOOP-14709. Fix checkstyle warnings in ContractTestUtils.
Contributed by Thomas Marquardt. (cherry picked from commit cb4679261097e729b433a523e3a65779fdc83841)
This commit is contained in:
parent
f9139ac8f6
commit
5e4434f628
@ -70,7 +70,8 @@ public class ContractTestUtils extends Assert {
|
|||||||
* Assert that a property in the property set matches the expected value.
|
* Assert that a property in the property set matches the expected value.
|
||||||
* @param props property set
|
* @param props property set
|
||||||
* @param key property name
|
* @param key property name
|
||||||
* @param expected expected value. If null, the property must not be in the set
|
* @param expected expected value. If null, the property must not be in the
|
||||||
|
* set
|
||||||
*/
|
*/
|
||||||
public static void assertPropertyEquals(Properties props,
|
public static void assertPropertyEquals(Properties props,
|
||||||
String key,
|
String key,
|
||||||
@ -232,7 +233,7 @@ public static void verifyFileContents(FileSystem fs,
|
|||||||
assertTrue("not a file " + statText, stat.isFile());
|
assertTrue("not a file " + statText, stat.isFile());
|
||||||
assertEquals("wrong length " + statText, original.length, stat.getLen());
|
assertEquals("wrong length " + statText, original.length, stat.getLen());
|
||||||
byte[] bytes = readDataset(fs, path, original.length);
|
byte[] bytes = readDataset(fs, path, original.length);
|
||||||
compareByteArrays(original,bytes,original.length);
|
compareByteArrays(original, bytes, original.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,7 +252,7 @@ public static void verifyRead(FSDataInputStream stm, byte[] fileContents,
|
|||||||
stm.readFully(out);
|
stm.readFully(out);
|
||||||
byte[] expected = Arrays.copyOfRange(fileContents, seekOff,
|
byte[] expected = Arrays.copyOfRange(fileContents, seekOff,
|
||||||
seekOff + toRead);
|
seekOff + toRead);
|
||||||
compareByteArrays(expected, out,toRead);
|
compareByteArrays(expected, out, toRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,11 +269,11 @@ public static void compareByteArrays(byte[] original,
|
|||||||
assertEquals("Number of bytes read != number written",
|
assertEquals("Number of bytes read != number written",
|
||||||
len, received.length);
|
len, received.length);
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
int first_error_byte = -1;
|
int firstErrorByte = -1;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
if (original[i] != received[i]) {
|
if (original[i] != received[i]) {
|
||||||
if (errors == 0) {
|
if (errors == 0) {
|
||||||
first_error_byte = i;
|
firstErrorByte = i;
|
||||||
}
|
}
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -285,8 +286,8 @@ public static void compareByteArrays(byte[] original,
|
|||||||
// the range either side of the first error to print
|
// the range either side of the first error to print
|
||||||
// this is a purely arbitrary number, to aid user debugging
|
// this is a purely arbitrary number, to aid user debugging
|
||||||
final int overlap = 10;
|
final int overlap = 10;
|
||||||
for (int i = Math.max(0, first_error_byte - overlap);
|
for (int i = Math.max(0, firstErrorByte - overlap);
|
||||||
i < Math.min(first_error_byte + overlap, len);
|
i < Math.min(firstErrorByte + overlap, len);
|
||||||
i++) {
|
i++) {
|
||||||
byte actual = received[i];
|
byte actual = received[i];
|
||||||
byte expected = original[i];
|
byte expected = original[i];
|
||||||
@ -479,7 +480,7 @@ public static void noteAction(String action) {
|
|||||||
public static void downgrade(String message, Throwable failure) {
|
public static void downgrade(String message, Throwable failure) {
|
||||||
LOG.warn("Downgrading test " + message, failure);
|
LOG.warn("Downgrading test " + message, failure);
|
||||||
AssumptionViolatedException ave =
|
AssumptionViolatedException ave =
|
||||||
new AssumptionViolatedException(failure, null);
|
new AssumptionViolatedException(failure, null);
|
||||||
throw ave;
|
throw ave;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,9 +524,9 @@ public static void assertFileHasLength(FileSystem fs, Path path,
|
|||||||
int expected) throws IOException {
|
int expected) throws IOException {
|
||||||
FileStatus status = fs.getFileStatus(path);
|
FileStatus status = fs.getFileStatus(path);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong file length of file " + path + " status: " + status,
|
"Wrong file length of file " + path + " status: " + status,
|
||||||
expected,
|
expected,
|
||||||
status.getLen());
|
status.getLen());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -711,7 +712,8 @@ public static String fileStatsToString(FileStatus[] stats, String separator) {
|
|||||||
*/
|
*/
|
||||||
public static String ls(FileSystem fileSystem, Path path) throws IOException {
|
public static String ls(FileSystem fileSystem, Path path) throws IOException {
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
//surfaces when someone calls getParent() on something at the top of the path
|
// surfaces when someone calls getParent() on something at the top of the
|
||||||
|
// path
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
FileStatus[] stats;
|
FileStatus[] stats;
|
||||||
@ -893,7 +895,7 @@ public static void assertListStatusFinds(FileSystem fs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for the host being an OSX machine
|
* Test for the host being an OSX machine.
|
||||||
* @return true if the JVM thinks that is running on OSX
|
* @return true if the JVM thinks that is running on OSX
|
||||||
*/
|
*/
|
||||||
public static boolean isOSX() {
|
public static boolean isOSX() {
|
||||||
@ -916,8 +918,9 @@ public static void validateFileContent(byte[] concat, byte[][] bytes) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mismatch)
|
if (mismatch) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assertFalse("File content of file is not as expected at offset " + idx,
|
assertFalse("File content of file is not as expected at offset " + idx,
|
||||||
mismatch);
|
mismatch);
|
||||||
@ -1027,7 +1030,9 @@ public static long generateTestFile(FileSystem fs, Path path,
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* thrown if an I/O error occurs while writing or reading the test file
|
* thrown if an I/O error occurs while writing or reading the test file
|
||||||
*/
|
*/
|
||||||
public static void createAndVerifyFile(FileSystem fs, Path parent, final long fileSize)
|
public static void createAndVerifyFile(FileSystem fs,
|
||||||
|
Path parent,
|
||||||
|
final long fileSize)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
int testBufferSize = fs.getConf()
|
int testBufferSize = fs.getConf()
|
||||||
.getInt(IO_CHUNK_BUFFER_SIZE, DEFAULT_IO_CHUNK_BUFFER_SIZE);
|
.getInt(IO_CHUNK_BUFFER_SIZE, DEFAULT_IO_CHUNK_BUFFER_SIZE);
|
||||||
|
Loading…
Reference in New Issue
Block a user