HBASE-22786 Fixed Checkstyle issues in tests in hbase-client

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
Jan Hentschel 2019-08-05 11:52:53 +02:00
parent dd657d08c5
commit ce709de6f4
No known key found for this signature in database
GPG Key ID: 5CD818B19CC299A3
18 changed files with 133 additions and 129 deletions

View File

@ -38,7 +38,12 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.ExpectedException;
/** Tests the HColumnDescriptor with appropriate arguments */
/**
* Tests the HColumnDescriptor with appropriate arguments.
*
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 together with
* {@link HColumnDescriptor}.
*/
@Category({MiscTests.class, SmallTests.class})
@Deprecated
public class TestHColumnDescriptor {

View File

@ -41,6 +41,9 @@ import org.slf4j.LoggerFactory;
/**
* Test setting values in the descriptor
*
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 together with
* {@link HTableDescriptor}.
*/
@Category({MiscTests.class, SmallTests.class})
@Deprecated
@ -117,8 +120,9 @@ public class TestHTableDescriptor {
}
/**
* Test cps in the table description
* @throws Exception
* Test cps in the table description.
*
* @throws Exception if adding a coprocessor fails
*/
@Test
public void testGetSetRemoveCP() throws Exception {
@ -134,8 +138,9 @@ public class TestHTableDescriptor {
}
/**
* Test cps in the table description
* @throws Exception
* Test cps in the table description.
*
* @throws Exception if adding a coprocessor fails
*/
@Test
public void testSetListRemoveCP() throws Exception {
@ -172,10 +177,9 @@ public class TestHTableDescriptor {
/**
* Test that we add and remove strings from settings properly.
* @throws Exception
*/
@Test
public void testAddGetRemoveString() throws Exception {
public void testAddGetRemoveString() {
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
String key = "Some";
String value = "value";
@ -191,15 +195,15 @@ public class TestHTableDescriptor {
assertEquals(null, desc.getValue(keyShouldNotNull));
}
String legalTableNames[] = { "foo", "with-dash_under.dot", "_under_start_ok",
"with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02"
, "dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2",
"trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02",
"", "汉:字", "_字_", "foo:字", "foo.字", "字.foo"};
String[] legalTableNames = { "foo", "with-dash_under.dot", "_under_start_ok",
"with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02",
"dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2",
"trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02",
"", "汉:字", "_字_", "foo:字", "foo.字", "字.foo"};
// Avoiding "zookeeper" in here as it's tough to encode in regex
String illegalTableNames[] = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2", String.valueOf((char)130),
String[] illegalTableNames = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2", String.valueOf((char)130),
String.valueOf((char)5), String.valueOf((char)65530)};
@Test

View File

@ -29,7 +29,6 @@ import org.junit.experimental.categories.Category;
@Category({ClientTests.class, SmallTests.class})
public class TestAttributes {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestAttributes.class);
@ -49,19 +48,22 @@ public class TestAttributes {
put.setAttribute("attribute1", Bytes.toBytes("value1"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttribute("attribute1")));
Assert.assertEquals(1, put.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"),
put.getAttributesMap().get("attribute1")));
// overriding attribute value
put.setAttribute("attribute1", Bytes.toBytes("value12"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttribute("attribute1")));
Assert.assertEquals(1, put.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"),
put.getAttributesMap().get("attribute1")));
// adding another attribute
put.setAttribute("attribute2", Bytes.toBytes("value2"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttribute("attribute2")));
Assert.assertEquals(2, put.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttributesMap().get("attribute2")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"),
put.getAttributesMap().get("attribute2")));
// removing attribute
put.setAttribute("attribute2", null);
@ -82,7 +84,6 @@ public class TestAttributes {
Assert.assertNull(put.getAttributesMap().get("attribute1"));
}
@Test
public void testDeleteAttributes() {
Delete del = new Delete(new byte [] {'r'});
@ -97,19 +98,22 @@ public class TestAttributes {
del.setAttribute("attribute1", Bytes.toBytes("value1"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), del.getAttribute("attribute1")));
Assert.assertEquals(1, del.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), del.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"),
del.getAttributesMap().get("attribute1")));
// overriding attribute value
del.setAttribute("attribute1", Bytes.toBytes("value12"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), del.getAttribute("attribute1")));
Assert.assertEquals(1, del.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), del.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"),
del.getAttributesMap().get("attribute1")));
// adding another attribute
del.setAttribute("attribute2", Bytes.toBytes("value2"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), del.getAttribute("attribute2")));
Assert.assertEquals(2, del.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), del.getAttributesMap().get("attribute2")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"),
del.getAttributesMap().get("attribute2")));
// removing attribute
del.setAttribute("attribute2", null);

