use of org.apache.hadoop.hbase.rest.model.CellSetModel in project hbase by apache.
the class RowResourceBase method checkValueXML.
protected static void checkValueXML(String url, String table, String row, String column, String value) throws IOException, JAXBException {
Response response = getValueXML(url);
assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
RowModel rowModel = cellSet.getRows().get(0);
CellModel cell = rowModel.getCells().get(0);
assertEquals(Bytes.toString(cell.getColumn()), column);
assertEquals(Bytes.toString(cell.getValue()), value);
}
use of org.apache.hadoop.hbase.rest.model.CellSetModel in project hbase by apache.
the class RowResourceBase method checkIncrementValueXML.
protected static void checkIncrementValueXML(String table, String row, String column, long value) throws IOException, JAXBException {
Response response1 = getValueXML(table, row, column);
assertEquals(200, response1.getCode());
assertEquals(Constants.MIMETYPE_XML, response1.getHeader("content-type"));
CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response1.getBody()));
RowModel rowModel = cellSet.getRows().get(0);
CellModel cell = rowModel.getCells().get(0);
assertEquals(Bytes.toString(cell.getColumn()), column);
assertEquals(Bytes.toLong(cell.getValue()), value);
}
use of org.apache.hadoop.hbase.rest.model.CellSetModel in project hbase by apache.
the class TestTableScan method testReversed.
@Test
public void testReversed() throws IOException, JAXBException {
StringBuilder builder = new StringBuilder();
builder.append("/*");
builder.append("?");
builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_1);
builder.append("&");
builder.append(Constants.SCAN_START_ROW + "=aaa");
builder.append("&");
builder.append(Constants.SCAN_END_ROW + "=aay");
Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
JAXBContext ctx = JAXBContext.newInstance(CellSetModel.class);
Unmarshaller ush = ctx.createUnmarshaller();
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
int count = TestScannerResource.countCellSet(model);
assertEquals(24, count);
List<RowModel> rowModels = model.getRows().subList(1, count);
// reversed
builder = new StringBuilder();
builder.append("/*");
builder.append("?");
builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_1);
builder.append("&");
builder.append(Constants.SCAN_START_ROW + "=aay");
builder.append("&");
builder.append(Constants.SCAN_END_ROW + "=aaa");
builder.append("&");
builder.append(Constants.SCAN_REVERSED + "=true");
response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
model = (CellSetModel) ush.unmarshal(response.getStream());
count = TestScannerResource.countCellSet(model);
assertEquals(24, count);
List<RowModel> reversedRowModels = model.getRows().subList(1, count);
Collections.reverse(reversedRowModels);
assertEquals(rowModels.size(), reversedRowModels.size());
for (int i = 0; i < rowModels.size(); i++) {
RowModel rowModel = rowModels.get(i);
RowModel reversedRowModel = reversedRowModels.get(i);
assertEquals(new String(rowModel.getKey(), StandardCharsets.UTF_8), new String(reversedRowModel.getKey(), StandardCharsets.UTF_8));
assertEquals(new String(rowModel.getCells().get(0).getValue(), StandardCharsets.UTF_8), new String(reversedRowModel.getCells().get(0).getValue(), StandardCharsets.UTF_8));
}
}
use of org.apache.hadoop.hbase.rest.model.CellSetModel in project hbase by apache.
the class TestTableScan method testCompoundFilter.
@Test
public void testCompoundFilter() throws IOException, JAXBException {
StringBuilder builder = new StringBuilder();
builder.append("/*");
builder.append("?");
builder.append(Constants.SCAN_FILTER + "=" + URLEncoder.encode("PrefixFilter('abc') AND QualifierFilter(=,'binary:1')", "UTF-8"));
Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
JAXBContext ctx = JAXBContext.newInstance(CellSetModel.class);
Unmarshaller ush = ctx.createUnmarshaller();
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
int count = TestScannerResource.countCellSet(model);
assertEquals(1, count);
assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue(), StandardCharsets.UTF_8));
}
use of org.apache.hadoop.hbase.rest.model.CellSetModel in project hbase by apache.
the class TestTableScan method testScanningUnknownColumnJson.
@Test
public void testScanningUnknownColumnJson() throws IOException {
// Test scanning particular columns with limit.
StringBuilder builder = new StringBuilder();
builder.append("/*");
builder.append("?");
builder.append(Constants.SCAN_COLUMN + "=a:test");
Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
CellSetModel model = mapper.readValue(response.getStream(), CellSetModel.class);
int count = TestScannerResource.countCellSet(model);
assertEquals(0, count);
}
Aggregations