當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。