View File

@ -38,7 +38,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
@Category({ClientTests.class, SmallTests.class})
public class TestClientExponentialBackoff {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestClientExponentialBackoff.class);
@ -149,7 +148,7 @@ public class TestClientExponentialBackoff {
backoffTime = backoff.getBackoffTime(server, regionname, stats);
assertTrue("Compaction pressure has no effect", backoffTime == 0);
long previous = backoffTime;
long previous = backoffTime;
update(stats, 0, 0, 50);
backoffTime = backoff.getBackoffTime(server, regionname, stats);
assertTrue("Compaction pressure should be bigger",
@ -163,8 +162,7 @@ public class TestClientExponentialBackoff {
private void update(ServerStatistics stats, int load) {
ClientProtos.RegionLoadStats stat = ClientProtos.RegionLoadStats.newBuilder()
.setMemStoreLoad
(load).build();
.setMemStoreLoad(load).build();
stats.update(regionname, ProtobufUtil.createRegionLoadStats(stat));
}

View File

@ -44,7 +44,6 @@ import org.junit.rules.ExpectedException;
@Category({MiscTests.class, SmallTests.class})
public class TestColumnFamilyDescriptorBuilder {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestColumnFamilyDescriptorBuilder.class);
@ -85,7 +84,8 @@ public class TestColumnFamilyDescriptorBuilder {
assertTrue(hcd.equals(deserializedHcd));
assertEquals(v, hcd.getBlocksize());
assertEquals(v, hcd.getTimeToLive());
assertTrue(Bytes.equals(hcd.getValue(Bytes.toBytes("a")), deserializedHcd.getValue(Bytes.toBytes("a"))));
assertTrue(Bytes.equals(hcd.getValue(Bytes.toBytes("a")),
deserializedHcd.getValue(Bytes.toBytes("a"))));
assertEquals(hcd.getMaxVersions(), deserializedHcd.getMaxVersions());
assertEquals(hcd.getMinVersions(), deserializedHcd.getMinVersions());
assertEquals(hcd.getKeepDeletedCells(), deserializedHcd.getKeepDeletedCells());

View File

@ -54,7 +54,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
// TODO: cover more test cases
@Category({ClientTests.class, SmallTests.class})
public class TestGet {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestGet.class);
@ -122,19 +121,22 @@ public class TestGet {
get.setAttribute("attribute1", Bytes.toBytes("value1"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttribute("attribute1")));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"),
get.getAttributesMap().get("attribute1")));
// overriding attribute value
get.setAttribute("attribute1", Bytes.toBytes("value12"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttribute("attribute1")));
Assert.assertEquals(1, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"),
get.getAttributesMap().get("attribute1")));
// adding another attribute
get.setAttribute("attribute2", Bytes.toBytes("value2"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttribute("attribute2")));
Assert.assertEquals(2, get.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttributesMap().get("attribute2")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"),
get.getAttributesMap().get("attribute2")));
// removing attribute
get.setAttribute("attribute2", null);

View File

@ -49,7 +49,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpeci
@Category({ClientTests.class, MetricsTests.class, SmallTests.class})
public class TestMetricsConnection {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestMetricsConnection.class);
@ -119,8 +118,8 @@ public class TestMetricsConnection {
MetricsConnection.newCallStats());
}
for (MetricsConnection.CallTracker t : new MetricsConnection.CallTracker[] {
METRICS.getTracker, METRICS.scanTracker, METRICS.multiTracker, METRICS.appendTracker,
METRICS.deleteTracker, METRICS.incrementTracker, METRICS.putTracker
METRICS.getTracker, METRICS.scanTracker, METRICS.multiTracker, METRICS.appendTracker,
METRICS.deleteTracker, METRICS.incrementTracker, METRICS.putTracker
}) {
assertEquals("Failed to invoke callTimer on " + t, loop, t.callTimer.getCount());
assertEquals("Failed to invoke reqHist on " + t, loop, t.reqHist.getCount());

View File

@ -76,7 +76,6 @@ import org.apache.hbase.thirdparty.com.google.gson.Gson;
*/
@Category({ClientTests.class, SmallTests.class})
public class TestOperation {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestOperation.class);
@ -284,11 +283,11 @@ public class TestOperation {
/**
* Test the client Operations' JSON encoding to ensure that produced JSON is
* parseable and that the details are present and not corrupted.
* @throws IOException
*
* @throws IOException if the JSON conversion fails
*/
@Test
public void testOperationJSON()
throws IOException {
public void testOperationJSON() throws IOException {
// produce a Scan Operation
Scan scan = new Scan(ROW);
scan.addColumn(FAMILY, QUALIFIER);
@ -428,18 +427,17 @@ public class TestOperation {
// TODO: We should ensure all subclasses of Operation is checked.
Class[] classes = new Class[] {
Operation.class,
OperationWithAttributes.class,
Mutation.class,
Query.class,
Delete.class,
Increment.class,
Append.class,
Put.class,
Get.class,
Scan.class};
Operation.class,
OperationWithAttributes.class,
Mutation.class,
Query.class,
Delete.class,
Increment.class,
Append.class,
Put.class,
Get.class,
Scan.class};
BuilderStyleTest.assertClassesAreBuilderStyle(classes);
}
}

View File

@ -45,7 +45,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
// TODO: cover more test cases
@Category({ClientTests.class, SmallTests.class})
public class TestScan {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestScan.class);
@ -94,7 +93,8 @@ public class TestScan {
assertEquals(get.getFilter(), scan.getFilter());
assertEquals(get.getId(), scan.getId());
assertEquals(get.getIsolationLevel(), scan.getIsolationLevel());
assertEquals(get.getLoadColumnFamiliesOnDemandValue(), scan.getLoadColumnFamiliesOnDemandValue());
assertEquals(get.getLoadColumnFamiliesOnDemandValue(),
scan.getLoadColumnFamiliesOnDemandValue());
assertEquals(get.getMaxResultsPerColumnFamily(), scan.getMaxResultsPerColumnFamily());
assertEquals(get.getMaxVersions(), scan.getMaxVersions());
assertEquals(get.getRowOffsetPerColumnFamily(), scan.getRowOffsetPerColumnFamily());
@ -125,19 +125,22 @@ public class TestScan {
scan.setAttribute("attribute1", Bytes.toBytes("value1"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan.getAttribute("attribute1")));
Assert.assertEquals(1, scan.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"),
scan.getAttributesMap().get("attribute1")));
// overriding attribute value
scan.setAttribute("attribute1", Bytes.toBytes("value12"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), scan.getAttribute("attribute1")));
Assert.assertEquals(1, scan.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), scan.getAttributesMap().get("attribute1")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"),
scan.getAttributesMap().get("attribute1")));
// adding another attribute
scan.setAttribute("attribute2", Bytes.toBytes("value2"));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan.getAttribute("attribute2")));
Assert.assertEquals(2, scan.getAttributesMap().size());
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan.getAttributesMap().get("attribute2")));
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"),
scan.getAttributesMap().get("attribute2")));
// removing attribute
scan.setAttribute("attribute2", null);
@ -290,4 +293,3 @@ public class TestScan {
EqualsBuilder.reflectionEquals(scan, scanCopy));
}
}

