Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide
- index b59db4e..0eb8bc5 100644
- --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
- +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
- @@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.Abortable;
- import org.apache.hadoop.hbase.Cell;
- import org.apache.hadoop.hbase.CellUtil;
- import org.apache.hadoop.hbase.DoNotRetryIOException;
- +import org.apache.hadoop.hbase.HBaseConfiguration;
- import org.apache.hadoop.hbase.HBaseTestingUtility;
- import org.apache.hadoop.hbase.HColumnDescriptor;
- import org.apache.hadoop.hbase.HConstants;
- @@ -165,6 +166,62 @@ public class TestFromClientSide {
- // Nothing to do.
- }
- + @Test
- + public void testPutDeleteCell() throws Exception {
- + final byte[] TABLENAME = Bytes.toBytes("testHbasePutDeleteCell");
- + Configuration configuration = TEST_UTIL.getConfiguration();
- + final String rowKey = "12345";
- + final byte[] FAMILY = Bytes.toBytes("family");
- + HColumnDescriptor hcd = new HColumnDescriptor(FAMILY)
- + .setKeepDeletedCells(true).setMaxVersions(3);
- +
- + HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLENAME));
- + desc.addFamily(hcd);
- + TEST_UTIL.getHBaseAdmin().createTable(desc);
- +
- + HTableInterface table = new HTable(configuration, TABLENAME);
- + // put one row
- + Put put = new Put(Bytes.toBytes(rowKey));
- + put.add(FAMILY, Bytes.toBytes("A"), Bytes.toBytes("a"));
- + put.add(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b"));
- + put.add(FAMILY, Bytes.toBytes("C"), Bytes.toBytes("c"));
- + table.put(put);
- + // get row back and assert the values
- + Get get = new Get(Bytes.toBytes(rowKey));
- + Result result = table.get(get);
- + assertEquals("Column A value should be a",
- + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"), true);
- + assertEquals("Column B value should be b",
- + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"), true);
- + assertEquals("Column C value should be c",
- + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("C"))).equals("c"), true);
- +
- + // put the same row again with C column deleted
- + put = new Put(Bytes.toBytes(rowKey));
- + put.add(FAMILY, Bytes.toBytes("A"), Bytes.toBytes("a"));
- + put.add(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b"));
- + KeyValue kv = new KeyValue(Bytes.toBytes(rowKey), FAMILY, Bytes.toBytes("C"),
- + HConstants.LATEST_TIMESTAMP, KeyValue.Type.DeleteColumn);
- + /*
- + put.add(kv);
- + */
- + table.put(put);
- + Delete del = new Delete(Bytes.toBytes(rowKey));
- + del.deleteColumns(FAMILY, Bytes.toBytes("C"), HConstants.LATEST_TIMESTAMP);
- + table.delete(del);
- + // get row back and assert the values
- + get = new Get(Bytes.toBytes(rowKey));
- + result = table.get(get);
- + table.close();
- +
- + assertEquals("Column A value should be a",
- + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"), true);
- + assertEquals("Column A value should be b",
- + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"), true);
- + byte[] val = result.getValue(FAMILY, Bytes.toBytes("C"));
- + assertEquals("Column C should not exists", null, Bytes.toString(val));
- + }
- +
- /**
- * Basic client side validation of HBASE-4536
- */
Advertisement
Add Comment
Please, Sign In to add comment