HBASE-9375 [REST] Querying row data gives all the available versions of a column (Vandana Ayyalasomayajula)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1522590 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
37e9a86396
commit
d70829a110
|
@ -46,7 +46,7 @@ public class RowSpec {
|
|||
new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
|
||||
private long startTime = DEFAULT_START_TIMESTAMP;
|
||||
private long endTime = DEFAULT_END_TIMESTAMP;
|
||||
private int maxVersions = HColumnDescriptor.DEFAULT_VERSIONS;
|
||||
private int maxVersions = 1;
|
||||
private int maxValues = Integer.MAX_VALUE;
|
||||
|
||||
public RowSpec(String path) throws IllegalArgumentException {
|
||||
|
|
|
@ -52,7 +52,9 @@ import org.apache.hadoop.hbase.security.User;
|
|||
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
@ -97,6 +99,10 @@ public class TestRowResource {
|
|||
unmarshaller = context.createUnmarshaller();
|
||||
client = new Client(new Cluster().add("localhost",
|
||||
REST_TEST_UTIL.getServletPort()));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void beforeMethod() throws Exception {
|
||||
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||
if (admin.tableExists(TABLE)) {
|
||||
return;
|
||||
|
@ -107,6 +113,15 @@ public class TestRowResource {
|
|||
admin.createTable(htd);
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterMethod() throws Exception {
|
||||
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||
if (admin.tableExists(TABLE)) {
|
||||
admin.disableTable(TABLE);
|
||||
admin.deleteTable(TABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
REST_TEST_UTIL.shutdownServletContainer();
|
||||
|
@ -721,5 +736,33 @@ public class TestRowResource {
|
|||
assertEquals(response.getCode(), 400);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLatestCellGetXML() throws IOException, JAXBException {
|
||||
final String path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1;
|
||||
CellSetModel cellSetModel = new CellSetModel();
|
||||
RowModel rowModel = new RowModel(ROW_1);
|
||||
CellModel cellOne = new CellModel(Bytes.toBytes(COLUMN_1), 1L, Bytes.toBytes(VALUE_1));
|
||||
CellModel cellTwo = new CellModel(Bytes.toBytes(COLUMN_1), 2L, Bytes.toBytes(VALUE_2));
|
||||
rowModel.addCell(cellOne);
|
||||
rowModel.addCell(cellTwo);
|
||||
cellSetModel.addRow(rowModel);
|
||||
StringWriter writer = new StringWriter();
|
||||
marshaller.marshal(cellSetModel, writer);
|
||||
Response response = client.put(path, Constants.MIMETYPE_XML, Bytes.toBytes(writer.toString()));
|
||||
assertEquals(response.getCode(), 200);
|
||||
response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
||||
assertEquals(response.getCode(), 200);
|
||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||
CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response
|
||||
.getBody()));
|
||||
assertTrue(cellSet.getRows().size() == 1);
|
||||
assertTrue(cellSet.getRows().get(0).getCells().size() == 1);
|
||||
CellModel cell = cellSet.getRows().get(0).getCells().get(0);
|
||||
assertEquals(VALUE_2, Bytes.toString(cell.getValue()));
|
||||
assertEquals(2L, cell.getTimestamp());
|
||||
response = deleteRow(TABLE, ROW_1);
|
||||
assertEquals(response.getCode(), 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue