Skip to content

Commit 289063e

Browse files
committed
HBASE-22786 Fixed Checkstyle issues in tests in hbase-client
Signed-off-by: stack <stack@apache.org>
1 parent 7b2c3f6 commit 289063e

18 files changed

+133
-129
lines changed

hbase-client/src/test/java/org/apache/hadoop/hbase/TestHColumnDescriptor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@
3838
import org.junit.experimental.categories.Category;
3939
import org.junit.rules.ExpectedException;
4040

41-
/** Tests the HColumnDescriptor with appropriate arguments */
41+
/**
42+
* Tests the HColumnDescriptor with appropriate arguments.
43+
*
44+
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 together with
45+
* {@link HColumnDescriptor}.
46+
*/
4247
@Category({MiscTests.class, SmallTests.class})
4348
@Deprecated
4449
public class TestHColumnDescriptor {

hbase-client/src/test/java/org/apache/hadoop/hbase/TestHTableDescriptor.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141

4242
/**
4343
* Test setting values in the descriptor
44+
*
45+
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 together with
46+
* {@link HTableDescriptor}.
4447
*/
4548
@Category({MiscTests.class, SmallTests.class})
4649
@Deprecated
@@ -117,8 +120,9 @@ public void testPb() throws DeserializationException, IOException {
117120
}
118121

119122
/**
120-
* Test cps in the table description
121-
* @throws Exception
123+
* Test cps in the table description.
124+
*
125+
* @throws Exception if adding a coprocessor fails
122126
*/
123127
@Test
124128
public void testGetSetRemoveCP() throws Exception {
@@ -134,8 +138,9 @@ public void testGetSetRemoveCP() throws Exception {
134138
}
135139

136140
/**
137-
* Test cps in the table description
138-
* @throws Exception
141+
* Test cps in the table description.
142+
*
143+
* @throws Exception if adding a coprocessor fails
139144
*/
140145
@Test
141146
public void testSetListRemoveCP() throws Exception {
@@ -172,10 +177,9 @@ public void testSetListRemoveCP() throws Exception {
172177

173178
/**
174179
* Test that we add and remove strings from settings properly.
175-
* @throws Exception
176180
*/
177181
@Test
178-
public void testAddGetRemoveString() throws Exception {
182+
public void testAddGetRemoveString() {
179183
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
180184
String key = "Some";
181185
String value = "value";
@@ -191,15 +195,15 @@ public void testAddGetRemoveString() throws Exception {
191195
assertEquals(null, desc.getValue(keyShouldNotNull));
192196
}
193197

194-
String legalTableNames[] = { "foo", "with-dash_under.dot", "_under_start_ok",
195-
"with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02"
196-
, "dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2",
197-
"trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02",
198-
"汉", "汉:字", "_字_", "foo:字", "foo.字", "字.foo"};
198+
String[] legalTableNames = { "foo", "with-dash_under.dot", "_under_start_ok",
199+
"with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02",
200+
"dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2",
201+
"trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02",
202+
"汉", "汉:字", "_字_", "foo:字", "foo.字", "字.foo"};
199203
// Avoiding "zookeeper" in here as it's tough to encode in regex
200-
String illegalTableNames[] = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
201-
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
202-
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2", String.valueOf((char)130),
204+
String[] illegalTableNames = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
205+
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
206+
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2", String.valueOf((char)130),
203207
String.valueOf((char)5), String.valueOf((char)65530)};
204208

205209
@Test

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAttributes.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
@Category({ClientTests.class, SmallTests.class})
3131
public class TestAttributes {
32-
3332
@ClassRule
3433
public static final HBaseClassTestRule CLASS_RULE =
3534
HBaseClassTestRule.forClass(TestAttributes.class);
@@ -49,19 +48,22 @@ public void testPutAttributes() {
4948
put.setAttribute("attribute1", Bytes.toBytes("value1"));
5049
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttribute("attribute1")));
5150
Assert.assertEquals(1, put.getAttributesMap().size());
52-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttributesMap().get("attribute1")));
51+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"),
52+
put.getAttributesMap().get("attribute1")));
5353

5454
// overriding attribute value
5555
put.setAttribute("attribute1", Bytes.toBytes("value12"));
5656
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttribute("attribute1")));
5757
Assert.assertEquals(1, put.getAttributesMap().size());
58-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttributesMap().get("attribute1")));
58+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"),
59+
put.getAttributesMap().get("attribute1")));
5960