View File

@ -41,11 +41,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test setting values in the descriptor
* Test setting values in the descriptor.
*/
@Category({MiscTests.class, SmallTests.class})
public class TestTableDescriptorBuilder {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestTableDescriptorBuilder.class);
@ -86,8 +85,9 @@ public class TestTableDescriptorBuilder {
}
/**
* Test cps in the table description
* @throws Exception
* Test cps in the table description.
*
* @throws Exception if setting a coprocessor fails
*/
@Test
public void testGetSetRemoveCP() throws Exception {
@ -105,8 +105,9 @@ public class TestTableDescriptorBuilder {
}
/**
* Test cps in the table description
* @throws Exception
* Test cps in the table description.
*
* @throws Exception if setting a coprocessor fails
*/
@Test
public void testSetListRemoveCP() throws Exception {
@ -157,10 +158,9 @@ public class TestTableDescriptorBuilder {
/**
* Test that we add and remove strings from settings properly.
* @throws Exception
*/
@Test
public void testRemoveString() throws Exception {
public void testRemoveString() {
byte[] key = Bytes.toBytes("Some");
byte[] value = Bytes.toBytes("value");
TableDescriptor desc
@ -174,13 +174,13 @@ public class TestTableDescriptorBuilder {
assertTrue(desc.getValue(key) == null);
}
String legalTableNames[] = { "foo", "with-dash_under.dot", "_under_start_ok",
"with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02"
, "dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2",
"trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02"};
String illegalTableNames[] = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2"};
String[] legalTableNames = { "foo", "with-dash_under.dot", "_under_start_ok",
"with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02",
"dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2",
"trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02"};
String[] illegalTableNames = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2"};
@Test
public void testLegalTableNames() {

View File

@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.exceptions;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.apache.hadoop.hbase.HBaseClassTestRule;
@ -32,13 +32,12 @@ import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
@SuppressWarnings("ThrowableInstanceNeverThrown")
@Category({ SmallTests.class, ClientTests.class })
public class TestClientExceptionsUtil {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestClientExceptionsUtil.class);
@Test
public void testFindException() throws Exception {
public void testFindException() {
IOException ioe = new IOException("Tesst");
ServiceException se = new ServiceException(ioe);
assertEquals(ioe, ClientExceptionsUtil.findException(se));

View File

@ -29,13 +29,12 @@ import org.junit.experimental.categories.Category;
@Category(SmallTests.class)
public class TestLongComparator {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestLongComparator.class);
private long values[] = { Long.MIN_VALUE, -10000000000L, -1000000L, 0L, 1000000L, 10000000000L,
Long.MAX_VALUE };
private long[] values = { Long.MIN_VALUE, -10000000000L, -1000000L, 0L, 1000000L, 10000000000L,
Long.MAX_VALUE };
@Test
public void testSimple() {

View File

@ -50,7 +50,6 @@ import org.slf4j.LoggerFactory;
@Category({ ClientTests.class, SmallTests.class })
public class TestCellBlockBuilder {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestCellBlockBuilder.class);
@ -137,15 +136,15 @@ public class TestCellBlockBuilder {
/**
* Prints usage and then exits w/ passed <code>errCode</code>
* @param errCode
* @param errorCode the error code to use to exit the application
*/
private static void usage(final int errCode) {
private static void usage(final int errorCode) {
System.out.println("Usage: IPCUtil [options]");
System.out.println("Micro-benchmarking how changed sizes and counts work with buffer resizing");
System.out.println(" --count Count of Cells");
System.out.println(" --size Size of Cell values");
System.out.println("Example: IPCUtil --count=1024 --size=1024");
System.exit(errCode);
System.exit(errorCode);
}
private static void timerTests(final CellBlockBuilder builder, final int count, final int size,
@ -177,8 +176,9 @@ public class TestCellBlockBuilder {
/**
* For running a few tests of methods herein.
* @param args
* @throws IOException
*
* @param args the arguments to use for the timer test
* @throws IOException if creating the build fails
*/
public static void main(String[] args) throws IOException {
int count = 1024;

View File

@ -36,7 +36,6 @@ import org.junit.experimental.categories.Category;
@Category({ ClientTests.class, SmallTests.class })
public class TestHBaseRpcControllerImpl {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestHBaseRpcControllerImpl.class);
@ -62,7 +61,7 @@ public class TestHBaseRpcControllerImpl {
}
/**
* @param index
* @param index the index of the cell to use as its value
* @return A faked out 'Cell' that does nothing but return index as its value
*/
static CellScannable createCell(final int index) {
@ -84,73 +83,61 @@ public class TestHBaseRpcControllerImpl {
@Override
public byte[] getRowArray() {
// unused
return null;
}
@Override
public int getRowOffset() {
// unused
return 0;
}
@Override
public short getRowLength() {
// unused
return 0;
}
@Override
public byte[] getFamilyArray() {
// unused
return null;
}
@Override
public int getFamilyOffset() {
// unused
return 0;
}
@Override
public byte getFamilyLength() {
// unused
return 0;
}
@Override
public byte[] getQualifierArray() {
// unused
return null;
}
@Override
public int getQualifierOffset() {
// unused
return 0;
}
@Override
public int getQualifierLength() {
// unused
return 0;
}
@Override
public long getTimestamp() {
// unused
return 0;
}
@Override
public byte getTypeByte() {
// unused
return 0;
}
@Override
public long getSequenceId() {
// unused
return 0;
}
@ -176,25 +163,21 @@ public class TestHBaseRpcControllerImpl {
@Override
public int getTagsOffset() {
// unused
return 0;
}
@Override
public int getTagsLength() {
// unused
return 0;
}
@Override
public byte[] getTagsArray() {
// unused
return null;
}
@Override
public Type getType() {
// unused
return null;
}
};
@ -205,7 +188,10 @@ public class TestHBaseRpcControllerImpl {
@Override
public boolean advance() {
// We have one Cell only so return true first time then false ever after.
if (!hasCell) return hasCell;
if (!hasCell) {
return hasCell;
}
hasCell = false;
return true;
}

View File

@ -27,13 +27,12 @@ import org.junit.experimental.categories.Category;
@Category({ClientTests.class, SmallTests.class})
public class TestQuotaFilter {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestQuotaFilter.class);
@Test
public void testClassMethodsAreBuilderStyle() {
@Test
public void testClassMethodsAreBuilderStyle() {
/* ReplicationPeerConfig should have a builder style setup where setXXX/addXXX methods
* can be chainable together:
* . For example:
@ -46,7 +45,6 @@ public class TestQuotaFilter {
* This test ensures that all methods starting with "set" returns the declaring object
*/
BuilderStyleTest.assertClassesAreBuilderStyle(QuotaFilter.class);
}
BuilderStyleTest.assertClassesAreBuilderStyle(QuotaFilter.class);
}
}

View File

@ -47,7 +47,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota;
*/
@Category(SmallTests.class)
public class TestQuotaSettingsFactory {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestQuotaSettingsFactory.class);
@ -62,9 +61,11 @@ public class TestQuotaSettingsFactory {
final long writeLimit = 500;
final Throttle throttle = Throttle.newBuilder()
// 1000 read reqs/min
.setReadNum(TimedQuota.newBuilder().setSoftLimit(readLimit).setTimeUnit(HBaseProtos.TimeUnit.MINUTES).build())
.setReadNum(TimedQuota.newBuilder().setSoftLimit(readLimit)
.setTimeUnit(HBaseProtos.TimeUnit.MINUTES).build())
// 500 write reqs/min
.setWriteNum(TimedQuota.newBuilder().setSoftLimit(writeLimit).setTimeUnit(HBaseProtos.TimeUnit.MINUTES).build())
.setWriteNum(TimedQuota.newBuilder().setSoftLimit(writeLimit)
.setTimeUnit(HBaseProtos.TimeUnit.MINUTES).build())
.build();
final Quotas quotas = Quotas.newBuilder()
.setSpace(spaceQuota) // Set the FS quotas
@ -145,9 +146,11 @@ public class TestQuotaSettingsFactory {
final TableName tableName = TableName.valueOf("foo");
final long sizeLimit = 1024L * 1024L * 1024L * 75; // 75GB
final SpaceViolationPolicy violationPolicy = SpaceViolationPolicy.NO_INSERTS;
QuotaSettings settings = QuotaSettingsFactory.limitTableSpace(tableName, sizeLimit, violationPolicy);
QuotaSettings settings =
QuotaSettingsFactory.limitTableSpace(tableName, sizeLimit, violationPolicy);
assertNotNull("QuotaSettings should not be null", settings);
assertTrue("Should be an instance of SpaceLimitSettings", settings instanceof SpaceLimitSettings);
assertTrue("Should be an instance of SpaceLimitSettings",
settings instanceof SpaceLimitSettings);
SpaceLimitSettings spaceLimitSettings = (SpaceLimitSettings) settings;
SpaceLimitRequest protoRequest = spaceLimitSettings.getProto();
assertTrue("Request should have a SpaceQuota", protoRequest.hasQuota());
@ -163,16 +166,18 @@ public class TestQuotaSettingsFactory {
final TableName tn = TableName.valueOf("tn1");
QuotaSettings nsSettings = QuotaSettingsFactory.removeNamespaceSpaceLimit(ns);
assertNotNull("QuotaSettings should not be null", nsSettings);
assertTrue("Should be an instance of SpaceLimitSettings", nsSettings instanceof SpaceLimitSettings);
assertTrue("Should be an instance of SpaceLimitSettings",
nsSettings instanceof SpaceLimitSettings);
SpaceLimitRequest nsProto = ((SpaceLimitSettings) nsSettings).getProto();
assertTrue("Request should have a SpaceQuota", nsProto.hasQuota());
assertTrue("The remove attribute should be true", nsProto.getQuota().getRemove());
QuotaSettings tableSettings = QuotaSettingsFactory.removeTableSpaceLimit(tn);
assertNotNull("QuotaSettings should not be null", tableSettings);
assertTrue("Should be an instance of SpaceLimitSettings", tableSettings instanceof SpaceLimitSettings);
assertTrue("Should be an instance of SpaceLimitSettings",
tableSettings instanceof SpaceLimitSettings);
SpaceLimitRequest tableProto = ((SpaceLimitSettings) tableSettings).getProto();
assertTrue("Request should have a SpaceQuota", tableProto.hasQuota());
assertTrue("The remove attribute should be true", tableProto.getQuota().getRemove());
}
}
}

View File

@ -60,7 +60,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;
@Category(SmallTests.class)
public class TestProtobufUtil {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestProtobufUtil.class);
@ -86,7 +85,7 @@ public class TestProtobufUtil {
/**
* Test basic Get conversions.
*
* @throws IOException
* @throws IOException if the conversion to a {@link Get} fails
*/
@Test
public void testGet() throws IOException {
@ -119,7 +118,8 @@ public class TestProtobufUtil {
/**
* Test Delete Mutate conversions.
*
* @throws IOException
* @throws IOException if the conversion to a {@link Delete} or a
* {@link org.apache.hadoop.hbase.client.Mutation} fails
*/
@Test
public void testDelete() throws IOException {
@ -166,7 +166,8 @@ public class TestProtobufUtil {
/**
* Test Put Mutate conversions.
*
* @throws IOException
* @throws IOException if the conversion to a {@link Put} or a
* {@link org.apache.hadoop.hbase.client.Mutation} fails
*/
@Test
public void testPut() throws IOException {
@ -216,7 +217,7 @@ public class TestProtobufUtil {
/**
* Test basic Scan conversions.
*
* @throws IOException
* @throws IOException if the conversion to a {@link org.apache.hadoop.hbase.client.Scan} fails
*/
@Test
public void testScan() throws IOException {
@ -255,7 +256,7 @@ public class TestProtobufUtil {
}
@Test
public void testToCell() throws Exception {
public void testToCell() {
KeyValue kv1 =
new KeyValue(Bytes.toBytes("aaa"), Bytes.toBytes("f1"), Bytes.toBytes("q1"), new byte[30]);
KeyValue kv2 =
@ -271,14 +272,16 @@ public class TestProtobufUtil {
dbb.put(arr);
ByteBufferKeyValue offheapKV = new ByteBufferKeyValue(dbb, kv1.getLength(), kv2.getLength());
CellProtos.Cell cell = ProtobufUtil.toCell(offheapKV);
Cell newOffheapKV = ProtobufUtil.toCell(ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY), cell);
Cell newOffheapKV =
ProtobufUtil.toCell(ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY), cell);
assertTrue(CellComparatorImpl.COMPARATOR.compare(offheapKV, newOffheapKV) == 0);
}
/**
* Test Increment Mutate conversions.
*
* @throws IOException
* @throws IOException if converting to an {@link Increment} or
* {@link org.apache.hadoop.hbase.client.Mutation} fails
*/
@Test
public void testIncrement() throws IOException {
@ -315,7 +318,7 @@ public class TestProtobufUtil {
/**
* Test Append Mutate conversions.
*
* @throws IOException
* @throws IOException if converting to an {@link Append} fails
*/
@Test
public void testAppend() throws IOException {

View File

@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.util;
import static org.junit.Assert.assertTrue;
@ -34,7 +33,8 @@ import java.util.Set;
* .setBar(bar)
* .setBaz(baz)
*/
public class BuilderStyleTest {
public final class BuilderStyleTest {
private BuilderStyleTest() {}
/*
* If a base class Foo declares a method setFoo() returning Foo, then the subclass should
@ -92,7 +92,9 @@ public class BuilderStyleTest {
boolean found = false;
for (Method m : e.getValue()) {
found = clazz.isAssignableFrom(m.getReturnType());
if (found) break;
if (found) {
break;
}
}
String errorMsg = "All setXXX()|addXX() methods in " + clazz.getSimpleName()
+ " should return a " + clazz.getSimpleName() + " object in builder style. "