use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class TestGetAndPutResource method testStartEndRowGetPutXML.
@Test
public void testStartEndRowGetPutXML() throws IOException, JAXBException {
String[] rows = { ROW_1, ROW_2, ROW_3 };
String[] values = { VALUE_1, VALUE_2, VALUE_3 };
Response response = null;
for (int i = 0; i < rows.length; i++) {
response = putValueXML(TABLE, rows[i], COLUMN_1, values[i]);
assertEquals(200, response.getCode());
checkValueXML(TABLE, rows[i], COLUMN_1, values[i]);
}
response = getValueXML(TABLE, rows[0], rows[2], COLUMN_1);
assertEquals(200, response.getCode());
CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
assertEquals(2, cellSet.getRows().size());
for (int i = 0; i < cellSet.getRows().size() - 1; i++) {
RowModel rowModel = cellSet.getRows().get(i);
for (CellModel cell : rowModel.getCells()) {
assertEquals(COLUMN_1, Bytes.toString(cell.getColumn()));
assertEquals(values[i], Bytes.toString(cell.getValue()));
}
}
for (String row : rows) {
response = deleteRow(TABLE, row);
assertEquals(200, response.getCode());
}
}
use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class TestGetAndPutResource method testAppendXML.
@Test
public void testAppendXML() throws IOException, JAXBException {
Response response = getValueXML(TABLE, ROW_1, COLUMN_1);
assertEquals(404, response.getCode());
// append cell
response = appendValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
assertEquals(200, response.getCode());
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
response = appendValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
assertEquals(200, response.getCode());
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2);
response = deleteRow(TABLE, ROW_1);
assertEquals(200, response.getCode());
}
use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class TestGetAndPutResource method testSingleCellGetJSON.
@Test
public void testSingleCellGetJSON() throws IOException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
Response response = client.put(path, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_4));
assertEquals(200, response.getCode());
Thread.yield();
response = client.get(path, Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
response = deleteRow(TABLE, ROW_4);
assertEquals(200, response.getCode());
}
use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class TestGetAndPutResource method testIncrementPB.
@Test
public void testIncrementPB() throws IOException, JAXBException {
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
assertEquals(404, response.getCode());
// append cell
response = incrementValuePB(TABLE, ROW_1, COLUMN_1, VALUE_5);
assertEquals(200, response.getCode());
checkIncrementValuePB(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5));
response = incrementValuePB(TABLE, ROW_1, COLUMN_1, VALUE_6);
assertEquals(200, response.getCode());
checkIncrementValuePB(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6));
response = deleteRow(TABLE, ROW_1);
assertEquals(200, response.getCode());
}
use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class TestGetAndPutResource method testMultiCellGetPutPB.
@Test
public void testMultiCellGetPutPB() throws IOException {
// deliberate nonexistent row
String path = "/" + TABLE + "/fakerow";
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_1);
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_1), Bytes.toBytes(VALUE_1)));
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_2), Bytes.toBytes(VALUE_2)));
cellSetModel.addRow(rowModel);
rowModel = new RowModel(ROW_2);
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_1), Bytes.toBytes(VALUE_3)));
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_2), Bytes.toBytes(VALUE_4)));
cellSetModel.addRow(rowModel);
Response response = client.put(path, Constants.MIMETYPE_PROTOBUF, cellSetModel.createProtobufOutput());
Thread.yield();
// make sure the fake row was not actually created
response = client.get(path, Constants.MIMETYPE_PROTOBUF);
assertEquals(404, response.getCode());
// check that all of the values were created
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
checkValuePB(TABLE, ROW_2, COLUMN_1, VALUE_3);
checkValuePB(TABLE, ROW_2, COLUMN_2, VALUE_4);
response = deleteRow(TABLE, ROW_1);
assertEquals(200, response.getCode());
response = deleteRow(TABLE, ROW_2);
assertEquals(200, response.getCode());
}
Aggregations