KeyValue kv1 = new KeyValue(HConstants.EMPTY_START_ROW,
HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
KeyValue [] expected = {kv1};
//Test from memstore
Result res = region.get(get, null);
assertEquals(expected.length, res.size());
for(int i=0; i<res.size(); i++){
assertEquals(0,
Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
assertEquals(0,
Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
assertEquals(0,
Bytes.compareTo(
expected[i].getQualifier(), res.raw()[i].getQualifier()));
}
//flush
region.flushcache();
//test2
res = region.get(get, null);
assertEquals(expected.length, res.size());
for(int i=0; i<res.size(); i++){
assertEquals(0,
Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
assertEquals(0,
Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
assertEquals(0,
Bytes.compareTo(
expected[i].getQualifier(), res.raw()[i].getQualifier()));
}
//Scan
Scan scan = new Scan();
scan.addFamily(HConstants.CATALOG_FAMILY);
InternalScanner s = region.getScanner(scan);
List<KeyValue> result = new ArrayList<KeyValue>();
s.next(result);
assertEquals(expected.length, result.size());
for(int i=0; i<res.size(); i++){
assertEquals(0,
Bytes.compareTo(expected[i].getRow(), result.get(i).getRow()));
assertEquals(0,
Bytes.compareTo(expected[i].getFamily(), result.get(i).getFamily()));
assertEquals(0,