Skip to content

Commit e9a1d51

Browse files
committed
HADOOP-19415. Fix Junit Test Error & CheckStyle Issue.
1 parent 1e5260f commit e9a1d51

19 files changed

+177
-179
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,15 @@ private void validateAndSetWritablePermissions(
429429
grantPermissions(xSubSubDir);
430430

431431
assertFalse(ret, "The return value should have been false.");
432-
assertTrue(new File(del, FILE_1_NAME).exists(),
432+
assertTrue(new File(del, FILE_1_NAME).exists(),
433433
"The file file1 should not have been deleted.");
434-
assertEquals(expectedRevokedPermissionDirsExist, xSubDir.exists(),
434+
assertEquals(expectedRevokedPermissionDirsExist, xSubDir.exists(),
435435
"The directory xSubDir *should* not have been deleted.");
436-
assertEquals(expectedRevokedPermissionDirsExist, file2.exists(),
436+
assertEquals(expectedRevokedPermissionDirsExist, file2.exists(),
437437
"The file file2 *should* not have been deleted.");
438-
assertEquals(expectedRevokedPermissionDirsExist, xSubSubDir.exists(),
438+
assertEquals(expectedRevokedPermissionDirsExist, xSubSubDir.exists(),
439439
"The directory xSubSubDir *should* not have been deleted.");
440-
assertEquals(expectedRevokedPermissionDirsExist, file22.exists(),
440+
assertEquals(expectedRevokedPermissionDirsExist, file22.exists(),
441441
"The file file22 *should* not have been deleted.");
442442
assertFalse(ySubDir.exists(), "The directory ySubDir should have been deleted.");
443443
assertFalse(zlink.exists(), "The link zlink should have been deleted.");
@@ -1317,7 +1317,7 @@ public void testCreateJarWithClassPath() throws Exception {
13171317
new File(tmp, "wildcard2.jar"), new File(tmp, "wildcard3.JAR"),
13181318
new File(tmp, "wildcard4.JAR"));
13191319
for (File wildcardMatch: wildcardMatches) {
1320-
assertTrue(wildcardMatch.createNewFile(),
1320+
assertTrue(wildcardMatch.createNewFile(),
13211321
"failure creating file: " + wildcardMatch);
13221322
}
13231323

@@ -1333,11 +1333,11 @@ public void testCreateJarWithClassPath() throws Exception {
13331333
List<String> classPaths = Arrays.asList("", "cp1.jar", "cp2.jar", wildcardPath,
13341334
"cp3.jar", nonExistentSubdir);
13351335
String inputClassPath = StringUtils.join(File.pathSeparator, classPaths);
1336-
String[] jarCp = FileUtil.createJarWithClassPath(inputClassPath +
1336+
String[] jarCp = FileUtil.createJarWithClassPath(inputClassPath +
13371337
File.pathSeparator + "unexpandedwildcard/*",
13381338
new Path(tmp.getCanonicalPath()), System.getenv());
13391339
String classPathJar = jarCp[0];
1340-
assertNotEquals(jarCp[1].indexOf("unexpanded"), -1,
1340+
assertNotEquals(jarCp[1].indexOf("unexpanded"), -1,
13411341
"Unexpanded wildcard was not placed in extra classpath");
13421342

13431343
// verify classpath by reading manifest from jar file
@@ -1399,7 +1399,7 @@ public void testCreateJarWithClassPath() throws Exception {
13991399
@Test
14001400
public void testGetJarsInDirectory() throws Exception {
14011401
List<Path> jars = FileUtil.getJarsInDirectory("/foo/bar/bogus/");
1402-
assertTrue(jars.isEmpty(),
1402+
assertTrue(jars.isEmpty(),
14031403
"no jars should be returned for a bogus path");
14041404

14051405

@@ -1423,7 +1423,7 @@ public void testGetJarsInDirectory() throws Exception {
14231423
for (Path jar: jars) {
14241424
URL url = jar.toUri().toURL();
14251425
assertTrue(url.equals(jar1.getCanonicalFile().toURI().toURL()) ||
1426-
url.equals(jar2.getCanonicalFile().toURI().toURL()),
1426+
url.equals(jar2.getCanonicalFile().toURI().toURL()),
14271427
"the jar should match either of the jars");
14281428
}
14291429
}
@@ -1549,25 +1549,25 @@ public void testCreateArbitrarySymlinkUsingJava() throws IOException {
15491549
File rootDir = new File("tmp");
15501550
try (TarArchiveOutputStream tos = new TarArchiveOutputStream(os)) {
15511551
tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
1552-
1552+
15531553
// Create arbitrary dir
15541554
File arbitraryDir = new File(rootDir, "arbitrary-dir/");
15551555
Verify.mkdirs(arbitraryDir);
1556-
1556+
15571557
// We will tar from the tar-root lineage
15581558
File tarRoot = new File(rootDir, "tar-root/");
15591559
File symlinkRoot = new File(tarRoot, "dir1/");
15601560
Verify.mkdirs(symlinkRoot);
1561-
1561+
15621562
// Create Symbolic Link to an arbitrary dir
15631563
java.nio.file.Path symLink = Paths.get(symlinkRoot.getPath(), "sl");
15641564
Files.createSymbolicLink(symLink, arbitraryDir.toPath().toAbsolutePath());
1565-
1565+
15661566
// Put entries in tar file
15671567
putEntriesInTar(tos, tarRoot);
15681568
putEntriesInTar(tos, new File(symLink.toFile(), "dir-outside-tar-root/"));
15691569
tos.close();
1570-
1570+
15711571
// Untar using Java
15721572
File untarFile = new File(rootDir, "extracted");
15731573
FileUtil.unTarUsingJava(simpleTar, untarFile, false);

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/ContractTestUtils.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static void writeDataset(FileSystem fs,
185185
public static void writeDataset(FileSystem fs, Path path, byte[] src,
186186
int len, int buffersize, boolean overwrite, boolean useBuilder)
187187
throws IOException {
188-
assertTrue(src.length >= len,
188+
assertTrue(src.length >= len,
189189
"Not enough data in source array to write " + len + " bytes");
190190
FSDataOutputStream out;
191191
if (useBuilder) {
@@ -340,7 +340,7 @@ public static void verifyRead(FSDataInputStream stm, byte[] fileContents,
340340
public static void compareByteArrays(byte[] original,
341341
byte[] received,
342342
int len) {
343-
assertEquals(len, received.length,
343+
assertEquals(len, received.length,
344344
"Number of bytes read != number written");
345345
int errors = 0;
346346
int firstErrorByte = -1;
@@ -485,7 +485,7 @@ public static boolean rm(FileSystem fileSystem,
485485
public static void rename(FileSystem fileSystem, Path src, Path dst)
486486
throws IOException {
487487
rejectRootOperation(src, false);
488-
assertTrue(fileSystem.rename(src, dst),
488+
assertTrue(fileSystem.rename(src, dst),
489489
"rename(" + src + ", " + dst + ") failed");
490490
assertPathDoesNotExist(fileSystem, "renamed source dir", src);
491491
}
@@ -613,7 +613,7 @@ public static Object fail(String text, Throwable thrown) {
613613
public static void assertFileHasLength(FileSystem fs, Path path,
614614
int expected) throws IOException {
615615
FileStatus status = fs.getFileStatus(path);
616-
assertEquals(expected, status.getLen(),
616+
assertEquals(expected, status.getLen(),
617617
"Wrong file length of file " + path + " status: " + status);
618618
}
619619

@@ -635,7 +635,7 @@ public static void assertIsDirectory(FileSystem fs,
635635
* @param fileStatus stats to check
636636
*/
637637
public static void assertIsDirectory(FileStatus fileStatus) {
638-
assertTrue(fileStatus.isDirectory(),
638+
assertTrue(fileStatus.isDirectory(),
639639
"Should be a directory -but isn't: " + fileStatus);
640640
}
641641

@@ -662,7 +662,7 @@ public static void assertErasureCoded(final FileSystem fs, final Path path)
662662
public static void assertNotErasureCoded(final FileSystem fs,
663663
final Path path) throws IOException {
664664
FileStatus fileStatus = fs.getFileStatus(path);
665-
assertFalse(fileStatus.isErasureCoded(),
665+
assertFalse(fileStatus.isErasureCoded(),
666666
path + " should not be erasure coded!");
667667
}
668668

@@ -962,9 +962,9 @@ public static void assertIsFile(FileContext fileContext, Path filename)
962962
*/
963963
public static void assertIsFile(Path filename, FileStatus status) {
964964
String fileInfo = filename + " " + status;
965-
assertFalse(status.isDirectory(),
965+
assertFalse(status.isDirectory(),
966966
"File claims to be a directory " + fileInfo);
967-
assertFalse(status.isSymlink(),
967+
assertFalse(status.isSymlink(),
968968
"File claims to be a symlink " + fileInfo);
969969
}
970970

@@ -1130,7 +1130,7 @@ public static void assertListStatusFinds(FileSystem fs,
11301130
found = true;
11311131
}
11321132
}
1133-
assertTrue(found,
1133+
assertTrue(found,
11341134
"Path " + subdir + " not found in directory " + dir + ":" + builder);
11351135
}
11361136

@@ -1174,7 +1174,7 @@ public static void validateFileContent(byte[] concat, byte[][] bytes) {
11741174
break;
11751175
}
11761176
}
1177-
assertFalse(mismatch,
1177+
assertFalse(mismatch,
11781178
"File content of file is not as expected at offset " + idx);
11791179
}
11801180

@@ -1710,21 +1710,21 @@ public static List<LocatedFileStatus> toListThroughNextCallsAlone(
17101710
public static void assertCapabilities(
17111711
Object stream, String[] shouldHaveCapabilities,
17121712
String[] shouldNotHaveCapabilities) {
1713-
assertTrue(stream instanceof StreamCapabilities,
1713+
assertTrue(stream instanceof StreamCapabilities,
17141714
"Stream should be instanceof StreamCapabilities");
17151715

17161716
StreamCapabilities source = (StreamCapabilities) stream;
17171717
if (shouldHaveCapabilities != null) {
17181718
for (String shouldHaveCapability : shouldHaveCapabilities) {
1719-
assertTrue(source.hasCapability(shouldHaveCapability),
1719+
assertTrue(source.hasCapability(shouldHaveCapability),
17201720
"Should have capability: " + shouldHaveCapability
17211721
+ " in " + source);
17221722
}
17231723
}
17241724

17251725
if (shouldNotHaveCapabilities != null) {
17261726
for (String shouldNotHaveCapability : shouldNotHaveCapabilities) {
1727-
assertFalse(source.hasCapability(shouldNotHaveCapability),
1727+
assertFalse(source.hasCapability(shouldNotHaveCapability),
17281728
"Should not have capability: " + shouldNotHaveCapability
17291729
+ " in " + source);
17301730
}
@@ -1772,7 +1772,7 @@ public static void assertHasPathCapabilities(
17721772
final String...capabilities) throws IOException {
17731773

17741774
for (String shouldHaveCapability: capabilities) {
1775-
assertTrue(source.hasPathCapability(path, shouldHaveCapability),
1775+
assertTrue(source.hasPathCapability(path, shouldHaveCapability),
17761776
"Should have capability: " + shouldHaveCapability
17771777
+ " under " + path
17781778
+ " in " + source);
@@ -1793,7 +1793,7 @@ public static void assertLacksPathCapabilities(
17931793
final String...capabilities) throws IOException {
17941794

17951795
for (String shouldHaveCapability: capabilities) {
1796-
assertFalse(source.hasPathCapability(path, shouldHaveCapability),
1796+
assertFalse(source.hasPathCapability(path, shouldHaveCapability),
17971797
"Path must not support capability: " + shouldHaveCapability
17981798
+ " under " + path);
17991799
}
@@ -2019,11 +2019,11 @@ public int hashCode() {
20192019
*/
20202020
public void assertSizeEquals(String text, long f, long d, long o) {
20212021
String self = dump();
2022-
assertEquals(f, getFileCount(),
2022+
assertEquals(f, getFileCount(),
20232023
text + ": file count in " + self);
2024-
assertEquals(d, getDirCount(),
2024+
assertEquals(d, getDirCount(),
20252025
text + ": directory count in " + self);
2026-
assertEquals(o, getOtherCount(),
2026+
assertEquals(o, getOtherCount(),
20272027
text + ": 'other' count in " + self);
20282028
}
20292029

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class TestTextCommand {
6565

6666
private static final String SEQUENCE_FILE_EXPECTED_OUTPUT =
6767
"Key1\tValue1" + SEPARATOR + "Key2\tValue2" + SEPARATOR;
68-
68+
6969
/**
7070
* Tests whether binary Avro data files are displayed correctly.
7171
*/

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ public void testWorkingDirectory() throws Exception {
321321

322322
@Test
323323
public void testResolvePath() throws IOException {
324-
assertEquals(chrootedTo, fSys.resolvePath(new Path("/")));
324+
assertEquals(chrootedTo, fSys.resolvePath(new Path("/")));
325325
fileSystemTestHelper.createFile(fSys, "/foo");
326326
assertEquals(new Path(chrootedTo, "foo"),
327327
fSys.resolvePath(new Path("/foo")));
328328
}
329329

330-
@Test
330+
@Test
331331
public void testResolvePathNonExisting() throws IOException {
332332
assertThrows(FileNotFoundException.class, () -> {
333333
fSys.resolvePath(new Path("/nonExisting"));

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void testNflyInvalidMinReplication() throws Exception {
122122
FileSystem.get(URI.create("viewfs://mt/"), conf);
123123
fail("Expected bad minReplication exception.");
124124
} catch (IOException ioe) {
125-
assertTrue(ioe.getMessage().contains("Minimum replication"),
125+
assertTrue(ioe.getMessage().contains("Minimum replication"),
126126
"No minReplication message");
127127
}
128128
}

0 commit comments

Comments
 (0)