Skip to content

Commit 2fcd2b7

Browse files
committed
HADOOP-19415. Fix CheckStyle Issue.
1 parent ea1fad4 commit 2fcd2b7

15 files changed

+237
-224
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBloomMapFile.java

+11-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
package org.apache.hadoop.io;
2020

21-
import static org.mockito.Mockito.*;
21+
import static org.mockito.Mockito.mock;
22+
import static org.mockito.Mockito.spy;
23+
import static org.mockito.Mockito.when;
2224

2325
import java.io.IOException;
2426
import java.io.InputStream;
@@ -134,8 +136,8 @@ private void checkMembershipVaryingSizedKeys(List<Text> keys)
134136
reader = new BloomMapFile.Reader(fs, qualifiedDirName.toString(), conf);
135137
Collections.reverse(keys);
136138
for (Text key : keys) {
137-
assertTrue(
138-
reader.probablyHasKey(key), "False negative for existing key " + key);
139+
assertTrue(reader.probablyHasKey(key),
140+
"False negative for existing key " + key);
139141
}
140142
reader.close();
141143
fs.delete(qualifiedDirName, true);
@@ -201,8 +203,8 @@ public void testIOExceptionInWriterConstructor() {
201203
reader = new BloomMapFile.Reader(dirNameSpy, conf,
202204
MapFile.Reader.comparator(new WritableComparator(IntWritable.class)));
203205

204-
assertNull(
205-
reader.getBloomFilter(), "testIOExceptionInWriterConstructor error !!!");
206+
assertNull(reader.getBloomFilter(),
207+
"testIOExceptionInWriterConstructor error !!!");
206208
} catch (Exception ex) {
207209
fail("unexpect ex in testIOExceptionInWriterConstructor !!!");
208210
} finally {
@@ -232,12 +234,12 @@ public void testGetBloomMapFile() {
232234
MapFile.Reader.comparator(new WritableComparator(IntWritable.class)));
233235

234236
for (int i = 0; i < SIZE; i++) {
235-
assertNotNull(
236-
reader.get(new IntWritable(i), new Text()), "testGetBloomMapFile error !!!");
237+
assertNotNull(reader.get(new IntWritable(i), new Text()),
238+
"testGetBloomMapFile error !!!");
237239
}
238240

239-
assertNull(
240-
reader.get(new IntWritable(SIZE + 5), new Text()), "testGetBloomMapFile error !!!");
241+
assertNull(reader.get(new IntWritable(SIZE + 5), new Text()),
242+
"testGetBloomMapFile error !!!");
241243
} catch (Exception ex) {
242244
fail("unexpect ex in testGetBloomMapFile !!!");
243245
} finally {

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBooleanWritable.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import java.io.IOException;
2121

2222
import org.junit.jupiter.api.Test;
23-
import static org.junit.jupiter.api.Assertions.*;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertFalse;
25+
import static org.junit.jupiter.api.Assertions.assertTrue;
2426

2527
public class TestBooleanWritable {
2628

@@ -64,7 +66,7 @@ public void testCommonMethods() {
6466
assertTrue(newInstance(true).compareTo(newInstance(false)) > 0, "testCommonMethods6 error !!!" );
6567
assertTrue(newInstance(false).compareTo(newInstance(true)) < 0, "testCommonMethods7 error !!!" );
6668
assertTrue(newInstance(false).compareTo(newInstance(false)) == 0, "testCommonMethods8 error !!!" );
67-
assertEquals("testCommonMethods9 error !!!", "true", newInstance(true).toString());
69+
assertEquals("true", newInstance(true).toString(), "testCommonMethods9 error !!!");
6870
}
6971

7072
private boolean checkHashCode(BooleanWritable f, BooleanWritable s) {

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBoundedByteArrayOutputStream.java

+22-22
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public void testBoundedStream() throws IOException {
4444

4545
// Write to the stream, get the data back and check for contents
4646
stream.write(INPUT, 0, SIZE);
47-
assertTrue(
48-
Arrays.equals(INPUT, stream.getBuffer()), "Array Contents Mismatch");
47+
assertTrue(Arrays.equals(INPUT, stream.getBuffer()),
48+
"Array Contents Mismatch");
4949

5050
// Try writing beyond end of buffer. Should throw an exception
5151
boolean caughtException = false;
@@ -56,16 +56,16 @@ public void testBoundedStream() throws IOException {
5656
caughtException = true;
5757
}
5858

59-
assertTrue(
60-
caughtException, "Writing beyond limit did not throw an exception");
59+
assertTrue(caughtException,
60+
"Writing beyond limit did not throw an exception");
6161

6262
//Reset the stream and try, should succeed
6363
stream.reset();
64-
assertTrue(
65-
(stream.getLimit() == SIZE), "Limit did not get reset correctly");
64+
assertTrue((stream.getLimit() == SIZE),
65+
"Limit did not get reset correctly");
6666
stream.write(INPUT, 0, SIZE);
67-
assertTrue(
68-
Arrays.equals(INPUT, stream.getBuffer()), "Array Contents Mismatch");
67+
assertTrue(Arrays.equals(INPUT, stream.getBuffer()),
68+
"Array Contents Mismatch");
6969

7070
// Try writing one more byte, should fail
7171
caughtException = false;
@@ -78,8 +78,8 @@ public void testBoundedStream() throws IOException {
7878
// Reset the stream, but set a lower limit. Writing beyond
7979
// the limit should throw an exception
8080
stream.reset(SIZE - 1);
81-
assertTrue(
82-
(stream.getLimit() == SIZE -1), "Limit did not get reset correctly");
81+
assertTrue((stream.getLimit() == SIZE -1),
82+
"Limit did not get reset correctly");
8383
caughtException = false;
8484

8585
try {
@@ -88,8 +88,8 @@ public void testBoundedStream() throws IOException {
8888
caughtException = true;
8989
}
9090

91-
assertTrue(
92-
caughtException, "Writing beyond limit did not throw an exception");
91+
assertTrue(caughtException,
92+
"Writing beyond limit did not throw an exception");
9393
}
9494

9595

@@ -114,8 +114,8 @@ public void testResetBuffer() throws IOException {
114114

115115
// Write to the stream, get the data back and check for contents
116116
stream.write(INPUT, 0, SIZE);
117-
assertTrue(
118-
Arrays.equals(INPUT, stream.getBuffer()), "Array Contents Mismatch");
117+
assertTrue(Arrays.equals(INPUT, stream.getBuffer()),
118+
"Array Contents Mismatch");
119119

120120
// Try writing beyond end of buffer. Should throw an exception
121121
boolean caughtException = false;
@@ -126,17 +126,17 @@ public void testResetBuffer() throws IOException {
126126
caughtException = true;
127127
}
128128

129-
assertTrue(
130-
caughtException, "Writing beyond limit did not throw an exception");
129+
assertTrue(caughtException,
130+
"Writing beyond limit did not throw an exception");
131131

132132
//Reset the stream and try, should succeed
133133
byte[] newBuf = new byte[SIZE];
134134
stream.resetBuffer(newBuf, 0, newBuf.length);
135-
assertTrue(
136-
(stream.getLimit() == SIZE), "Limit did not get reset correctly");
135+
assertTrue((stream.getLimit() == SIZE),
136+
"Limit did not get reset correctly");
137137
stream.write(INPUT, 0, SIZE);
138-
assertTrue(
139-
Arrays.equals(INPUT, stream.getBuffer()), "Array Contents Mismatch");
138+
assertTrue(Arrays.equals(INPUT, stream.getBuffer()),
139+
"Array Contents Mismatch");
140140

141141
// Try writing one more byte, should fail
142142
caughtException = false;
@@ -145,8 +145,8 @@ public void testResetBuffer() throws IOException {
145145
} catch (Exception e) {
146146
caughtException = true;
147147
}
148-
assertTrue(
149-
caughtException, "Writing beyond limit did not throw an exception");
148+
assertTrue(caughtException,
149+
"Writing beyond limit did not throw an exception");
150150
}
151151

152152
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBytesWritable.java

+17-15
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,28 @@ public void testZeroCopy() {
112112
BytesWritable zeroBuf = new BytesWritable(bytes, bytes.length); // new
113113
BytesWritable copyBuf = new BytesWritable(bytes); // old
114114
// using zero copy constructor shouldn't result in a copy
115-
assertTrue(
116-
bytes == zeroBuf.getBytes(), "copy took place, backing array != array passed to constructor");
117-
assertTrue(zeroBuf.getLength() == bytes.length, "length of BW should backing byte array");
118-
assertEquals(zeroBuf, copyBuf, "objects with same backing array should be equal");
119-
assertEquals("string repr of objects with same backing array should be equal",
120-
zeroBuf.toString(), copyBuf.toString());
121-
assertTrue(
122-
zeroBuf.compareTo(copyBuf) == 0, "compare order objects with same backing array should be equal");
123-
assertTrue(
124-
zeroBuf.hashCode() == copyBuf.hashCode(), "hash of objects with same backing array should be equal");
115+
assertTrue(bytes == zeroBuf.getBytes(),
116+
"copy took place, backing array != array passed to constructor");
117+
assertTrue(zeroBuf.getLength() == bytes.length,
118+
"length of BW should backing byte array");
119+
assertEquals(zeroBuf, copyBuf,
120+
"objects with same backing array should be equal");
121+
assertEquals(zeroBuf.toString(), copyBuf.toString(),
122+
"string repr of objects with same backing array should be equal");
123+
assertTrue(zeroBuf.compareTo(copyBuf) == 0,
124+
"compare order objects with same backing array should be equal");
125+
assertTrue(zeroBuf.hashCode() == copyBuf.hashCode(),
126+
"hash of objects with same backing array should be equal");
125127

126128
// ensure expanding buffer is handled correctly
127129
// for buffers created with zero copy api
128130
byte[] buffer = new byte[bytes.length * 5];
129131
zeroBuf.set(buffer, 0, buffer.length); // expand internal buffer
130132
zeroBuf.set(bytes, 0, bytes.length); // set back to normal contents
131-
assertEquals(
132-
zeroBuf, copyBuf, "buffer created with (array, len) has bad contents");
133-
assertTrue(
134-
zeroBuf.getLength() == copyBuf.getLength(), "buffer created with (array, len) has bad length");
133+
assertEquals(zeroBuf, copyBuf,
134+
"buffer created with (array, len) has bad contents");
135+
assertTrue(zeroBuf.getLength() == copyBuf.getLength(),
136+
"buffer created with (array, len) has bad length");
135137
}
136138

137139
/**
@@ -150,7 +152,7 @@ public void testObjectCommonMethods() {
150152
assertTrue(bw.equals(new ByteWritable((byte)0x9)), "testSetByteWritable equals error !!!");
151153
assertTrue(! bw.equals(new ByteWritable((byte)0xA)), "testSetByteWritable equals error !!!");
152154
assertTrue(! bw.equals(new IntWritable(1)), "testSetByteWritable equals error !!!");
153-
assertEquals("testSetByteWritable error ", "9", bw.toString());
155+
assertEquals("9", bw.toString(), "testSetByteWritable error ");
154156
}
155157

156158
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestDataByteBuffers.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
import java.util.Random;
2626

2727
import org.junit.jupiter.api.Test;
28-
import static org.junit.jupiter.api.Assertions.*;
28+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
29+
import static org.junit.jupiter.api.Assertions.assertEquals;
2930

3031
public class TestDataByteBuffers {
3132

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestDefaultStringifier.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public void testStoreLoad() throws IOException {
9393
DefaultStringifier.store(conf,text, keyName);
9494

9595
Text claimedText = DefaultStringifier.load(conf, keyName, Text.class);
96-
assertEquals(
97-
text, claimedText, "DefaultStringifier#load() or #store() might be flawed");
96+
assertEquals(text, claimedText,
97+
"DefaultStringifier#load() or #store() might be flawed");
9898

9999
}
100100

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestEnumSetWritable.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,11 @@ public void testEnumSetWritableEquals() {
135135
EnumSetWritable<TestEnumSet> eset2 = new EnumSetWritable<TestEnumSet>(
136136
EnumSet.of(TestEnumSet.APPEND, TestEnumSet.CREATE), TestEnumSet.class);
137137
assertTrue(eset1.equals(eset2), "testEnumSetWritableEquals error !!!");
138-
assertFalse(
139-
eset1.equals(new EnumSetWritable<TestEnumSet>(EnumSet.of(
140-
TestEnumSet.APPEND, TestEnumSet.CREATE, TestEnumSet.OVERWRITE),
141-
TestEnumSet.class)), "testEnumSetWritableEquals error !!!");
142-
assertTrue(eset1
143-
.getElementType().equals(TestEnumSet.class), "testEnumSetWritableEquals getElementType error !!!");
138+
assertFalse(eset1.equals(new EnumSetWritable<TestEnumSet>(EnumSet.of(
139+
TestEnumSet.APPEND, TestEnumSet.CREATE, TestEnumSet.OVERWRITE),
140+
TestEnumSet.class)), "testEnumSetWritableEquals error !!!");
141+
assertTrue(eset1.getElementType().equals(TestEnumSet.class),
142+
"testEnumSetWritableEquals getElementType error !!!");
144143
}
145144

146145
/**
@@ -163,8 +162,8 @@ public void testEnumSetWritableWriteRead() throws Exception {
163162
Iterator<TestEnumSet> dstIter = result.iterator();
164163
Iterator<TestEnumSet> srcIter = srcSet.iterator();
165164
while (dstIter.hasNext() && srcIter.hasNext()) {
166-
assertEquals(dstIter.next()
167-
, srcIter.next(), "testEnumSetWritableWriteRead error !!!");
165+
assertEquals(dstIter.next(), srcIter.next(),
166+
"testEnumSetWritableWriteRead error !!!");
168167
}
169168
}
170169
}

0 commit comments

Comments
 (0)