HBASE-22786 Fixed Checkstyle issues in tests in hbase-client
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
dd657d08c5
commit
ce709de6f4
|
@ -38,7 +38,12 @@ import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.junit.rules.ExpectedException;
|
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})
|
@Category({MiscTests.class, SmallTests.class})
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class TestHColumnDescriptor {
|
public class TestHColumnDescriptor {
|
||||||
|
|
|
@ -41,6 +41,9 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test setting values in the descriptor
|
* 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})
|
@Category({MiscTests.class, SmallTests.class})
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -117,8 +120,9 @@ public class TestHTableDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cps in the table description
|
* Test cps in the table description.
|
||||||
* @throws Exception
|
*
|
||||||
|
* @throws Exception if adding a coprocessor fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetSetRemoveCP() throws Exception {
|
public void testGetSetRemoveCP() throws Exception {
|
||||||
|
@ -134,8 +138,9 @@ public class TestHTableDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cps in the table description
|
* Test cps in the table description.
|
||||||
* @throws Exception
|
*
|
||||||
|
* @throws Exception if adding a coprocessor fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSetListRemoveCP() throws Exception {
|
public void testSetListRemoveCP() throws Exception {
|
||||||
|
@ -172,10 +177,9 @@ public class TestHTableDescriptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that we add and remove strings from settings properly.
|
* Test that we add and remove strings from settings properly.
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAddGetRemoveString() throws Exception {
|
public void testAddGetRemoveString() {
|
||||||
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
|
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
|
||||||
String key = "Some";
|
String key = "Some";
|
||||||
String value = "value";
|
String value = "value";
|
||||||
|
@ -191,13 +195,13 @@ public class TestHTableDescriptor {
|
||||||
assertEquals(null, desc.getValue(keyShouldNotNull));
|
assertEquals(null, desc.getValue(keyShouldNotNull));
|
||||||
}
|
}
|
||||||
|
|
||||||
String legalTableNames[] = { "foo", "with-dash_under.dot", "_under_start_ok",
|
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"
|
"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",
|
"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",
|
"trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02",
|
||||||
"汉", "汉:字", "_字_", "foo:字", "foo.字", "字.foo"};
|
"汉", "汉:字", "_字_", "foo:字", "foo.字", "字.foo"};
|
||||||
// Avoiding "zookeeper" in here as it's tough to encode in regex
|
// Avoiding "zookeeper" in here as it's tough to encode in regex
|
||||||
String illegalTableNames[] = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
|
String[] illegalTableNames = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
|
||||||
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
|
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
|
||||||
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2", String.valueOf((char)130),
|
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2", String.valueOf((char)130),
|
||||||
String.valueOf((char)5), String.valueOf((char)65530)};
|
String.valueOf((char)5), String.valueOf((char)65530)};
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category({ClientTests.class, SmallTests.class})
|
@Category({ClientTests.class, SmallTests.class})
|
||||||
public class TestAttributes {
|
public class TestAttributes {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestAttributes.class);
|
HBaseClassTestRule.forClass(TestAttributes.class);
|
||||||
|
@ -49,19 +48,22 @@ public class TestAttributes {
|
||||||
put.setAttribute("attribute1", Bytes.toBytes("value1"));
|
put.setAttribute("attribute1", Bytes.toBytes("value1"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttribute("attribute1")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttribute("attribute1")));
|
||||||
Assert.assertEquals(1, put.getAttributesMap().size());
|
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
|
// overriding attribute value
|
||||||
put.setAttribute("attribute1", Bytes.toBytes("value12"));
|
put.setAttribute("attribute1", Bytes.toBytes("value12"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttribute("attribute1")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttribute("attribute1")));
|
||||||
Assert.assertEquals(1, put.getAttributesMap().size());
|
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
|
// adding another attribute
|
||||||
put.setAttribute("attribute2", Bytes.toBytes("value2"));
|
put.setAttribute("attribute2", Bytes.toBytes("value2"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttribute("attribute2")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttribute("attribute2")));
|
||||||
Assert.assertEquals(2, put.getAttributesMap().size());
|
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
|
// removing attribute
|
||||||
put.setAttribute("attribute2", null);
|
put.setAttribute("attribute2", null);
|
||||||
|
@ -82,7 +84,6 @@ public class TestAttributes {
|
||||||
Assert.assertNull(put.getAttributesMap().get("attribute1"));
|
Assert.assertNull(put.getAttributesMap().get("attribute1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteAttributes() {
|
public void testDeleteAttributes() {
|
||||||
Delete del = new Delete(new byte [] {'r'});
|
Delete del = new Delete(new byte [] {'r'});
|
||||||
|
@ -97,19 +98,22 @@ public class TestAttributes {
|
||||||
del.setAttribute("attribute1", Bytes.toBytes("value1"));
|
del.setAttribute("attribute1", Bytes.toBytes("value1"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), del.getAttribute("attribute1")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), del.getAttribute("attribute1")));
|
||||||
Assert.assertEquals(1, del.getAttributesMap().size());
|
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
|
// overriding attribute value
|
||||||
del.setAttribute("attribute1", Bytes.toBytes("value12"));
|
del.setAttribute("attribute1", Bytes.toBytes("value12"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), del.getAttribute("attribute1")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), del.getAttribute("attribute1")));
|
||||||
Assert.assertEquals(1, del.getAttributesMap().size());
|
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
|
// adding another attribute
|
||||||
del.setAttribute("attribute2", Bytes.toBytes("value2"));
|
del.setAttribute("attribute2", Bytes.toBytes("value2"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), del.getAttribute("attribute2")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), del.getAttribute("attribute2")));
|
||||||
Assert.assertEquals(2, del.getAttributesMap().size());
|
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
|
// removing attribute
|
||||||
del.setAttribute("attribute2", null);
|
del.setAttribute("attribute2", null);
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
|
||||||
|
|
||||||
@Category({ClientTests.class, SmallTests.class})
|
@Category({ClientTests.class, SmallTests.class})
|
||||||
public class TestClientExponentialBackoff {
|
public class TestClientExponentialBackoff {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestClientExponentialBackoff.class);
|
HBaseClassTestRule.forClass(TestClientExponentialBackoff.class);
|
||||||
|
@ -163,8 +162,7 @@ public class TestClientExponentialBackoff {
|
||||||
|
|
||||||
private void update(ServerStatistics stats, int load) {
|
private void update(ServerStatistics stats, int load) {
|
||||||
ClientProtos.RegionLoadStats stat = ClientProtos.RegionLoadStats.newBuilder()
|
ClientProtos.RegionLoadStats stat = ClientProtos.RegionLoadStats.newBuilder()
|
||||||
.setMemStoreLoad
|
.setMemStoreLoad(load).build();
|
||||||
(load).build();
|
|
||||||
stats.update(regionname, ProtobufUtil.createRegionLoadStats(stat));
|
stats.update(regionname, ProtobufUtil.createRegionLoadStats(stat));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
@Category({MiscTests.class, SmallTests.class})
|
@Category({MiscTests.class, SmallTests.class})
|
||||||
public class TestColumnFamilyDescriptorBuilder {
|
public class TestColumnFamilyDescriptorBuilder {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestColumnFamilyDescriptorBuilder.class);
|
HBaseClassTestRule.forClass(TestColumnFamilyDescriptorBuilder.class);
|
||||||
|
@ -85,7 +84,8 @@ public class TestColumnFamilyDescriptorBuilder {
|
||||||
assertTrue(hcd.equals(deserializedHcd));
|
assertTrue(hcd.equals(deserializedHcd));
|
||||||
assertEquals(v, hcd.getBlocksize());
|
assertEquals(v, hcd.getBlocksize());
|
||||||
assertEquals(v, hcd.getTimeToLive());
|
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.getMaxVersions(), deserializedHcd.getMaxVersions());
|
||||||
assertEquals(hcd.getMinVersions(), deserializedHcd.getMinVersions());
|
assertEquals(hcd.getMinVersions(), deserializedHcd.getMinVersions());
|
||||||
assertEquals(hcd.getKeepDeletedCells(), deserializedHcd.getKeepDeletedCells());
|
assertEquals(hcd.getKeepDeletedCells(), deserializedHcd.getKeepDeletedCells());
|
||||||
|
|
|
@ -54,7 +54,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
|
||||||
// TODO: cover more test cases
|
// TODO: cover more test cases
|
||||||
@Category({ClientTests.class, SmallTests.class})
|
@Category({ClientTests.class, SmallTests.class})
|
||||||
public class TestGet {
|
public class TestGet {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestGet.class);
|
HBaseClassTestRule.forClass(TestGet.class);
|
||||||
|
@ -122,19 +121,22 @@ public class TestGet {
|
||||||
get.setAttribute("attribute1", Bytes.toBytes("value1"));
|
get.setAttribute("attribute1", Bytes.toBytes("value1"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttribute("attribute1")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttribute("attribute1")));
|
||||||
Assert.assertEquals(1, get.getAttributesMap().size());
|
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
|
// overriding attribute value
|
||||||
get.setAttribute("attribute1", Bytes.toBytes("value12"));
|
get.setAttribute("attribute1", Bytes.toBytes("value12"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttribute("attribute1")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttribute("attribute1")));
|
||||||
Assert.assertEquals(1, get.getAttributesMap().size());
|
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
|
// adding another attribute
|
||||||
get.setAttribute("attribute2", Bytes.toBytes("value2"));
|
get.setAttribute("attribute2", Bytes.toBytes("value2"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttribute("attribute2")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttribute("attribute2")));
|
||||||
Assert.assertEquals(2, get.getAttributesMap().size());
|
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
|
// removing attribute
|
||||||
get.setAttribute("attribute2", null);
|
get.setAttribute("attribute2", null);
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpeci
|
||||||
|
|
||||||
@Category({ClientTests.class, MetricsTests.class, SmallTests.class})
|
@Category({ClientTests.class, MetricsTests.class, SmallTests.class})
|
||||||
public class TestMetricsConnection {
|
public class TestMetricsConnection {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestMetricsConnection.class);
|
HBaseClassTestRule.forClass(TestMetricsConnection.class);
|
||||||
|
|
|
@ -76,7 +76,6 @@ import org.apache.hbase.thirdparty.com.google.gson.Gson;
|
||||||
*/
|
*/
|
||||||
@Category({ClientTests.class, SmallTests.class})
|
@Category({ClientTests.class, SmallTests.class})
|
||||||
public class TestOperation {
|
public class TestOperation {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestOperation.class);
|
HBaseClassTestRule.forClass(TestOperation.class);
|
||||||
|
@ -284,11 +283,11 @@ public class TestOperation {
|
||||||
/**
|
/**
|
||||||
* Test the client Operations' JSON encoding to ensure that produced JSON is
|
* Test the client Operations' JSON encoding to ensure that produced JSON is
|
||||||
* parseable and that the details are present and not corrupted.
|
* parseable and that the details are present and not corrupted.
|
||||||
* @throws IOException
|
*
|
||||||
|
* @throws IOException if the JSON conversion fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testOperationJSON()
|
public void testOperationJSON() throws IOException {
|
||||||
throws IOException {
|
|
||||||
// produce a Scan Operation
|
// produce a Scan Operation
|
||||||
Scan scan = new Scan(ROW);
|
Scan scan = new Scan(ROW);
|
||||||
scan.addColumn(FAMILY, QUALIFIER);
|
scan.addColumn(FAMILY, QUALIFIER);
|
||||||
|
@ -441,5 +440,4 @@ public class TestOperation {
|
||||||
|
|
||||||
BuilderStyleTest.assertClassesAreBuilderStyle(classes);
|
BuilderStyleTest.assertClassesAreBuilderStyle(classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
|
||||||
// TODO: cover more test cases
|
// TODO: cover more test cases
|
||||||
@Category({ClientTests.class, SmallTests.class})
|
@Category({ClientTests.class, SmallTests.class})
|
||||||
public class TestScan {
|
public class TestScan {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestScan.class);
|
HBaseClassTestRule.forClass(TestScan.class);
|
||||||
|
@ -94,7 +93,8 @@ public class TestScan {
|
||||||
assertEquals(get.getFilter(), scan.getFilter());
|
assertEquals(get.getFilter(), scan.getFilter());
|
||||||
assertEquals(get.getId(), scan.getId());
|
assertEquals(get.getId(), scan.getId());
|
||||||
assertEquals(get.getIsolationLevel(), scan.getIsolationLevel());
|
assertEquals(get.getIsolationLevel(), scan.getIsolationLevel());
|
||||||
assertEquals(get.getLoadColumnFamiliesOnDemandValue(), scan.getLoadColumnFamiliesOnDemandValue());
|
assertEquals(get.getLoadColumnFamiliesOnDemandValue(),
|
||||||
|
scan.getLoadColumnFamiliesOnDemandValue());
|
||||||
assertEquals(get.getMaxResultsPerColumnFamily(), scan.getMaxResultsPerColumnFamily());
|
assertEquals(get.getMaxResultsPerColumnFamily(), scan.getMaxResultsPerColumnFamily());
|
||||||
assertEquals(get.getMaxVersions(), scan.getMaxVersions());
|
assertEquals(get.getMaxVersions(), scan.getMaxVersions());
|
||||||
assertEquals(get.getRowOffsetPerColumnFamily(), scan.getRowOffsetPerColumnFamily());
|
assertEquals(get.getRowOffsetPerColumnFamily(), scan.getRowOffsetPerColumnFamily());
|
||||||
|
@ -125,19 +125,22 @@ public class TestScan {
|
||||||
scan.setAttribute("attribute1", Bytes.toBytes("value1"));
|
scan.setAttribute("attribute1", Bytes.toBytes("value1"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan.getAttribute("attribute1")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan.getAttribute("attribute1")));
|
||||||
Assert.assertEquals(1, scan.getAttributesMap().size());
|
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
|
// overriding attribute value
|
||||||
scan.setAttribute("attribute1", Bytes.toBytes("value12"));
|
scan.setAttribute("attribute1", Bytes.toBytes("value12"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), scan.getAttribute("attribute1")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), scan.getAttribute("attribute1")));
|
||||||
Assert.assertEquals(1, scan.getAttributesMap().size());
|
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
|
// adding another attribute
|
||||||
scan.setAttribute("attribute2", Bytes.toBytes("value2"));
|
scan.setAttribute("attribute2", Bytes.toBytes("value2"));
|
||||||
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan.getAttribute("attribute2")));
|
Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan.getAttribute("attribute2")));
|
||||||
Assert.assertEquals(2, scan.getAttributesMap().size());
|
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
|
// removing attribute
|
||||||
scan.setAttribute("attribute2", null);
|
scan.setAttribute("attribute2", null);
|
||||||
|
@ -290,4 +293,3 @@ public class TestScan {
|
||||||
EqualsBuilder.reflectionEquals(scan, scanCopy));
|
EqualsBuilder.reflectionEquals(scan, scanCopy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,10 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test setting values in the descriptor
|
* Test setting values in the descriptor.
|
||||||
*/
|
*/
|
||||||
@Category({MiscTests.class, SmallTests.class})
|
@Category({MiscTests.class, SmallTests.class})
|
||||||
public class TestTableDescriptorBuilder {
|
public class TestTableDescriptorBuilder {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestTableDescriptorBuilder.class);
|
HBaseClassTestRule.forClass(TestTableDescriptorBuilder.class);
|
||||||
|
@ -86,8 +85,9 @@ public class TestTableDescriptorBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cps in the table description
|
* Test cps in the table description.
|
||||||
* @throws Exception
|
*
|
||||||
|
* @throws Exception if setting a coprocessor fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetSetRemoveCP() throws Exception {
|
public void testGetSetRemoveCP() throws Exception {
|
||||||
|
@ -105,8 +105,9 @@ public class TestTableDescriptorBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cps in the table description
|
* Test cps in the table description.
|
||||||
* @throws Exception
|
*
|
||||||
|
* @throws Exception if setting a coprocessor fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSetListRemoveCP() throws Exception {
|
public void testSetListRemoveCP() throws Exception {
|
||||||
|
@ -157,10 +158,9 @@ public class TestTableDescriptorBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that we add and remove strings from settings properly.
|
* Test that we add and remove strings from settings properly.
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveString() throws Exception {
|
public void testRemoveString() {
|
||||||
byte[] key = Bytes.toBytes("Some");
|
byte[] key = Bytes.toBytes("Some");
|
||||||
byte[] value = Bytes.toBytes("value");
|
byte[] value = Bytes.toBytes("value");
|
||||||
TableDescriptor desc
|
TableDescriptor desc
|
||||||
|
@ -174,11 +174,11 @@ public class TestTableDescriptorBuilder {
|
||||||
assertTrue(desc.getValue(key) == null);
|
assertTrue(desc.getValue(key) == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
String legalTableNames[] = { "foo", "with-dash_under.dot", "_under_start_ok",
|
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"
|
"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",
|
"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"};
|
"trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02"};
|
||||||
String illegalTableNames[] = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
|
String[] illegalTableNames = { ".dot_start_illegal", "-dash_start_illegal", "spaces not ok",
|
||||||
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
|
"-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
|
||||||
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2"};
|
"new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2"};
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.exceptions;
|
package org.apache.hadoop.hbase.exceptions;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||||
|
@ -32,13 +32,12 @@ import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
|
||||||
@SuppressWarnings("ThrowableInstanceNeverThrown")
|
@SuppressWarnings("ThrowableInstanceNeverThrown")
|
||||||
@Category({ SmallTests.class, ClientTests.class })
|
@Category({ SmallTests.class, ClientTests.class })
|
||||||
public class TestClientExceptionsUtil {
|
public class TestClientExceptionsUtil {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestClientExceptionsUtil.class);
|
HBaseClassTestRule.forClass(TestClientExceptionsUtil.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindException() throws Exception {
|
public void testFindException() {
|
||||||
IOException ioe = new IOException("Tesst");
|
IOException ioe = new IOException("Tesst");
|
||||||
ServiceException se = new ServiceException(ioe);
|
ServiceException se = new ServiceException(ioe);
|
||||||
assertEquals(ioe, ClientExceptionsUtil.findException(se));
|
assertEquals(ioe, ClientExceptionsUtil.findException(se));
|
||||||
|
|
|
@ -29,12 +29,11 @@ import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category(SmallTests.class)
|
@Category(SmallTests.class)
|
||||||
public class TestLongComparator {
|
public class TestLongComparator {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestLongComparator.class);
|
HBaseClassTestRule.forClass(TestLongComparator.class);
|
||||||
|
|
||||||
private long values[] = { Long.MIN_VALUE, -10000000000L, -1000000L, 0L, 1000000L, 10000000000L,
|
private long[] values = { Long.MIN_VALUE, -10000000000L, -1000000L, 0L, 1000000L, 10000000000L,
|
||||||
Long.MAX_VALUE };
|
Long.MAX_VALUE };
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -50,7 +50,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@Category({ ClientTests.class, SmallTests.class })
|
@Category({ ClientTests.class, SmallTests.class })
|
||||||
public class TestCellBlockBuilder {
|
public class TestCellBlockBuilder {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestCellBlockBuilder.class);
|
HBaseClassTestRule.forClass(TestCellBlockBuilder.class);
|
||||||
|
@ -137,15 +136,15 @@ public class TestCellBlockBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints usage and then exits w/ passed <code>errCode</code>
|
* 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("Usage: IPCUtil [options]");
|
||||||
System.out.println("Micro-benchmarking how changed sizes and counts work with buffer resizing");
|
System.out.println("Micro-benchmarking how changed sizes and counts work with buffer resizing");
|
||||||
System.out.println(" --count Count of Cells");
|
System.out.println(" --count Count of Cells");
|
||||||
System.out.println(" --size Size of Cell values");
|
System.out.println(" --size Size of Cell values");
|
||||||
System.out.println("Example: IPCUtil --count=1024 --size=1024");
|
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,
|
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.
|
* 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 {
|
public static void main(String[] args) throws IOException {
|
||||||
int count = 1024;
|
int count = 1024;
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category({ ClientTests.class, SmallTests.class })
|
@Category({ ClientTests.class, SmallTests.class })
|
||||||
public class TestHBaseRpcControllerImpl {
|
public class TestHBaseRpcControllerImpl {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestHBaseRpcControllerImpl.class);
|
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
|
* @return A faked out 'Cell' that does nothing but return index as its value
|
||||||
*/
|
*/
|
||||||
static CellScannable createCell(final int index) {
|
static CellScannable createCell(final int index) {
|
||||||
|
@ -84,73 +83,61 @@ public class TestHBaseRpcControllerImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getRowArray() {
|
public byte[] getRowArray() {
|
||||||
// unused
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRowOffset() {
|
public int getRowOffset() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short getRowLength() {
|
public short getRowLength() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getFamilyArray() {
|
public byte[] getFamilyArray() {
|
||||||
// unused
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFamilyOffset() {
|
public int getFamilyOffset() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte getFamilyLength() {
|
public byte getFamilyLength() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getQualifierArray() {
|
public byte[] getQualifierArray() {
|
||||||
// unused
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getQualifierOffset() {
|
public int getQualifierOffset() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getQualifierLength() {
|
public int getQualifierLength() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte getTypeByte() {
|
public byte getTypeByte() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSequenceId() {
|
public long getSequenceId() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,25 +163,21 @@ public class TestHBaseRpcControllerImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTagsOffset() {
|
public int getTagsOffset() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTagsLength() {
|
public int getTagsLength() {
|
||||||
// unused
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getTagsArray() {
|
public byte[] getTagsArray() {
|
||||||
// unused
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
// unused
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -205,7 +188,10 @@ public class TestHBaseRpcControllerImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean advance() {
|
public boolean advance() {
|
||||||
// We have one Cell only so return true first time then false ever after.
|
// We have one Cell only so return true first time then false ever after.
|
||||||
if (!hasCell) return hasCell;
|
if (!hasCell) {
|
||||||
|
return hasCell;
|
||||||
|
}
|
||||||
|
|
||||||
hasCell = false;
|
hasCell = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category({ClientTests.class, SmallTests.class})
|
@Category({ClientTests.class, SmallTests.class})
|
||||||
public class TestQuotaFilter {
|
public class TestQuotaFilter {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestQuotaFilter.class);
|
HBaseClassTestRule.forClass(TestQuotaFilter.class);
|
||||||
|
@ -48,5 +47,4 @@ public class TestQuotaFilter {
|
||||||
|
|
||||||
BuilderStyleTest.assertClassesAreBuilderStyle(QuotaFilter.class);
|
BuilderStyleTest.assertClassesAreBuilderStyle(QuotaFilter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota;
|
||||||
*/
|
*/
|
||||||
@Category(SmallTests.class)
|
@Category(SmallTests.class)
|
||||||
public class TestQuotaSettingsFactory {
|
public class TestQuotaSettingsFactory {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestQuotaSettingsFactory.class);
|
HBaseClassTestRule.forClass(TestQuotaSettingsFactory.class);
|
||||||
|
@ -62,9 +61,11 @@ public class TestQuotaSettingsFactory {
|
||||||
final long writeLimit = 500;
|
final long writeLimit = 500;
|
||||||
final Throttle throttle = Throttle.newBuilder()
|
final Throttle throttle = Throttle.newBuilder()
|
||||||
// 1000 read reqs/min
|
// 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
|
// 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();
|
.build();
|
||||||
final Quotas quotas = Quotas.newBuilder()
|
final Quotas quotas = Quotas.newBuilder()
|
||||||
.setSpace(spaceQuota) // Set the FS quotas
|
.setSpace(spaceQuota) // Set the FS quotas
|
||||||
|
@ -145,9 +146,11 @@ public class TestQuotaSettingsFactory {
|
||||||
final TableName tableName = TableName.valueOf("foo");
|
final TableName tableName = TableName.valueOf("foo");
|
||||||
final long sizeLimit = 1024L * 1024L * 1024L * 75; // 75GB
|
final long sizeLimit = 1024L * 1024L * 1024L * 75; // 75GB
|
||||||
final SpaceViolationPolicy violationPolicy = SpaceViolationPolicy.NO_INSERTS;
|
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);
|
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;
|
SpaceLimitSettings spaceLimitSettings = (SpaceLimitSettings) settings;
|
||||||
SpaceLimitRequest protoRequest = spaceLimitSettings.getProto();
|
SpaceLimitRequest protoRequest = spaceLimitSettings.getProto();
|
||||||
assertTrue("Request should have a SpaceQuota", protoRequest.hasQuota());
|
assertTrue("Request should have a SpaceQuota", protoRequest.hasQuota());
|
||||||
|
@ -163,14 +166,16 @@ public class TestQuotaSettingsFactory {
|
||||||
final TableName tn = TableName.valueOf("tn1");
|
final TableName tn = TableName.valueOf("tn1");
|
||||||
QuotaSettings nsSettings = QuotaSettingsFactory.removeNamespaceSpaceLimit(ns);
|
QuotaSettings nsSettings = QuotaSettingsFactory.removeNamespaceSpaceLimit(ns);
|
||||||
assertNotNull("QuotaSettings should not be null", nsSettings);
|
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();
|
SpaceLimitRequest nsProto = ((SpaceLimitSettings) nsSettings).getProto();
|
||||||
assertTrue("Request should have a SpaceQuota", nsProto.hasQuota());
|
assertTrue("Request should have a SpaceQuota", nsProto.hasQuota());
|
||||||
assertTrue("The remove attribute should be true", nsProto.getQuota().getRemove());
|
assertTrue("The remove attribute should be true", nsProto.getQuota().getRemove());
|
||||||
|
|
||||||
QuotaSettings tableSettings = QuotaSettingsFactory.removeTableSpaceLimit(tn);
|
QuotaSettings tableSettings = QuotaSettingsFactory.removeTableSpaceLimit(tn);
|
||||||
assertNotNull("QuotaSettings should not be null", tableSettings);
|
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();
|
SpaceLimitRequest tableProto = ((SpaceLimitSettings) tableSettings).getProto();
|
||||||
assertTrue("Request should have a SpaceQuota", tableProto.hasQuota());
|
assertTrue("Request should have a SpaceQuota", tableProto.hasQuota());
|
||||||
assertTrue("The remove attribute should be true", tableProto.getQuota().getRemove());
|
assertTrue("The remove attribute should be true", tableProto.getQuota().getRemove());
|
||||||
|
|
|
@ -60,7 +60,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;
|
||||||
|
|
||||||
@Category(SmallTests.class)
|
@Category(SmallTests.class)
|
||||||
public class TestProtobufUtil {
|
public class TestProtobufUtil {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestProtobufUtil.class);
|
HBaseClassTestRule.forClass(TestProtobufUtil.class);
|
||||||
|
@ -86,7 +85,7 @@ public class TestProtobufUtil {
|
||||||
/**
|
/**
|
||||||
* Test basic Get conversions.
|
* Test basic Get conversions.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException if the conversion to a {@link Get} fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGet() throws IOException {
|
public void testGet() throws IOException {
|
||||||
|
@ -119,7 +118,8 @@ public class TestProtobufUtil {
|
||||||
/**
|
/**
|
||||||
* Test Delete Mutate conversions.
|
* 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
|
@Test
|
||||||
public void testDelete() throws IOException {
|
public void testDelete() throws IOException {
|
||||||
|
@ -166,7 +166,8 @@ public class TestProtobufUtil {
|
||||||
/**
|
/**
|
||||||
* Test Put Mutate conversions.
|
* 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
|
@Test
|
||||||
public void testPut() throws IOException {
|
public void testPut() throws IOException {
|
||||||
|
@ -216,7 +217,7 @@ public class TestProtobufUtil {
|
||||||
/**
|
/**
|
||||||
* Test basic Scan conversions.
|
* Test basic Scan conversions.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException if the conversion to a {@link org.apache.hadoop.hbase.client.Scan} fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testScan() throws IOException {
|
public void testScan() throws IOException {
|
||||||
|
@ -255,7 +256,7 @@ public class TestProtobufUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToCell() throws Exception {
|
public void testToCell() {
|
||||||
KeyValue kv1 =
|
KeyValue kv1 =
|
||||||
new KeyValue(Bytes.toBytes("aaa"), Bytes.toBytes("f1"), Bytes.toBytes("q1"), new byte[30]);
|
new KeyValue(Bytes.toBytes("aaa"), Bytes.toBytes("f1"), Bytes.toBytes("q1"), new byte[30]);
|
||||||
KeyValue kv2 =
|
KeyValue kv2 =
|
||||||
|
@ -271,14 +272,16 @@ public class TestProtobufUtil {
|
||||||
dbb.put(arr);
|
dbb.put(arr);
|
||||||
ByteBufferKeyValue offheapKV = new ByteBufferKeyValue(dbb, kv1.getLength(), kv2.getLength());
|
ByteBufferKeyValue offheapKV = new ByteBufferKeyValue(dbb, kv1.getLength(), kv2.getLength());
|
||||||
CellProtos.Cell cell = ProtobufUtil.toCell(offheapKV);
|
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);
|
assertTrue(CellComparatorImpl.COMPARATOR.compare(offheapKV, newOffheapKV) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Increment Mutate conversions.
|
* Test Increment Mutate conversions.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException if converting to an {@link Increment} or
|
||||||
|
* {@link org.apache.hadoop.hbase.client.Mutation} fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIncrement() throws IOException {
|
public void testIncrement() throws IOException {
|
||||||
|
@ -315,7 +318,7 @@ public class TestProtobufUtil {
|
||||||
/**
|
/**
|
||||||
* Test Append Mutate conversions.
|
* Test Append Mutate conversions.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException if converting to an {@link Append} fails
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAppend() throws IOException {
|
public void testAppend() throws IOException {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.util;
|
package org.apache.hadoop.hbase.util;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -34,7 +33,8 @@ import java.util.Set;
|
||||||
* .setBar(bar)
|
* .setBar(bar)
|
||||||
* .setBaz(baz)
|
* .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
|
* 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;
|
boolean found = false;
|
||||||
for (Method m : e.getValue()) {
|
for (Method m : e.getValue()) {
|
||||||
found = clazz.isAssignableFrom(m.getReturnType());
|
found = clazz.isAssignableFrom(m.getReturnType());
|
||||||
if (found) break;
|
if (found) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String errorMsg = "All setXXX()|addXX() methods in " + clazz.getSimpleName()
|
String errorMsg = "All setXXX()|addXX() methods in " + clazz.getSimpleName()
|
||||||
+ " should return a " + clazz.getSimpleName() + " object in builder style. "
|
+ " should return a " + clazz.getSimpleName() + " object in builder style. "
|
||||||
|
|
Loading…
Reference in New Issue