6061
// adding another attribute
6162
put.setAttribute("attribute2", Bytes.toBytes("value2"));
6263
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttribute("attribute2")));
6364
Assert.assertEquals(2, put.getAttributesMap().size());
64-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttributesMap().get("attribute2")));
65+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"),
66+
put.getAttributesMap().get("attribute2")));
6567

6668
// removing attribute
6769
put.setAttribute("attribute2", null);
@@ -82,7 +84,6 @@ public void testPutAttributes() {
8284
Assert.assertNull(put.getAttributesMap().get("attribute1"));
8385
}
8486

85-
8687
@Test
8788
public void testDeleteAttributes() {
8889
Delete del = new Delete(new byte [] {'r'});
@@ -97,19 +98,22 @@ public void testDeleteAttributes() {
9798
del.setAttribute("attribute1", Bytes.toBytes("value1"));
9899
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), del.getAttribute("attribute1")));
99100
Assert.assertEquals(1, del.getAttributesMap().size());
100-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), del.getAttributesMap().get("attribute1")));
101+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"),
102+
del.getAttributesMap().get("attribute1")));
101103

102104
// overriding attribute value
103105
del.setAttribute("attribute1", Bytes.toBytes("value12"));
104106
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), del.getAttribute("attribute1")));
105107
Assert.assertEquals(1, del.getAttributesMap().size());
106-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), del.getAttributesMap().get("attribute1")));
108+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"),
109+
del.getAttributesMap().get("attribute1")));
107110

108111
// adding another attribute
109112
del.setAttribute("attribute2", Bytes.toBytes("value2"));
110113
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), del.getAttribute("attribute2")));
111114
Assert.assertEquals(2, del.getAttributesMap().size());
112-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), del.getAttributesMap().get("attribute2")));
115+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"),
116+
del.getAttributesMap().get("attribute2")));
113117

