HBASE-20136 TestKeyValue misses ClassRule and Category annotations
This commit is contained in:
parent
1384da7137
commit
b7fb2df154
|
@ -18,7 +18,11 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -31,16 +35,23 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||
import org.apache.hadoop.hbase.util.ByteBufferUtils;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class TestKeyValue extends TestCase {
|
||||
@Category(SmallTests.class)
|
||||
public class TestKeyValue {
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestKeyValue.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestKeyValue.class);
|
||||
|
||||
@Test
|
||||
public void testColumnCompare() throws Exception {
|
||||
final byte [] a = Bytes.toBytes("aaa");
|
||||
byte [] family1 = Bytes.toBytes("abc");
|
||||
|
@ -64,6 +75,7 @@ public class TestKeyValue extends TestCase {
|
|||
* Test a corner case when the family qualifier is a prefix of the
|
||||
* column qualifier.
|
||||
*/
|
||||
@Test
|
||||
public void testColumnCompare_prefix() throws Exception {
|
||||
final byte [] a = Bytes.toBytes("aaa");
|
||||
byte [] family1 = Bytes.toBytes("abc");
|
||||
|
@ -75,14 +87,16 @@ public class TestKeyValue extends TestCase {
|
|||
assertFalse(CellUtil.matchingColumn(aaa, family2, qualifier2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasics() throws Exception {
|
||||
LOG.info("LOWKEY: " + KeyValue.LOWESTKEY.toString());
|
||||
check(Bytes.toBytes(getName()),
|
||||
Bytes.toBytes(getName()), Bytes.toBytes(getName()), 1,
|
||||
Bytes.toBytes(getName()));
|
||||
String name = "testBasics";
|
||||
check(Bytes.toBytes(name),
|
||||
Bytes.toBytes(name), Bytes.toBytes(name), 1,
|
||||
Bytes.toBytes(name));
|
||||
// Test empty value and empty column -- both should work. (not empty fam)
|
||||
check(Bytes.toBytes(getName()), Bytes.toBytes(getName()), null, 1, null);
|
||||
check(HConstants.EMPTY_BYTE_ARRAY, Bytes.toBytes(getName()), null, 1, null);
|
||||
check(Bytes.toBytes(name), Bytes.toBytes(name), null, 1, null);
|
||||
check(HConstants.EMPTY_BYTE_ARRAY, Bytes.toBytes(name), null, 1, null);
|
||||
// empty qual is equivalent to null qual
|
||||
assertEquals(
|
||||
new KeyValue(Bytes.toBytes("rk"), Bytes.toBytes("fam"), null, 1, (byte[]) null),
|
||||
|
@ -100,6 +114,7 @@ public class TestKeyValue extends TestCase {
|
|||
LOG.info(kv.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainCompare() throws Exception {
|
||||
final byte [] a = Bytes.toBytes("aaa");
|
||||
final byte [] b = Bytes.toBytes("bbb");
|
||||
|
@ -127,6 +142,7 @@ public class TestKeyValue extends TestCase {
|
|||
assertTrue(CellComparatorImpl.COMPARATOR.compare(aaa, aaa) == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreComparisons() throws Exception {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
|
@ -155,6 +171,7 @@ public class TestKeyValue extends TestCase {
|
|||
metacomparisons(CellComparatorImpl.META_COMPARATOR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetaComparatorTableKeysWithCommaOk() {
|
||||
CellComparator c = CellComparatorImpl.META_COMPARATOR;
|
||||
long now = System.currentTimeMillis();
|
||||
|
@ -170,6 +187,7 @@ public class TestKeyValue extends TestCase {
|
|||
* See HBASE-832
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test
|
||||
public void testKeyValueBorderCases() throws IOException {
|
||||
// % sorts before , so if we don't do special comparator, rowB would
|
||||
// come before rowA.
|
||||
|
@ -220,6 +238,7 @@ public class TestKeyValue extends TestCase {
|
|||
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,1"), now)) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBinaryKeys() throws Exception {
|
||||
Set<KeyValue> set = new TreeSet<>(CellComparatorImpl.COMPARATOR);
|
||||
final byte [] fam = Bytes.toBytes("col");
|
||||
|
@ -241,7 +260,7 @@ public class TestKeyValue extends TestCase {
|
|||
for (KeyValue k: set) {
|
||||
assertTrue(count++ == k.getTimestamp());
|
||||
}
|
||||
} catch (junit.framework.AssertionFailedError e) {
|
||||
} catch (java.lang.AssertionError e) {
|
||||
// Expected
|
||||
assertion = true;
|
||||
}
|
||||
|
@ -255,6 +274,7 @@ public class TestKeyValue extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStackedUpKeyValue() {
|
||||
// Test multiple KeyValues in a single blob.
|
||||
|
||||
|
@ -286,6 +306,7 @@ public class TestKeyValue extends TestCase {
|
|||
assertTrue(cmp > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareWithoutRow() {
|
||||
final CellComparator c = CellComparatorImpl.COMPARATOR;
|
||||
byte[] row = Bytes.toBytes("row");
|
||||
|
@ -333,6 +354,7 @@ public class TestKeyValue extends TestCase {
|
|||
assertKVLessWithoutRow(c, commonLength + 6, kv0_1, kv0_2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstLastOnRow() {
|
||||
final CellComparator c = CellComparatorImpl.COMPARATOR;
|
||||
long ts = 1;
|
||||
|
@ -379,6 +401,7 @@ public class TestKeyValue extends TestCase {
|
|||
assertKVLess(c, firstOnRowABufferFamQual, lastOnRowA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateKeyOnly() throws Exception {
|
||||
long ts = 1;
|
||||
byte [] value = Bytes.toBytes("a real value");
|
||||
|
@ -400,6 +423,7 @@ public class TestKeyValue extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateKeyValueFromKey() {
|
||||
KeyValue kv = new KeyValue(Bytes.toBytes("myRow"), Bytes.toBytes("myCF"),
|
||||
Bytes.toBytes("myQualifier"), 12345L, Bytes.toBytes("myValue"));
|
||||
|
@ -423,6 +447,7 @@ public class TestKeyValue extends TestCase {
|
|||
* Tests that getTimestamp() does always return the proper timestamp, even after updating it.
|
||||
* See HBASE-6265.
|
||||
*/
|
||||
@Test
|
||||
public void testGetTimestamp() {
|
||||
KeyValue kv = new KeyValue(Bytes.toBytes("myRow"), Bytes.toBytes("myCF"),
|
||||
Bytes.toBytes("myQualifier"), HConstants.LATEST_TIMESTAMP,
|
||||
|
@ -434,6 +459,7 @@ public class TestKeyValue extends TestCase {
|
|||
assertEquals(12345L, time2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKVsWithTags() {
|
||||
byte[] row = Bytes.toBytes("myRow");
|
||||
byte[] cf = Bytes.toBytes("myCF");
|
||||
|
@ -497,6 +523,7 @@ public class TestKeyValue extends TestCase {
|
|||
assertFalse(tagItr.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetaKeyComparator() {
|
||||
CellComparator c = CellComparatorImpl.META_COMPARATOR;
|
||||
long now = System.currentTimeMillis();
|
||||
|
@ -542,6 +569,7 @@ public class TestKeyValue extends TestCase {
|
|||
assertTrue(c.compare(a, b) < 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsAndHashCode() throws Exception {
|
||||
KeyValue kvA1 = new KeyValue(Bytes.toBytes("key"), Bytes.toBytes("cf"),
|
||||
Bytes.toBytes("qualA"), Bytes.toBytes("1"));
|
||||
|
@ -560,6 +588,7 @@ public class TestKeyValue extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeyValueSerialization() throws Exception {
|
||||
KeyValue kvA1 = new KeyValue(Bytes.toBytes("key"), Bytes.toBytes("cf"), Bytes.toBytes("qualA"),
|
||||
Bytes.toBytes("1"));
|
||||
|
|
Loading…
Reference in New Issue