use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class TestGetAndPutResource method testNoSuchCF.
@Test
public void testNoSuchCF() throws IOException {
final String goodPath = "/" + TABLE + "/" + ROW_1 + "/" + CFA + ":";
final String badPath = "/" + TABLE + "/" + ROW_1 + "/" + "BAD";
Response response = client.post(goodPath, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1));
assertEquals(200, response.getCode());
assertEquals(200, client.get(goodPath, Constants.MIMETYPE_BINARY).getCode());
assertEquals(404, client.get(badPath, Constants.MIMETYPE_BINARY).getCode());
assertEquals(200, client.get(goodPath, Constants.MIMETYPE_BINARY).getCode());
}
use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class TestMultiRowResource method testMultiCellGetWithColsJSON.
@Test
public void testMultiCellGetWithColsJSON() throws IOException {
String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1;
String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2;
StringBuilder path = new StringBuilder();
path.append("/");
path.append(TABLE);
path.append("/multiget");
path.append("/" + COLUMN_1 + "," + CFB);
path.append("?row=");
path.append(ROW_1);
path.append("&row=");
path.append(ROW_2);
client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1), extraHdr);
client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2), extraHdr);
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
CellSetModel cellSet = mapper.readValue(response.getBody(), CellSetModel.class);
assertEquals(2, cellSet.getRows().size());
assertEquals(ROW_1, Bytes.toString(cellSet.getRows().get(0).getKey()));
assertEquals(VALUE_1, Bytes.toString(cellSet.getRows().get(0).getCells().get(0).getValue()));
assertEquals(ROW_2, Bytes.toString(cellSet.getRows().get(1).getKey()));
assertEquals(VALUE_2, Bytes.toString(cellSet.getRows().get(1).getCells().get(0).getValue()));
client.delete(row_5_url, extraHdr);
client.delete(row_6_url, extraHdr);
}
use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class TestMultiRowResource method testMultiCellGetXML.
@Test
public void testMultiCellGetXML() throws IOException {
String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1;
String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2;
StringBuilder path = new StringBuilder();
path.append("/");
path.append(TABLE);
path.append("/multiget/?row=");
path.append(ROW_1);
path.append("&row=");
path.append(ROW_2);
client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1), extraHdr);
client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2), extraHdr);
Response response = client.get(path.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
client.delete(row_5_url, extraHdr);
client.delete(row_6_url, extraHdr);
}
use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class RowResourceBase method putValueXML.
protected static Response putValueXML(String url, String table, String row, String column, String value) throws IOException, JAXBException {
RowModel rowModel = new RowModel(row);
rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(value)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
Response response = client.put(url, Constants.MIMETYPE_XML, Bytes.toBytes(writer.toString()));
Thread.yield();
return response;
}
use of org.apache.hadoop.hbase.rest.client.Response in project hbase by apache.
the class RowResourceBase method putValueJson.
protected static Response putValueJson(String url, String table, String row, String column, String value) throws IOException {
RowModel rowModel = new RowModel(row);
rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(value)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
String jsonString = jsonMapper.writeValueAsString(cellSetModel);
Response response = client.put(url, Constants.MIMETYPE_JSON, Bytes.toBytes(jsonString));
Thread.yield();
return response;
}
Aggregations