当前位置: 首页>>代码示例>>Java>>正文


Java JacksonProvider类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.rest.provider.JacksonProvider的典型用法代码示例。如果您正苦于以下问题:Java JacksonProvider类的具体用法?Java JacksonProvider怎么用?Java JacksonProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JacksonProvider类属于org.apache.hadoop.hbase.rest.provider包,在下文中一共展示了JacksonProvider类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpBeforeClass

import org.apache.hadoop.hbase.rest.provider.JacksonProvider; //导入依赖的package包/类
@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 JacksonProvider()
  .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");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestNamespacesInstanceResource.java

示例2: testMultiCellGetJSONNotFound

import org.apache.hadoop.hbase.rest.provider.JacksonProvider; //导入依赖的package包/类
@Test
public void testMultiCellGetJSONNotFound() throws IOException, JAXBException {
  String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1;

  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));
  Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
  assertEquals(response.getCode(), 200);
  ObjectMapper mapper = new JacksonProvider().locateMapper(CellSetModel.class,
    MediaType.APPLICATION_JSON_TYPE);
  CellSetModel cellSet = (CellSetModel) mapper.readValue(response.getBody(), CellSetModel.class);
  assertEquals(1, 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()));
  client.delete(row_5_url);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestMultiRowResource.java

示例3: testScanningUnknownColumnJson

import org.apache.hadoop.hbase.rest.provider.JacksonProvider; //导入依赖的package包/类
@Test
public void testScanningUnknownColumnJson() throws IOException, JAXBException {
  // 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 JacksonProvider().locateMapper(CellSetModel.class,
    MediaType.APPLICATION_JSON_TYPE);
  CellSetModel model = mapper.readValue(response.getStream(), CellSetModel.class);
  int count = TestScannerResource.countCellSet(model);
  assertEquals(0, count);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestTableScan.java

示例4: setUpBeforeClass

import org.apache.hadoop.hbase.rest.provider.JacksonProvider; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(conf);
  context = JAXBContext.newInstance(
      CellModel.class,
      CellSetModel.class,
      RowModel.class);
  xmlMarshaller = context.createMarshaller();
  xmlUnmarshaller = context.createUnmarshaller();
  jsonMapper = new JacksonProvider()
  .locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:RowResourceBase.java

示例5: checkValueJSON

import org.apache.hadoop.hbase.rest.provider.JacksonProvider; //导入依赖的package包/类
protected static void checkValueJSON(String table, String row, String column,
    String value) throws IOException, JAXBException {
  Response response = getValueJson(table, row, column);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
  ObjectMapper mapper = new JacksonProvider()
  .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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:RowResourceBase.java

示例6: testSimpleScannerJson

import org.apache.hadoop.hbase.rest.provider.JacksonProvider; //导入依赖的package包/类
@Test
public void testSimpleScannerJson() throws IOException, JAXBException {
  // Test scanning particular columns with limit.
  StringBuilder builder = new StringBuilder();
  builder.append("/*");
  builder.append("?");
  builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_1);
  builder.append("&");
  builder.append(Constants.SCAN_LIMIT + "=20");
  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 JacksonProvider()
      .locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
  CellSetModel model = mapper.readValue(response.getStream(), CellSetModel.class);
  int count = TestScannerResource.countCellSet(model);
  assertEquals(20, count);
  checkRowsNotNull(model);

  //Test scanning with no limit.
  builder = new StringBuilder();
  builder.append("/*");
  builder.append("?");
  builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_2);
  response = client.get("/" + TABLE + builder.toString(),
    Constants.MIMETYPE_JSON);
  assertEquals(200, response.getCode());
  assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
  model = mapper.readValue(response.getStream(), CellSetModel.class);
  count = TestScannerResource.countCellSet(model);
  assertEquals(expectedRows2, count);
  checkRowsNotNull(model);

  //Test with start row and end row.
  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 = client.get("/" + TABLE + builder.toString(),
    Constants.MIMETYPE_JSON);
  assertEquals(200, response.getCode());
  model = mapper.readValue(response.getStream(), CellSetModel.class);
  RowModel startRow = model.getRows().get(0);
  assertEquals("aaa", Bytes.toString(startRow.getKey()));
  RowModel endRow = model.getRows().get(model.getRows().size() - 1);
  assertEquals("aax", Bytes.toString(endRow.getKey()));
  count = TestScannerResource.countCellSet(model);
  assertEquals(24, count);
  checkRowsNotNull(model);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:56,代码来源:TestTableScan.java

示例7: testStreamingJSON

import org.apache.hadoop.hbase.rest.provider.JacksonProvider; //导入依赖的package包/类
@Test
public void testStreamingJSON() throws Exception {
  // Test scanning particular columns with limit.
  StringBuilder builder = new StringBuilder();
  builder.append("/*");
  builder.append("?");
  builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_1);
  builder.append("&");
  builder.append(Constants.SCAN_LIMIT + "=20");
  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 JacksonProvider()
      .locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
  CellSetModel model = mapper.readValue(response.getStream(), CellSetModel.class);
  int count = TestScannerResource.countCellSet(model);
  assertEquals(20, count);
  checkRowsNotNull(model);

  //Test scanning with no limit.
  builder = new StringBuilder();
  builder.append("/*");
  builder.append("?");
  builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_2);
  response = client.get("/" + TABLE + builder.toString(),
    Constants.MIMETYPE_JSON);
  assertEquals(200, response.getCode());
  assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
  model = mapper.readValue(response.getStream(), CellSetModel.class);
  count = TestScannerResource.countCellSet(model);
  assertEquals(expectedRows2, count);
  checkRowsNotNull(model);

  //Test with start row and end row.
  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 = client.get("/" + TABLE + builder.toString(),
    Constants.MIMETYPE_JSON);
  assertEquals(200, response.getCode());

  count = 0;
  JsonFactory jfactory = new JsonFactory(mapper);
  JsonParser jParser = jfactory.createJsonParser(response.getStream());
  boolean found = false;
  while (jParser.nextToken() != JsonToken.END_OBJECT) {
    if(jParser.getCurrentToken() == JsonToken.START_OBJECT && found) {
      RowModel row = jParser.readValueAs(RowModel.class);
      assertNotNull(row.getKey());
      for (int i = 0; i < row.getCells().size(); i++) {
        if (count == 0) {
          assertEquals("aaa", Bytes.toString(row.getKey()));
        }
        if (count == 23) {
          assertEquals("aax", Bytes.toString(row.getKey()));
        }
        count++;
      }
      jParser.skipChildren();
    } else {
      found = jParser.getCurrentToken() == JsonToken.START_ARRAY;
    }
  }
  assertEquals(24, count);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:72,代码来源:TestTableScan.java


注:本文中的org.apache.hadoop.hbase.rest.provider.JacksonProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。