switch (code) { case 201: uri = response.getLocation(); return; case 509:
@Test public void testTableDoesNotExist() throws IOException, JAXBException { ScannerModel model = new ScannerModel(); StringWriter writer = new StringWriter(); marshaller.marshal(model, writer); byte[] body = Bytes.toBytes(writer.toString()); Response response = client.put("/" + NONEXISTENT_TABLE + "/scanner", Constants.MIMETYPE_XML, body); String scannerURI = response.getLocation(); assertNotNull(scannerURI); response = client.get(scannerURI, Constants.MIMETYPE_XML); assertEquals(404, response.getCode()); }
void testScannerResultCodes() throws Exception { Header[] headers = new Header[3]; headers[0] = new BasicHeader("Content-Type", Constants.MIMETYPE_XML); headers[1] = new BasicHeader("Accept", Constants.MIMETYPE_JSON); headers[2] = new BasicHeader("Accept-Encoding", "gzip"); Response response = client.post("/" + TABLE + "/scanner", headers, Bytes.toBytes("<Scanner/>")); assertEquals(201, response.getCode()); String scannerUrl = response.getLocation(); assertNotNull(scannerUrl); response = client.get(scannerUrl); assertEquals(200, response.getCode()); response = client.get(scannerUrl); assertEquals(204, response.getCode()); }
@Test public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException { final int BATCH_SIZE = 5; // new scanner ScannerModel model = new ScannerModel(); model.setBatch(BATCH_SIZE); model.addColumn(Bytes.toBytes(COLUMN_1)); model.addLabel(PUBLIC); StringWriter writer = new StringWriter(); marshaller.marshal(model, writer); byte[] body = Bytes.toBytes(writer.toString()); // recall previous put operation with read-only off conf.set("hbase.rest.readonly", "false"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); // Respond with 204 as there are no cells to be retrieved assertEquals(204, response.getCode()); // With no content in the payload, the 'Content-Type' header is not echo back }
Constants.MIMETYPE_XML, body); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI);
@Test public void testSimpleScannerXMLWithLabelsThatReceivesData() throws IOException, JAXBException { // new scanner ScannerModel model = new ScannerModel(); model.setBatch(5); model.addColumn(Bytes.toBytes(COLUMN_1)); model.addLabel(SECRET); StringWriter writer = new StringWriter(); marshaller.marshal(model, writer); byte[] body = Bytes.toBytes(writer.toString()); // recall previous put operation with read-only off conf.set("hbase.rest.readonly", "false"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); // Respond with 204 as there are no cells to be retrieved assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response .getBody())); assertEquals(5, countCellSet(cellSet)); }
Constants.MIMETYPE_XML, body); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI);
Constants.MIMETYPE_XML, body); assertEquals(403, response.getCode()); String scannerURI = response.getLocation(); assertNull(scannerURI); body); assertEquals(201, response.getCode()); scannerURI = response.getLocation(); assertNotNull(scannerURI);
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); assertEquals(403, response.getCode()); String scannerURI = response.getLocation(); assertNull(scannerURI); Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); assertEquals(201, response.getCode()); scannerURI = response.getLocation(); assertNotNull(scannerURI);
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); int count = 0;
Constants.MIMETYPE_XML, body); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI);
@Test public void testTableScanWithTableDisable() throws IOException { ScannerModel model = new ScannerModel(); model.addColumn(Bytes.toBytes(COLUMN_1)); model.setCaching(1); Response response = client.put("/" + TABLE_TO_BE_DISABLED + "/scanner", Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); TEST_UTIL.getAdmin().disableTable(TABLE_TO_BE_DISABLED); response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF); assertTrue("got " + response.getCode(), response.getCode() == 410); }
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); assertEquals(403, response.getCode()); String scannerURI = response.getLocation(); assertNull(scannerURI); Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); assertEquals(201, response.getCode()); scannerURI = response.getLocation(); assertNotNull(scannerURI);
switch (code) { case 201: uri = response.getLocation(); return; case 509:
@Test public void testTableDoesNotExist() throws IOException, JAXBException { ScannerModel model = new ScannerModel(); StringWriter writer = new StringWriter(); marshaller.marshal(model, writer); byte[] body = Bytes.toBytes(writer.toString()); Response response = client.put("/" + NONEXISTENT_TABLE + "/scanner", Constants.MIMETYPE_XML, body); String scannerURI = response.getLocation(); assertNotNull(scannerURI); response = client.get(scannerURI, Constants.MIMETYPE_XML); assertEquals(404, response.getCode()); }
void testScannerResultCodes() throws Exception { Header[] headers = new Header[3]; headers[0] = new BasicHeader("Content-Type", Constants.MIMETYPE_XML); headers[1] = new BasicHeader("Accept", Constants.MIMETYPE_JSON); headers[2] = new BasicHeader("Accept-Encoding", "gzip"); Response response = client.post("/" + TABLE + "/scanner", headers, Bytes.toBytes("<Scanner/>")); assertEquals(201, response.getCode()); String scannerUrl = response.getLocation(); assertNotNull(scannerUrl); response = client.get(scannerUrl); assertEquals(200, response.getCode()); response = client.get(scannerUrl); assertEquals(204, response.getCode()); }
@Test public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException { final int BATCH_SIZE = 5; // new scanner ScannerModel model = new ScannerModel(); model.setBatch(BATCH_SIZE); model.addColumn(Bytes.toBytes(COLUMN_1)); model.addLabel(PUBLIC); StringWriter writer = new StringWriter(); marshaller.marshal(model, writer); byte[] body = Bytes.toBytes(writer.toString()); // recall previous put operation with read-only off conf.set("hbase.rest.readonly", "false"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); // Respond with 204 as there are no cells to be retrieved assertEquals(204, response.getCode()); // With no content in the payload, the 'Content-Type' header is not echo back }
@Test public void testSimpleScannerXMLWithLabelsThatReceivesData() throws IOException, JAXBException { // new scanner ScannerModel model = new ScannerModel(); model.setBatch(5); model.addColumn(Bytes.toBytes(COLUMN_1)); model.addLabel(SECRET); StringWriter writer = new StringWriter(); marshaller.marshal(model, writer); byte[] body = Bytes.toBytes(writer.toString()); // recall previous put operation with read-only off conf.set("hbase.rest.readonly", "false"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); // Respond with 204 as there are no cells to be retrieved assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response .getBody())); assertEquals(5, countCellSet(cellSet)); }
Constants.MIMETYPE_XML, body); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI);
@Test public void testTableScanWithTableDisable() throws IOException { ScannerModel model = new ScannerModel(); model.addColumn(Bytes.toBytes(COLUMN_1)); model.setCaching(1); Response response = client.put("/" + TABLE_TO_BE_DISABLED + "/scanner", Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); TEST_UTIL.getAdmin().disableTable(TABLE_TO_BE_DISABLED); response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF); assertTrue("got " + response.getCode(), response.getCode() == 410); }