114118
// removing attribute
115119
del.setAttribute("attribute2", null);

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientExponentialBackoff.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
@Category({ClientTests.class, SmallTests.class})
4040
public class TestClientExponentialBackoff {
41-
4241
@ClassRule
4342
public static final HBaseClassTestRule CLASS_RULE =
4443
HBaseClassTestRule.forClass(TestClientExponentialBackoff.class);
@@ -149,7 +148,7 @@ public void testCompactionPressurePolicy() {
149148
backoffTime = backoff.getBackoffTime(server, regionname, stats);
150149
assertTrue("Compaction pressure has no effect", backoffTime == 0);
151150

152-
long previous = backoffTime;
151+
long previous = backoffTime;
153152
update(stats, 0, 0, 50);
154153
backoffTime = backoff.getBackoffTime(server, regionname, stats);
155154
assertTrue("Compaction pressure should be bigger",
@@ -163,8 +162,7 @@ public void testCompactionPressurePolicy() {
163162

164163
private void update(ServerStatistics stats, int load) {
165164
ClientProtos.RegionLoadStats stat = ClientProtos.RegionLoadStats.newBuilder()
166-
.setMemStoreLoad
167-
(load).build();
165+
.setMemStoreLoad(load).build();
168166
stats.update(regionname, ProtobufUtil.createRegionLoadStats(stat));
169167
}
170168

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestColumnFamilyDescriptorBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
@Category({MiscTests.class, SmallTests.class})
4646
public class TestColumnFamilyDescriptorBuilder {
47-
4847
@ClassRule
4948
public static final HBaseClassTestRule CLASS_RULE =
5049
HBaseClassTestRule.forClass(TestColumnFamilyDescriptorBuilder.class);
@@ -85,7 +84,8 @@ public void testBuilder() throws DeserializationException {
8584
assertTrue(hcd.equals(deserializedHcd));
8685
assertEquals(v, hcd.getBlocksize());
8786
assertEquals(v, hcd.getTimeToLive());
88-
assertTrue(Bytes.equals(hcd.getValue(Bytes.toBytes("a")), deserializedHcd.getValue(Bytes.toBytes("a"))));
87+
assertTrue(Bytes.equals(hcd.getValue(Bytes.toBytes("a")),
88+
deserializedHcd.getValue(Bytes.toBytes("a"))));
8989
assertEquals(hcd.getMaxVersions(), deserializedHcd.getMaxVersions());
9090
assertEquals(hcd.getMinVersions(), deserializedHcd.getMinVersions());
9191
assertEquals(hcd.getKeepDeletedCells(), deserializedHcd.getKeepDeletedCells());

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
// TODO: cover more test cases
5555
@Category({ClientTests.class, SmallTests.class})
5656
public class TestGet {
57-
5857
@ClassRule
5958
public static final HBaseClassTestRule CLASS_RULE =
6059
HBaseClassTestRule.forClass(TestGet.class);
@@ -122,19 +121,22 @@ public void testGetAttributes() {
122121
get.setAttribute("attribute1", Bytes.toBytes("value1"));
123122
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttribute("attribute1")));
124123
Assert.assertEquals(1, get.getAttributesMap().size());
125-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttributesMap().get("attribute1")));
124+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"),
125+
get.getAttributesMap().get("attribute1")));
126126

127127
// overriding attribute value
128128
get.setAttribute("attribute1", Bytes.toBytes("value12"));
129129
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttribute("attribute1")));
130130
Assert.assertEquals(1, get.getAttributesMap().size());
131-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttributesMap().get("attribute1")));
131+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"),
132+
get.getAttributesMap().get("attribute1")));
132133

133134
// adding another attribute
134135
get.setAttribute("attribute2", Bytes.toBytes("value2"));
135136
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttribute("attribute2")));
136137
Assert.assertEquals(2, get.getAttributesMap().size());
137-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttributesMap().get("attribute2")));
138+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"),
139+
get.getAttributesMap().get("attribute2")));
138140

139141
// removing attribute
140142
get.setAttribute("attribute2", null);

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestMetricsConnection.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050

