Search in sources :

Example 1 with JacksonJaxbJsonProvider

use of org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project hbase by apache.

the class TestVersionResource method testGetStargateVersionJSON.

@Test
public void testGetStargateVersionJSON() throws IOException {
    Response response = client.get("/version", Constants.MIMETYPE_JSON);
    assertEquals(200, response.getCode());
    assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
    ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(VersionModel.class, MediaType.APPLICATION_JSON_TYPE);
    VersionModel model = mapper.readValue(response.getBody(), VersionModel.class);
    validate(model);
    LOG.info("success retrieving Stargate version as JSON");
}
Also used : Response(org.apache.hadoop.hbase.rest.client.Response) JacksonJaxbJsonProvider(org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StorageClusterVersionModel(org.apache.hadoop.hbase.rest.model.StorageClusterVersionModel) VersionModel(org.apache.hadoop.hbase.rest.model.VersionModel) Test(org.junit.Test)

Example 2 with JacksonJaxbJsonProvider

use of org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project hbase by apache.

the class TestNamespacesInstanceResource method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    conf = TEST_UTIL.getConfiguration();
    TEST_UTIL.startMiniCluster();
    REST_TEST_UTIL.startServletContainer(conf);
    client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
    testNamespacesInstanceModel = new TestNamespacesInstanceModel();
    context = JAXBContext.newInstance(NamespacesInstanceModel.class, TableListModel.class);
    jsonMapper = new JacksonJaxbJsonProvider().locateMapper(NamespacesInstanceModel.class, MediaType.APPLICATION_JSON_TYPE);
    NAMESPACE1_PROPS.put("key1", "value1");
    NAMESPACE2_PROPS.put("key2a", "value2a");
    NAMESPACE2_PROPS.put("key2b", "value2b");
    NAMESPACE3_PROPS.put("key3", "value3");
    NAMESPACE4_PROPS.put("key4a", "value4a");
    NAMESPACE4_PROPS.put("key4b", "value4b");
}
Also used : TestNamespacesInstanceModel(org.apache.hadoop.hbase.rest.model.TestNamespacesInstanceModel) NamespacesInstanceModel(org.apache.hadoop.hbase.rest.model.NamespacesInstanceModel) TableListModel(org.apache.hadoop.hbase.rest.model.TableListModel) TestNamespacesInstanceModel(org.apache.hadoop.hbase.rest.model.TestNamespacesInstanceModel) Cluster(org.apache.hadoop.hbase.rest.client.Cluster) JacksonJaxbJsonProvider(org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) Client(org.apache.hadoop.hbase.rest.client.Client) BeforeClass(org.junit.BeforeClass)

Example 3 with JacksonJaxbJsonProvider

use of org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider 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);
}
Also used : Response(org.apache.hadoop.hbase.rest.client.Response) CellSetModel(org.apache.hadoop.hbase.rest.model.CellSetModel) JacksonJaxbJsonProvider(org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with JacksonJaxbJsonProvider

use of org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project hbase by apache.

the class RowResourceBase method checkValueJSON.

protected static void checkValueJSON(String table, String row, String column, String value) throws IOException {
    Response response = getValueJson(table, row, column);
    assertEquals(200, response.getCode());
    assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
    ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
    CellSetModel cellSet = mapper.readValue(response.getBody(), CellSetModel.class);
    RowModel rowModel = cellSet.getRows().get(0);
    CellModel cell = rowModel.getCells().get(0);
    assertEquals(Bytes.toString(cell.getColumn()), column);
    assertEquals(Bytes.toString(cell.getValue()), value);
}
Also used : Response(org.apache.hadoop.hbase.rest.client.Response) CellSetModel(org.apache.hadoop.hbase.rest.model.CellSetModel) RowModel(org.apache.hadoop.hbase.rest.model.RowModel) CellModel(org.apache.hadoop.hbase.rest.model.CellModel) JacksonJaxbJsonProvider(org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with JacksonJaxbJsonProvider

use of org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider 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);
}
Also used : Response(org.apache.hadoop.hbase.rest.client.Response) CellSetModel(org.apache.hadoop.hbase.rest.model.CellSetModel) JacksonJaxbJsonProvider(org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

JacksonJaxbJsonProvider (org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)14 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)12 Response (org.apache.hadoop.hbase.rest.client.Response)11 CellSetModel (org.apache.hadoop.hbase.rest.model.CellSetModel)10 Test (org.junit.Test)9 RowModel (org.apache.hadoop.hbase.rest.model.RowModel)7 CellModel (org.apache.hadoop.hbase.rest.model.CellModel)4 Client (org.apache.hadoop.hbase.rest.client.Client)2 Cluster (org.apache.hadoop.hbase.rest.client.Cluster)2 StorageClusterVersionModel (org.apache.hadoop.hbase.rest.model.StorageClusterVersionModel)2 BeforeClass (org.junit.BeforeClass)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonParser (com.fasterxml.jackson.core.JsonParser)1 IOException (java.io.IOException)1 URL (java.net.URL)1 TableName (org.apache.hadoop.hbase.TableName)1 NamespacesInstanceModel (org.apache.hadoop.hbase.rest.model.NamespacesInstanceModel)1 TableListModel (org.apache.hadoop.hbase.rest.model.TableListModel)1 TestNamespacesInstanceModel (org.apache.hadoop.hbase.rest.model.TestNamespacesInstanceModel)1 VersionModel (org.apache.hadoop.hbase.rest.model.VersionModel)1