hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From larsgeo...@apache.org
Subject svn commit: r1502433 [2/2] - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/thrift2/ main/java/org/apache/hadoop/hbase/thrift2/generated/ main/resources/org/apache/hadoop/hbase/thrift2/ test/java/org/apache/hadoop/hbase/thrift2/
Date Fri, 12 Jul 2013 06:04:40 GMT
Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java?rev=1502433&r1=1502432&r2=1502433&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
Fri Jul 12 06:04:40 2013
@@ -26,6 +26,7 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -35,6 +36,10 @@ import org.apache.hadoop.hbase.HColumnDe
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.filter.ParseFilter;
 import org.apache.hadoop.hbase.thrift.ThriftMetrics;
 import org.apache.hadoop.hbase.thrift2.generated.TColumn;
@@ -63,6 +68,10 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.getFromThrift;
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.putFromThrift;
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.scanFromThrift;
+import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.deleteFromThrift;
 import static org.junit.Assert.*;
 import static java.nio.ByteBuffer.wrap;
 
@@ -689,6 +698,37 @@ public class TestThriftHBaseServiceHandl
     verifyMetrics(metrics, "put_num_ops", 1);
     verifyMetrics(metrics, "exists_num_ops", 2);
   }
+
+  @Test
+  public void testAttribute() throws Exception {
+    byte[] rowName = "testAttribute".getBytes();
+    byte[] attributeKey = "attribute1".getBytes();
+    byte[] attributeValue = "value1".getBytes();
+    Map<ByteBuffer, ByteBuffer> attributes = new HashMap<ByteBuffer, ByteBuffer>();
+    attributes.put(wrap(attributeKey), wrap(attributeValue));
+
+    TGet tGet = new TGet(wrap(rowName));
+    tGet.setAttributes(attributes);
+    Get get = getFromThrift(tGet);
+    assertArrayEquals(get.getAttribute("attribute1"), attributeValue);
+
+    List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
+    columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));
+    TPut tPut = new TPut(wrap(rowName) , columnValues);
+    tPut.setAttributes(attributes);
+    Put put = putFromThrift(tPut);
+    assertArrayEquals(put.getAttribute("attribute1"), attributeValue);
+
+    TScan tScan = new TScan();
+    tScan.setAttributes(attributes);
+    Scan scan = scanFromThrift(tScan);
+    assertArrayEquals(scan.getAttribute("attribute1"), attributeValue);
+
+    TDelete tDelete = new TDelete(wrap(rowName));
+    tDelete.setAttributes(attributes);
+    Delete delete = deleteFromThrift(tDelete);
+    assertArrayEquals(delete.getAttribute("attribute1"), attributeValue);
+  }
  
   private static ThriftMetrics getMetrics(Configuration conf) throws Exception {
     setupMetricsContext();



Mime
View raw message