5151
@Category({ClientTests.class, MetricsTests.class, SmallTests.class})
5252
public class TestMetricsConnection {
53-
5453
@ClassRule
5554
public static final HBaseClassTestRule CLASS_RULE =
5655
HBaseClassTestRule.forClass(TestMetricsConnection.class);
@@ -122,8 +121,8 @@ public void testStaticMetrics() throws IOException {
122121
MetricsConnection.newCallStats());
123122
}
124123
for (MetricsConnection.CallTracker t : new MetricsConnection.CallTracker[] {
125-
METRICS.getTracker, METRICS.scanTracker, METRICS.multiTracker, METRICS.appendTracker,
126-
METRICS.deleteTracker, METRICS.incrementTracker, METRICS.putTracker
124+
METRICS.getTracker, METRICS.scanTracker, METRICS.multiTracker, METRICS.appendTracker,
125+
METRICS.deleteTracker, METRICS.incrementTracker, METRICS.putTracker
127126
}) {
128127
assertEquals("Failed to invoke callTimer on " + t, loop, t.callTimer.getCount());
129128
assertEquals("Failed to invoke reqHist on " + t, loop, t.reqHist.getCount());

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
*/
7474
@Category({ClientTests.class, SmallTests.class})
7575
public class TestOperation {
76-
7776
@ClassRule
7877
public static final HBaseClassTestRule CLASS_RULE =
7978
HBaseClassTestRule.forClass(TestOperation.class);
@@ -281,11 +280,11 @@ public class TestOperation {
281280
/**
282281
* Test the client Operations' JSON encoding to ensure that produced JSON is
283282
* parseable and that the details are present and not corrupted.
284-
* @throws IOException
283+
*
284+
* @throws IOException if the JSON conversion fails
285285
*/
286286
@Test
287-
public void testOperationJSON()
288-
throws IOException {
287+
public void testOperationJSON() throws IOException {
289288
// produce a Scan Operation
290289
Scan scan = new Scan(ROW);
291290
scan.addColumn(FAMILY, QUALIFIER);
@@ -423,18 +422,17 @@ public void testOperationSubClassMethodsAreBuilderStyle() {
423422

424423
// TODO: We should ensure all subclasses of Operation is checked.
425424
Class[] classes = new Class[] {
426-
Operation.class,
427-
OperationWithAttributes.class,
428-
Mutation.class,
429-
Query.class,
430-
Delete.class,
431-
Increment.class,
432-
Append.class,
433-
Put.class,
434-
Get.class,
435-
Scan.class};
425+
Operation.class,
426+
OperationWithAttributes.class,
427+
Mutation.class,
428+
Query.class,
429+
Delete.class,
430+
Increment.class,
431+
Append.class,
432+
Put.class,
433+
Get.class,
434+
Scan.class};
436435

437436
BuilderStyleTest.assertClassesAreBuilderStyle(classes);
438437
}
439-
440438
}

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestScan.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
// TODO: cover more test cases
4646
@Category({ClientTests.class, SmallTests.class})
4747
public class TestScan {
48-
4948
@ClassRule
5049
public static final HBaseClassTestRule CLASS_RULE =
5150
HBaseClassTestRule.forClass(TestScan.class);
@@ -94,7 +93,8 @@ public void testGetToScan() throws Exception {
9493
assertEquals(get.getFilter(), scan.getFilter());
9594
assertEquals(get.getId(), scan.getId());
9695
assertEquals(get.getIsolationLevel(), scan.getIsolationLevel());
97-
assertEquals(get.getLoadColumnFamiliesOnDemandValue(), scan.getLoadColumnFamiliesOnDemandValue());
96+
assertEquals(get.getLoadColumnFamiliesOnDemandValue(),
97+
scan.getLoadColumnFamiliesOnDemandValue());
9898
assertEquals(get.getMaxResultsPerColumnFamily(), scan.getMaxResultsPerColumnFamily());
9999
assertEquals(get.getMaxVersions(), scan.getMaxVersions());
100100
assertEquals(get.getRowOffsetPerColumnFamily(), scan.getRowOffsetPerColumnFamily());
@@ -125,19 +125,22 @@ public void testScanAttributes() {
125125
scan.setAttribute("attribute1", Bytes.toBytes("value1"));
126126
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan.getAttribute("attribute1")));
127127
Assert.assertEquals(1, scan.getAttributesMap().size());
128-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan.getAttributesMap().get("attribute1")));
128+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"),
129+
scan.getAttributesMap().get("attribute1")));
129130

130131
// overriding attribute value
131132
scan.setAttribute("attribute1", Bytes.toBytes("value12"));
132133
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), scan.getAttribute("attribute1")));
133134
Assert.assertEquals(1, scan.getAttributesMap().size());
134-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), scan.getAttributesMap().get("attribute1")));
135+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"),
136+
scan.getAttributesMap().get("attribute1")));
135137

136138
// adding another attribute
137139
scan.setAttribute("attribute2", Bytes.toBytes("value2"));
138140
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan.getAttribute("attribute2")));
139141
Assert.assertEquals(2, scan.getAttributesMap().size());
140-
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan.getAttributesMap().get("attribute2")));
142+
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"),
143+
scan.getAttributesMap().get("attribute2")));
141144

142145
// removing attribute
143146
scan.setAttribute("attribute2", null);
@@ -290,4 +293,3 @@ public void testScanCopyConstructor() throws Exception {
290293
EqualsBuilder.reflectionEquals(scan, scanCopy));
291294
}
292295
}
293-

0 commit comments

Comments
 (0)