HBASE-19846 Fix findbugs and error-prone warnings in hbase-rest (branch-2)
Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
ce50830a0a
commit
aeffca497b
|
@ -27,14 +27,15 @@ import javax.ws.rs.core.MultivaluedMap;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.apache.hadoop.hbase.Cell;
|
import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.rest.model.CellModel;
|
import org.apache.hadoop.hbase.rest.model.CellModel;
|
||||||
import org.apache.hadoop.hbase.rest.model.CellSetModel;
|
import org.apache.hadoop.hbase.rest.model.CellSetModel;
|
||||||
import org.apache.hadoop.hbase.rest.model.RowModel;
|
import org.apache.hadoop.hbase.rest.model.RowModel;
|
||||||
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class MultiRowResource extends ResourceBase implements Constants {
|
public class MultiRowResource extends ResourceBase implements Constants {
|
||||||
|
@ -83,7 +84,7 @@ public class MultiRowResource extends ResourceBase implements Constants {
|
||||||
|
|
||||||
if (this.columns != null) {
|
if (this.columns != null) {
|
||||||
for (int i = 0; i < this.columns.length; i++) {
|
for (int i = 0; i < this.columns.length; i++) {
|
||||||
rowSpec.addColumn(this.columns[i].getBytes());
|
rowSpec.addColumn(Bytes.toBytes(this.columns[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,17 +23,17 @@ import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.apache.hadoop.hbase.Cell;
|
import org.apache.hadoop.hbase.Cell;
|
||||||
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
||||||
import org.apache.hadoop.hbase.client.Get;
|
import org.apache.hadoop.hbase.client.Get;
|
||||||
import org.apache.hadoop.hbase.client.Result;
|
import org.apache.hadoop.hbase.client.Result;
|
||||||
import org.apache.hadoop.hbase.client.Table;
|
import org.apache.hadoop.hbase.client.Table;
|
||||||
import org.apache.hadoop.hbase.filter.Filter;
|
import org.apache.hadoop.hbase.filter.Filter;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class RowResultGenerator extends ResultGenerator {
|
public class RowResultGenerator extends ResultGenerator {
|
||||||
|
@ -83,9 +83,11 @@ public class RowResultGenerator extends ResultGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -96,6 +98,7 @@ public class RowResultGenerator extends ResultGenerator {
|
||||||
return valuesI.hasNext();
|
return valuesI.hasNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Cell next() {
|
public Cell next() {
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
Cell kv = cache;
|
Cell kv = cache;
|
||||||
|
@ -112,10 +115,12 @@ public class RowResultGenerator extends ResultGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void putBack(Cell kv) {
|
public void putBack(Cell kv) {
|
||||||
this.cache = kv;
|
this.cache = kv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
throw new UnsupportedOperationException("remove not supported");
|
throw new UnsupportedOperationException("remove not supported");
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,6 +376,7 @@ public class RowSpec {
|
||||||
this.endTime = endTime;
|
this.endTime = endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
result.append("{startRow => '");
|
result.append("{startRow => '");
|
||||||
|
|
|
@ -27,9 +27,6 @@ import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.TableNotEnabledException;
|
import org.apache.hadoop.hbase.TableNotEnabledException;
|
||||||
import org.apache.hadoop.hbase.TableNotFoundException;
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
import org.apache.hadoop.hbase.UnknownScannerException;
|
import org.apache.hadoop.hbase.UnknownScannerException;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.apache.hadoop.hbase.client.Result;
|
import org.apache.hadoop.hbase.client.Result;
|
||||||
import org.apache.hadoop.hbase.client.ResultScanner;
|
import org.apache.hadoop.hbase.client.ResultScanner;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
|
@ -38,6 +35,9 @@ import org.apache.hadoop.hbase.filter.Filter;
|
||||||
import org.apache.hadoop.hbase.rest.model.ScannerModel;
|
import org.apache.hadoop.hbase.rest.model.ScannerModel;
|
||||||
import org.apache.hadoop.hbase.security.visibility.Authorizations;
|
import org.apache.hadoop.hbase.security.visibility.Authorizations;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class ScannerResultGenerator extends ResultGenerator {
|
public class ScannerResultGenerator extends ResultGenerator {
|
||||||
|
@ -115,6 +115,7 @@ public class ScannerResultGenerator extends ResultGenerator {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
if (scanner != null) {
|
if (scanner != null) {
|
||||||
scanner.close();
|
scanner.close();
|
||||||
|
@ -122,6 +123,7 @@ public class ScannerResultGenerator extends ResultGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -145,6 +147,7 @@ public class ScannerResultGenerator extends ResultGenerator {
|
||||||
return cached != null;
|
return cached != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Cell next() {
|
public Cell next() {
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
Cell kv = cache;
|
Cell kv = cache;
|
||||||
|
@ -187,10 +190,12 @@ public class ScannerResultGenerator extends ResultGenerator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void putBack(Cell kv) {
|
public void putBack(Cell kv) {
|
||||||
this.cache = kv;
|
this.cache = kv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
throw new UnsupportedOperationException("remove not supported");
|
throw new UnsupportedOperationException("remove not supported");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -30,12 +32,12 @@ import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
|
||||||
import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
|
import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
|
||||||
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a row. A row is a related set of cells, grouped by common
|
* Representation of a row. A row is a related set of cells, grouped by common
|
||||||
|
@ -77,7 +79,7 @@ public class RowModel implements ProtobufMessageHandler, Serializable {
|
||||||
* @param key the row key
|
* @param key the row key
|
||||||
*/
|
*/
|
||||||
public RowModel(final String key) {
|
public RowModel(final String key) {
|
||||||
this(key.getBytes());
|
this(Bytes.toBytes(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +97,7 @@ public class RowModel implements ProtobufMessageHandler, Serializable {
|
||||||
* @param cells the cells
|
* @param cells the cells
|
||||||
*/
|
*/
|
||||||
public RowModel(final String key, final List<CellModel> cells) {
|
public RowModel(final String key, final List<CellModel> cells) {
|
||||||
this(key.getBytes(), cells);
|
this(Bytes.toBytes(key), cells);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
|
@ -63,7 +64,7 @@ public class ProtobufMessageBodyConsumer
|
||||||
throws IOException, WebApplicationException {
|
throws IOException, WebApplicationException {
|
||||||
ProtobufMessageHandler obj = null;
|
ProtobufMessageHandler obj = null;
|
||||||
try {
|
try {
|
||||||
obj = type.newInstance();
|
obj = type.getDeclaredConstructor().newInstance();
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
byte[] buffer = new byte[4096];
|
byte[] buffer = new byte[4096];
|
||||||
int read;
|
int read;
|
||||||
|
@ -78,9 +79,8 @@ public class ProtobufMessageBodyConsumer
|
||||||
inputStream);
|
inputStream);
|
||||||
}
|
}
|
||||||
obj = obj.getObjectFromMessage(baos.toByteArray());
|
obj = obj.getObjectFromMessage(baos.toByteArray());
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException
|
||||||
throw new WebApplicationException(e);
|
| IllegalAccessException e) {
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new WebApplicationException(e);
|
throw new WebApplicationException(e);
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
|
|
|
@ -31,8 +31,9 @@ import javax.ws.rs.core.MultivaluedMap;
|
||||||
import javax.ws.rs.ext.MessageBodyWriter;
|
import javax.ws.rs.ext.MessageBodyWriter;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.hadoop.hbase.rest.Constants;
|
import org.apache.hadoop.hbase.rest.Constants;
|
||||||
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An adapter between Jersey and Object.toString(). Hooks up plain text output
|
* An adapter between Jersey and Object.toString(). Hooks up plain text output
|
||||||
|
@ -64,6 +65,6 @@ public class PlainTextMessageBodyProducer
|
||||||
Annotation[] annotations, MediaType mediaType,
|
Annotation[] annotations, MediaType mediaType,
|
||||||
MultivaluedMap<String, Object> httpHeaders, OutputStream outStream)
|
MultivaluedMap<String, Object> httpHeaders, OutputStream outStream)
|
||||||
throws IOException, WebApplicationException {
|
throws IOException, WebApplicationException {
|
||||||
outStream.write(object.toString().getBytes());
|
outStream.write(Bytes.toBytes(object.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.provider.producer;
|
package org.apache.hadoop.hbase.rest.provider.producer;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
|
@ -32,9 +31,9 @@ import javax.ws.rs.core.MultivaluedMap;
|
||||||
import javax.ws.rs.ext.MessageBodyWriter;
|
import javax.ws.rs.ext.MessageBodyWriter;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
|
||||||
import org.apache.hadoop.hbase.rest.Constants;
|
import org.apache.hadoop.hbase.rest.Constants;
|
||||||
import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
|
import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
|
||||||
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An adapter between Jersey and ProtobufMessageHandler implementors. Hooks up
|
* An adapter between Jersey and ProtobufMessageHandler implementors. Hooks up
|
||||||
|
@ -61,6 +60,7 @@ public class ProtobufMessageBodyProducer
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeTo(ProtobufMessageHandler m, Class<?> type, Type genericType,
|
public void writeTo(ProtobufMessageHandler m, Class<?> type, Type genericType,
|
||||||
Annotation[] annotations, MediaType mediaType,
|
Annotation[] annotations, MediaType mediaType,
|
||||||
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
|
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class RowResourceBase {
|
||||||
protected static void checkValueXML(String url, String table, String row,
|
protected static void checkValueXML(String url, String table, String row,
|
||||||
String column, String value) throws IOException, JAXBException {
|
String column, String value) throws IOException, JAXBException {
|
||||||
Response response = getValueXML(url);
|
Response response = getValueXML(url);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel)
|
CellSetModel cellSet = (CellSetModel)
|
||||||
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
|
@ -167,7 +167,7 @@ public class RowResourceBase {
|
||||||
protected static void checkValueXML(String table, String row, String column,
|
protected static void checkValueXML(String table, String row, String column,
|
||||||
String value) throws IOException, JAXBException {
|
String value) throws IOException, JAXBException {
|
||||||
Response response = getValueXML(table, row, column);
|
Response response = getValueXML(table, row, column);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel)
|
CellSetModel cellSet = (CellSetModel)
|
||||||
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
|
@ -180,7 +180,7 @@ public class RowResourceBase {
|
||||||
protected static void checkIncrementValueXML(String table, String row, String column,
|
protected static void checkIncrementValueXML(String table, String row, String column,
|
||||||
long value) throws IOException, JAXBException {
|
long value) throws IOException, JAXBException {
|
||||||
Response response1 = getValueXML(table, row, column);
|
Response response1 = getValueXML(table, row, column);
|
||||||
assertEquals(response1.getCode(), 200);
|
assertEquals(200, response1.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response1.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response1.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel)
|
CellSetModel cellSet = (CellSetModel)
|
||||||
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response1.getBody()));
|
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response1.getBody()));
|
||||||
|
@ -237,7 +237,7 @@ public class RowResourceBase {
|
||||||
protected static void checkValuePB(String table, String row, String column,
|
protected static void checkValuePB(String table, String row, String column,
|
||||||
String value) throws IOException {
|
String value) throws IOException {
|
||||||
Response response = getValuePB(table, row, column);
|
Response response = getValuePB(table, row, column);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = new CellSetModel();
|
CellSetModel cellSet = new CellSetModel();
|
||||||
cellSet.getObjectFromMessage(response.getBody());
|
cellSet.getObjectFromMessage(response.getBody());
|
||||||
|
@ -250,7 +250,7 @@ public class RowResourceBase {
|
||||||
protected static void checkIncrementValuePB(String table, String row, String column,
|
protected static void checkIncrementValuePB(String table, String row, String column,
|
||||||
long value) throws IOException {
|
long value) throws IOException {
|
||||||
Response response = getValuePB(table, row, column);
|
Response response = getValuePB(table, row, column);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = new CellSetModel();
|
CellSetModel cellSet = new CellSetModel();
|
||||||
cellSet.getObjectFromMessage(response.getBody());
|
cellSet.getObjectFromMessage(response.getBody());
|
||||||
|
@ -536,7 +536,7 @@ public class RowResourceBase {
|
||||||
protected static void checkValueJSON(String table, String row, String column,
|
protected static void checkValueJSON(String table, String row, String column,
|
||||||
String value) throws IOException, JAXBException {
|
String value) throws IOException, JAXBException {
|
||||||
Response response = getValueJson(table, row, column);
|
Response response = getValueJson(table, row, column);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
||||||
ObjectMapper mapper = new JacksonJaxbJsonProvider()
|
ObjectMapper mapper = new JacksonJaxbJsonProvider()
|
||||||
.locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
|
.locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
|
||||||
|
@ -550,7 +550,7 @@ public class RowResourceBase {
|
||||||
protected static void checkIncrementValueJSON(String table, String row, String column,
|
protected static void checkIncrementValueJSON(String table, String row, String column,
|
||||||
long value) throws IOException, JAXBException {
|
long value) throws IOException, JAXBException {
|
||||||
Response response = getValueJson(table, row, column);
|
Response response = getValueJson(table, row, column);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
||||||
ObjectMapper mapper = new JacksonJaxbJsonProvider()
|
ObjectMapper mapper = new JacksonJaxbJsonProvider()
|
||||||
.locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
|
.locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
|
||||||
|
|
|
@ -59,39 +59,39 @@ public class TestDeleteRow extends RowResourceBase {
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteXML() throws IOException, JAXBException {
|
public void testDeleteXML() throws IOException, JAXBException {
|
||||||
Response response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
Response response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = putValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
response = putValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
|
|
||||||
response = deleteValue(TABLE, ROW_1, COLUMN_1);
|
response = deleteValue(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
|
|
||||||
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
response = getValueXML(TABLE, ROW_1, COLUMN_2);
|
response = getValueXML(TABLE, ROW_1, COLUMN_2);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
//Delete a row in non existent table
|
//Delete a row in non existent table
|
||||||
response = deleteValue("dummy", ROW_1, COLUMN_1);
|
response = deleteValue("dummy", ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
//Delete non existent column
|
//Delete non existent column
|
||||||
response = deleteValue(TABLE, ROW_1, "dummy");
|
response = deleteValue(TABLE, ROW_1, "dummy");
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,92 +55,92 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
conf.set("hbase.rest.readonly", "true");
|
conf.set("hbase.rest.readonly", "true");
|
||||||
|
|
||||||
Response response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
Response response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2);
|
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2);
|
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
response = deleteValue(TABLE, ROW_1, COLUMN_1);
|
response = deleteValue(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
|
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
|
|
||||||
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2);
|
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3);
|
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = deleteValue(TABLE, ROW_1, COLUMN_1);
|
response = deleteValue(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingleCellGetPutXML() throws IOException, JAXBException {
|
public void testSingleCellGetPutXML() throws IOException, JAXBException {
|
||||||
Response response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
Response response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
||||||
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3);
|
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
||||||
response = checkAndDeleteXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
response = checkAndDeleteXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingleCellGetPutPB() throws IOException, JAXBException {
|
public void testSingleCellGetPutPB() throws IOException, JAXBException {
|
||||||
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
||||||
|
|
||||||
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3);
|
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
||||||
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3, VALUE_4);
|
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3, VALUE_4);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_4);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_4);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleCellCheckPutPB() throws IOException, JAXBException {
|
public void testMultipleCellCheckPutPB() throws IOException, JAXBException {
|
||||||
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// Add 2 Columns to setup the test
|
// Add 2 Columns to setup the test
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
|
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
|
|
||||||
HashMap<String,String> otherCells = new HashMap<>();
|
HashMap<String,String> otherCells = new HashMap<>();
|
||||||
|
@ -148,32 +148,32 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// On Success update both the cells
|
// On Success update both the cells
|
||||||
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_3, otherCells);
|
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_3, otherCells);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_3);
|
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_3);
|
||||||
|
|
||||||
// On Failure, we dont update any cells
|
// On Failure, we dont update any cells
|
||||||
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_4, otherCells);
|
response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_4, otherCells);
|
||||||
assertEquals(response.getCode(), 304);
|
assertEquals(304, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_3);
|
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_3);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleCellCheckPutXML() throws IOException, JAXBException {
|
public void testMultipleCellCheckPutXML() throws IOException, JAXBException {
|
||||||
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// Add 2 Columns to setup the test
|
// Add 2 Columns to setup the test
|
||||||
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
|
|
||||||
response = putValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
response = putValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
|
|
||||||
HashMap<String,String> otherCells = new HashMap<>();
|
HashMap<String,String> otherCells = new HashMap<>();
|
||||||
|
@ -181,36 +181,36 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// On Success update both the cells
|
// On Success update both the cells
|
||||||
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_3, otherCells);
|
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_3, otherCells);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_3);
|
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_3);
|
||||||
|
|
||||||
// On Failure, we dont update any cells
|
// On Failure, we dont update any cells
|
||||||
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_4, otherCells);
|
response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_4, otherCells);
|
||||||
assertEquals(response.getCode(), 304);
|
assertEquals(304, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3);
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_3);
|
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_3);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleCellCheckDeletePB() throws IOException, JAXBException {
|
public void testMultipleCellCheckDeletePB() throws IOException, JAXBException {
|
||||||
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// Add 3 Columns to setup the test
|
// Add 3 Columns to setup the test
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
|
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
|
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
response = putValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
||||||
|
|
||||||
// Deletes the following columns based on Column1 check
|
// Deletes the following columns based on Column1 check
|
||||||
|
@ -220,44 +220,44 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// On Success update both the cells
|
// On Success update both the cells
|
||||||
response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1, cellsToDelete);
|
response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1, cellsToDelete);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
|
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
|
|
||||||
response = getValuePB(TABLE, ROW_1, COLUMN_2);
|
response = getValuePB(TABLE, ROW_1, COLUMN_2);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
response = getValuePB(TABLE, ROW_1, COLUMN_3);
|
response = getValuePB(TABLE, ROW_1, COLUMN_3);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
|
|
||||||
response = putValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
response = putValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
||||||
|
|
||||||
// On Failure, we dont update any cells
|
// On Failure, we dont update any cells
|
||||||
response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_3, cellsToDelete);
|
response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_3, cellsToDelete);
|
||||||
assertEquals(response.getCode(), 304);
|
assertEquals(304, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testSingleCellGetPutBinary() throws IOException {
|
public void testSingleCellGetPutBinary() throws IOException {
|
||||||
final String path = "/" + TABLE + "/" + ROW_3 + "/" + COLUMN_1;
|
final String path = "/" + TABLE + "/" + ROW_3 + "/" + COLUMN_1;
|
||||||
final byte[] body = Bytes.toBytes(VALUE_3);
|
final byte[] body = Bytes.toBytes(VALUE_3);
|
||||||
Response response = client.put(path, Constants.MIMETYPE_BINARY, body);
|
Response response = client.put(path, Constants.MIMETYPE_BINARY, body);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
|
|
||||||
response = client.get(path, Constants.MIMETYPE_BINARY);
|
response = client.get(path, Constants.MIMETYPE_BINARY);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_BINARY, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_BINARY, response.getHeader("content-type"));
|
||||||
assertTrue(Bytes.equals(response.getBody(), body));
|
assertTrue(Bytes.equals(response.getBody(), body));
|
||||||
boolean foundTimestampHeader = false;
|
boolean foundTimestampHeader = false;
|
||||||
|
@ -270,7 +270,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
assertTrue(foundTimestampHeader);
|
assertTrue(foundTimestampHeader);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_3);
|
response = deleteRow(TABLE, ROW_3);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -278,13 +278,13 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
|
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
|
||||||
Response response = client.put(path, Constants.MIMETYPE_BINARY,
|
Response response = client.put(path, Constants.MIMETYPE_BINARY,
|
||||||
Bytes.toBytes(VALUE_4));
|
Bytes.toBytes(VALUE_4));
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
response = client.get(path, Constants.MIMETYPE_JSON);
|
response = client.get(path, Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
||||||
response = deleteRow(TABLE, ROW_4);
|
response = deleteRow(TABLE, ROW_4);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -302,10 +302,10 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
String jsonString = jsonMapper.writeValueAsString(cellSetModel);
|
String jsonString = jsonMapper.writeValueAsString(cellSetModel);
|
||||||
Response response = client.put(path, Constants.MIMETYPE_JSON,
|
Response response = client.put(path, Constants.MIMETYPE_JSON,
|
||||||
Bytes.toBytes(jsonString));
|
Bytes.toBytes(jsonString));
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
response = client.get(path, Constants.MIMETYPE_JSON);
|
response = client.get(path, Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = jsonMapper.readValue(response.getBody(), CellSetModel.class);
|
CellSetModel cellSet = jsonMapper.readValue(response.getBody(), CellSetModel.class);
|
||||||
assertTrue(cellSet.getRows().size() == 1);
|
assertTrue(cellSet.getRows().size() == 1);
|
||||||
|
@ -314,7 +314,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
assertEquals(VALUE_2 , Bytes.toString(cell.getValue()));
|
assertEquals(VALUE_2 , Bytes.toString(cell.getValue()));
|
||||||
assertEquals(2L , cell.getTimestamp());
|
assertEquals(2L , cell.getTimestamp());
|
||||||
response = deleteRow(TABLE, ROW_4);
|
response = deleteRow(TABLE, ROW_4);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -330,7 +330,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
Response response;
|
Response response;
|
||||||
response = putValueXML(path.toString(), TABLE, urlKey, COLUMN_1,
|
response = putValueXML(path.toString(), TABLE, urlKey, COLUMN_1,
|
||||||
VALUE_1);
|
VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(path.toString(), TABLE, urlKey, COLUMN_1, VALUE_1);
|
checkValueXML(path.toString(), TABLE, urlKey, COLUMN_1, VALUE_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,13 +340,10 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
final String badPath = "/" + TABLE + "/" + ROW_1 + "/" + "BAD";
|
final String badPath = "/" + TABLE + "/" + ROW_1 + "/" + "BAD";
|
||||||
Response response = client.post(goodPath, Constants.MIMETYPE_BINARY,
|
Response response = client.post(goodPath, Constants.MIMETYPE_BINARY,
|
||||||
Bytes.toBytes(VALUE_1));
|
Bytes.toBytes(VALUE_1));
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(client.get(goodPath, Constants.MIMETYPE_BINARY).getCode(),
|
assertEquals(200, client.get(goodPath, Constants.MIMETYPE_BINARY).getCode());
|
||||||
200);
|
assertEquals(404, client.get(badPath, Constants.MIMETYPE_BINARY).getCode());
|
||||||
assertEquals(client.get(badPath, Constants.MIMETYPE_BINARY).getCode(),
|
assertEquals(200, client.get(goodPath, Constants.MIMETYPE_BINARY).getCode());
|
||||||
404);
|
|
||||||
assertEquals(client.get(goodPath, Constants.MIMETYPE_BINARY).getCode(),
|
|
||||||
200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -374,7 +371,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// make sure the fake row was not actually created
|
// make sure the fake row was not actually created
|
||||||
response = client.get(path, Constants.MIMETYPE_XML);
|
response = client.get(path, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// check that all of the values were created
|
// check that all of the values were created
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
|
@ -383,9 +380,9 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
checkValueXML(TABLE, ROW_2, COLUMN_2, VALUE_4);
|
checkValueXML(TABLE, ROW_2, COLUMN_2, VALUE_4);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = deleteRow(TABLE, ROW_2);
|
response = deleteRow(TABLE, ROW_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -411,7 +408,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// make sure the fake row was not actually created
|
// make sure the fake row was not actually created
|
||||||
response = client.get(path, Constants.MIMETYPE_PROTOBUF);
|
response = client.get(path, Constants.MIMETYPE_PROTOBUF);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// check that all of the values were created
|
// check that all of the values were created
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
|
@ -420,9 +417,9 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
checkValuePB(TABLE, ROW_2, COLUMN_2, VALUE_4);
|
checkValuePB(TABLE, ROW_2, COLUMN_2, VALUE_4);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = deleteRow(TABLE, ROW_2);
|
response = deleteRow(TABLE, ROW_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -467,7 +464,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
Response response = client.put(path, Constants.MIMETYPE_XML,
|
Response response = client.put(path, Constants.MIMETYPE_XML,
|
||||||
Bytes.toBytes(writer.toString()));
|
Bytes.toBytes(writer.toString()));
|
||||||
assertEquals(response.getCode(), 400);
|
assertEquals(400, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -485,7 +482,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
Response response = client.put(path, Constants.MIMETYPE_XML,
|
Response response = client.put(path, Constants.MIMETYPE_XML,
|
||||||
Bytes.toBytes(writer.toString()));
|
Bytes.toBytes(writer.toString()));
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -513,7 +510,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// make sure the fake row was not actually created
|
// make sure the fake row was not actually created
|
||||||
response = client.get(path, Constants.MIMETYPE_JSON);
|
response = client.get(path, Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// check that all of the values were created
|
// check that all of the values were created
|
||||||
checkValueJSON(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValueJSON(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
|
@ -522,9 +519,9 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
checkValueJSON(TABLE, ROW_2, COLUMN_2, VALUE_4);
|
checkValueJSON(TABLE, ROW_2, COLUMN_2, VALUE_4);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = deleteRow(TABLE, ROW_2);
|
response = deleteRow(TABLE, ROW_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -532,13 +529,13 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
|
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
|
||||||
Response response = client.put(path, Constants.MIMETYPE_BINARY,
|
Response response = client.put(path, Constants.MIMETYPE_BINARY,
|
||||||
Bytes.toBytes(VALUE_4));
|
Bytes.toBytes(VALUE_4));
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
response = client.get(path, Constants.MIMETYPE_JSON);
|
response = client.get(path, Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
||||||
response = deleteRow(TABLE, ROW_4);
|
response = deleteRow(TABLE, ROW_4);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
|
|
||||||
UserProvider userProvider = UserProvider.instantiate(conf);
|
UserProvider userProvider = UserProvider.instantiate(conf);
|
||||||
METRICS_ASSERT.assertCounterGt("requests", 2l,
|
METRICS_ASSERT.assertCounterGt("requests", 2l,
|
||||||
|
@ -571,14 +568,14 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// make sure the fake row was not actually created
|
// make sure the fake row was not actually created
|
||||||
response = client.get(path, Constants.MIMETYPE_XML);
|
response = client.get(path, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// Try getting all the column values at once.
|
// Try getting all the column values at once.
|
||||||
path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "," + COLUMN_2 + "," + COLUMN_3;
|
path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "," + COLUMN_2 + "," + COLUMN_3;
|
||||||
response = client.get(path, Constants.MIMETYPE_XML);
|
response = client.get(path, Constants.MIMETYPE_XML);
|
||||||
assertEquals(200, response.getCode());
|
assertEquals(200, response.getCode());
|
||||||
CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response
|
CellSetModel cellSet =
|
||||||
.getBody()));
|
(CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
assertTrue(cellSet.getRows().size() == 1);
|
assertTrue(cellSet.getRows().size() == 1);
|
||||||
assertTrue(cellSet.getRows().get(0).getCells().size() == 3);
|
assertTrue(cellSet.getRows().get(0).getCells().size() == 3);
|
||||||
List<CellModel> cells = cellSet.getRows().get(0).getCells();
|
List<CellModel> cells = cellSet.getRows().get(0).getCells();
|
||||||
|
@ -587,7 +584,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
assertTrue(containsCellModel(cells, COLUMN_2, VALUE_2));
|
assertTrue(containsCellModel(cells, COLUMN_2, VALUE_2));
|
||||||
assertTrue(containsCellModel(cells, COLUMN_3, VALUE_2));
|
assertTrue(containsCellModel(cells, COLUMN_3, VALUE_2));
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsCellModel(List<CellModel> cells, String column, String value) {
|
private boolean containsCellModel(List<CellModel> cells, String column, String value) {
|
||||||
|
@ -627,7 +624,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// make sure the fake row was not actually created
|
// make sure the fake row was not actually created
|
||||||
response = client.get(path, Constants.MIMETYPE_XML);
|
response = client.get(path, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// check that all of the values were created
|
// check that all of the values were created
|
||||||
StringBuilder query = new StringBuilder();
|
StringBuilder query = new StringBuilder();
|
||||||
|
@ -636,16 +633,16 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
query.append('/');
|
query.append('/');
|
||||||
query.append("testrow*");
|
query.append("testrow*");
|
||||||
response = client.get(query.toString(), Constants.MIMETYPE_XML);
|
response = client.get(query.toString(), Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel)
|
CellSetModel cellSet = (CellSetModel)
|
||||||
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
assertTrue(cellSet.getRows().size() == 2);
|
assertTrue(cellSet.getRows().size() == 2);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = deleteRow(TABLE, ROW_2);
|
response = deleteRow(TABLE, ROW_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -673,7 +670,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
|
|
||||||
// make sure the fake row was not actually created
|
// make sure the fake row was not actually created
|
||||||
response = client.get(path, Constants.MIMETYPE_XML);
|
response = client.get(path, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
// check that all of the values were created
|
// check that all of the values were created
|
||||||
StringBuilder query = new StringBuilder();
|
StringBuilder query = new StringBuilder();
|
||||||
|
@ -684,7 +681,7 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
query.append('/');
|
query.append('/');
|
||||||
query.append(COLUMN_1);
|
query.append(COLUMN_1);
|
||||||
response = client.get(query.toString(), Constants.MIMETYPE_XML);
|
response = client.get(query.toString(), Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel)
|
CellSetModel cellSet = (CellSetModel)
|
||||||
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
|
@ -695,114 +692,114 @@ public class TestGetAndPutResource extends RowResourceBase {
|
||||||
assertEquals(COLUMN_1, Bytes.toString(row.getCells().get(0).getColumn()));
|
assertEquals(COLUMN_1, Bytes.toString(row.getCells().get(0).getColumn()));
|
||||||
}
|
}
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = deleteRow(TABLE, ROW_2);
|
response = deleteRow(TABLE, ROW_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppendXML() throws IOException, JAXBException {
|
public void testAppendXML() throws IOException, JAXBException {
|
||||||
Response response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
Response response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
//append cell
|
//append cell
|
||||||
response = appendValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = appendValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
response = appendValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
response = appendValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2);
|
checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppendPB() throws IOException, JAXBException {
|
public void testAppendPB() throws IOException, JAXBException {
|
||||||
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
//append cell
|
//append cell
|
||||||
response = appendValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = appendValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
response = appendValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
response = appendValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2);
|
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppendJSON() throws IOException, JAXBException {
|
public void testAppendJSON() throws IOException, JAXBException {
|
||||||
Response response = getValueJson(TABLE, ROW_1, COLUMN_1);
|
Response response = getValueJson(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
//append cell
|
//append cell
|
||||||
response = appendValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
response = appendValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
putValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
putValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1);
|
||||||
response = appendValueJson(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
response = appendValueJson(TABLE, ROW_1, COLUMN_1, VALUE_2);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
putValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2);
|
putValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2);
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncrementXML() throws IOException, JAXBException {
|
public void testIncrementXML() throws IOException, JAXBException {
|
||||||
Response response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
Response response = getValueXML(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
//append single cell
|
//append single cell
|
||||||
response = incrementValueXML(TABLE, ROW_1, COLUMN_1, VALUE_5);
|
response = incrementValueXML(TABLE, ROW_1, COLUMN_1, VALUE_5);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkIncrementValueXML(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5));
|
checkIncrementValueXML(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5));
|
||||||
response = incrementValueXML(TABLE, ROW_1, COLUMN_1, VALUE_6);
|
response = incrementValueXML(TABLE, ROW_1, COLUMN_1, VALUE_6);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkIncrementValueXML(TABLE, ROW_1, COLUMN_1,
|
checkIncrementValueXML(TABLE, ROW_1, COLUMN_1,
|
||||||
Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6));
|
Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6));
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncrementPB() throws IOException, JAXBException {
|
public void testIncrementPB() throws IOException, JAXBException {
|
||||||
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
//append cell
|
//append cell
|
||||||
response = incrementValuePB(TABLE, ROW_1, COLUMN_1, VALUE_5);
|
response = incrementValuePB(TABLE, ROW_1, COLUMN_1, VALUE_5);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkIncrementValuePB(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5));
|
checkIncrementValuePB(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5));
|
||||||
response = incrementValuePB(TABLE, ROW_1, COLUMN_1, VALUE_6);
|
response = incrementValuePB(TABLE, ROW_1, COLUMN_1, VALUE_6);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkIncrementValuePB(TABLE, ROW_1, COLUMN_1,
|
checkIncrementValuePB(TABLE, ROW_1, COLUMN_1,
|
||||||
Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6));
|
Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6));
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncrementJSON() throws IOException, JAXBException {
|
public void testIncrementJSON() throws IOException, JAXBException {
|
||||||
Response response = getValueJson(TABLE, ROW_1, COLUMN_1);
|
Response response = getValueJson(TABLE, ROW_1, COLUMN_1);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
|
|
||||||
//append cell
|
//append cell
|
||||||
response = incrementValueJson(TABLE, ROW_1, COLUMN_1, VALUE_5);
|
response = incrementValueJson(TABLE, ROW_1, COLUMN_1, VALUE_5);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkIncrementValueJSON(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5));
|
checkIncrementValueJSON(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5));
|
||||||
response = incrementValueJson(TABLE, ROW_1, COLUMN_1, VALUE_6);
|
response = incrementValueJson(TABLE, ROW_1, COLUMN_1, VALUE_6);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
checkIncrementValueJSON(TABLE, ROW_1, COLUMN_1,
|
checkIncrementValueJSON(TABLE, ROW_1, COLUMN_1,
|
||||||
Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6));
|
Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6));
|
||||||
|
|
||||||
response = deleteRow(TABLE, ROW_1);
|
response = deleteRow(TABLE, ROW_1);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class TestGzipFilter {
|
||||||
headers[0] = new BasicHeader("Content-Type", Constants.MIMETYPE_BINARY);
|
headers[0] = new BasicHeader("Content-Type", Constants.MIMETYPE_BINARY);
|
||||||
headers[1] = new BasicHeader("Content-Encoding", "gzip");
|
headers[1] = new BasicHeader("Content-Encoding", "gzip");
|
||||||
Response response = client.put(path, headers, value_1_gzip);
|
Response response = client.put(path, headers, value_1_gzip);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
|
|
||||||
Table table = TEST_UTIL.getConnection().getTable(TABLE);
|
Table table = TEST_UTIL.getConnection().getTable(TABLE);
|
||||||
Get get = new Get(Bytes.toBytes(ROW_1));
|
Get get = new Get(Bytes.toBytes(ROW_1));
|
||||||
|
@ -114,7 +114,7 @@ public class TestGzipFilter {
|
||||||
headers[0] = new BasicHeader("Accept", Constants.MIMETYPE_BINARY);
|
headers[0] = new BasicHeader("Accept", Constants.MIMETYPE_BINARY);
|
||||||
headers[1] = new BasicHeader("Accept-Encoding", "gzip");
|
headers[1] = new BasicHeader("Accept-Encoding", "gzip");
|
||||||
response = client.get(path, headers);
|
response = client.get(path, headers);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(response.getBody());
|
ByteArrayInputStream bis = new ByteArrayInputStream(response.getBody());
|
||||||
GZIPInputStream is = new GZIPInputStream(bis);
|
GZIPInputStream is = new GZIPInputStream(bis);
|
||||||
value = new byte[VALUE_1.length];
|
value = new byte[VALUE_1.length];
|
||||||
|
@ -131,15 +131,14 @@ public class TestGzipFilter {
|
||||||
headers[0] = new BasicHeader("Content-Type", Constants.MIMETYPE_XML);
|
headers[0] = new BasicHeader("Content-Type", Constants.MIMETYPE_XML);
|
||||||
headers[1] = new BasicHeader("Accept", Constants.MIMETYPE_JSON);
|
headers[1] = new BasicHeader("Accept", Constants.MIMETYPE_JSON);
|
||||||
headers[2] = new BasicHeader("Accept-Encoding", "gzip");
|
headers[2] = new BasicHeader("Accept-Encoding", "gzip");
|
||||||
Response response = client.post("/" + TABLE + "/scanner", headers,
|
Response response = client.post("/" + TABLE + "/scanner", headers, Bytes.toBytes("<Scanner/>"));
|
||||||
"<Scanner/>".getBytes());
|
assertEquals(201, response.getCode());
|
||||||
assertEquals(response.getCode(), 201);
|
|
||||||
String scannerUrl = response.getLocation();
|
String scannerUrl = response.getLocation();
|
||||||
assertNotNull(scannerUrl);
|
assertNotNull(scannerUrl);
|
||||||
response = client.get(scannerUrl);
|
response = client.get(scannerUrl);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
response = client.get(scannerUrl);
|
response = client.get(scannerUrl);
|
||||||
assertEquals(response.getCode(), 204);
|
assertEquals(204, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,26 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.rest;
|
package org.apache.hadoop.hbase.rest;
|
||||||
|
|
||||||
import org.apache.http.Header;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.apache.http.message.BasicHeader;
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Marshaller;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.*;
|
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
|
||||||
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.client.Admin;
|
import org.apache.hadoop.hbase.client.Admin;
|
||||||
import org.apache.hadoop.hbase.rest.client.Client;
|
import org.apache.hadoop.hbase.rest.client.Client;
|
||||||
import org.apache.hadoop.hbase.rest.client.Cluster;
|
import org.apache.hadoop.hbase.rest.client.Cluster;
|
||||||
|
@ -32,6 +48,8 @@ import org.apache.hadoop.hbase.rest.model.RowModel;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
import org.apache.http.Header;
|
||||||
|
import org.apache.http.message.BasicHeader;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -39,19 +57,6 @@ import org.junit.experimental.categories.Category;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.xml.bind.JAXBContext;
|
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
import javax.xml.bind.Marshaller;
|
|
||||||
import javax.xml.bind.Unmarshaller;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
@Category({RestTests.class, MediumTests.class})
|
@Category({RestTests.class, MediumTests.class})
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public class TestMultiRowResource {
|
public class TestMultiRowResource {
|
||||||
|
@ -144,7 +149,7 @@ public class TestMultiRowResource {
|
||||||
|
|
||||||
|
|
||||||
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
|
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
||||||
|
|
||||||
client.delete(row_5_url, extraHdr);
|
client.delete(row_5_url, extraHdr);
|
||||||
|
@ -171,7 +176,7 @@ public class TestMultiRowResource {
|
||||||
|
|
||||||
|
|
||||||
Response response = client.get(path.toString(), Constants.MIMETYPE_XML);
|
Response response = client.get(path.toString(), Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
|
|
||||||
client.delete(row_5_url, extraHdr);
|
client.delete(row_5_url, extraHdr);
|
||||||
|
@ -198,7 +203,7 @@ public class TestMultiRowResource {
|
||||||
client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2), extraHdr);
|
client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2), extraHdr);
|
||||||
|
|
||||||
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
|
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
ObjectMapper mapper =
|
ObjectMapper mapper =
|
||||||
new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
|
new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
|
||||||
CellSetModel cellSet = mapper.readValue(response.getBody(), CellSetModel.class);
|
CellSetModel cellSet = mapper.readValue(response.getBody(), CellSetModel.class);
|
||||||
|
@ -227,7 +232,7 @@ public class TestMultiRowResource {
|
||||||
|
|
||||||
client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1), extraHdr);
|
client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1), extraHdr);
|
||||||
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
|
Response response = client.get(path.toString(), Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class,
|
ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class,
|
||||||
MediaType.APPLICATION_JSON_TYPE);
|
MediaType.APPLICATION_JSON_TYPE);
|
||||||
CellSetModel cellSet = (CellSetModel) mapper.readValue(response.getBody(), CellSetModel.class);
|
CellSetModel cellSet = (CellSetModel) mapper.readValue(response.getBody(), CellSetModel.class);
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class TestScannerResource {
|
||||||
model.setBatch(100);
|
model.setBatch(100);
|
||||||
Response response = client.put("/" + TABLE + "/scanner",
|
Response response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -161,7 +161,7 @@ public class TestScannerResource {
|
||||||
}
|
}
|
||||||
// delete the scanner
|
// delete the scanner
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ public class TestScannerResource {
|
||||||
conf.set("hbase.rest.readonly", "true");
|
conf.set("hbase.rest.readonly", "true");
|
||||||
Response response = client.put("/" + TABLE + "/scanner",
|
Response response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_XML, body);
|
Constants.MIMETYPE_XML, body);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNull(scannerURI);
|
assertNull(scannerURI);
|
||||||
|
|
||||||
|
@ -225,28 +225,28 @@ public class TestScannerResource {
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML,
|
response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML,
|
||||||
body);
|
body);
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
scannerURI = response.getLocation();
|
scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
|
|
||||||
// get a cell set
|
// get a cell set
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel)
|
CellSetModel cellSet = (CellSetModel)
|
||||||
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
// confirm batch size conformance
|
// confirm batch size conformance
|
||||||
assertEquals(countCellSet(cellSet), BATCH_SIZE);
|
assertEquals(BATCH_SIZE, countCellSet(cellSet));
|
||||||
|
|
||||||
// test delete scanner operation is forbidden in read-only mode
|
// test delete scanner operation is forbidden in read-only mode
|
||||||
conf.set("hbase.rest.readonly", "true");
|
conf.set("hbase.rest.readonly", "true");
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
|
|
||||||
// recall previous delete scanner operation with read-only off
|
// recall previous delete scanner operation with read-only off
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -261,7 +261,7 @@ public class TestScannerResource {
|
||||||
conf.set("hbase.rest.readonly", "true");
|
conf.set("hbase.rest.readonly", "true");
|
||||||
Response response = client.put("/" + TABLE + "/scanner",
|
Response response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNull(scannerURI);
|
assertNull(scannerURI);
|
||||||
|
|
||||||
|
@ -269,28 +269,28 @@ public class TestScannerResource {
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
response = client.put("/" + TABLE + "/scanner",
|
response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
scannerURI = response.getLocation();
|
scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
|
|
||||||
// get a cell set
|
// get a cell set
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF);
|
response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = new CellSetModel();
|
CellSetModel cellSet = new CellSetModel();
|
||||||
cellSet.getObjectFromMessage(response.getBody());
|
cellSet.getObjectFromMessage(response.getBody());
|
||||||
// confirm batch size conformance
|
// confirm batch size conformance
|
||||||
assertEquals(countCellSet(cellSet), BATCH_SIZE);
|
assertEquals(BATCH_SIZE, countCellSet(cellSet));
|
||||||
|
|
||||||
// test delete scanner operation is forbidden in read-only mode
|
// test delete scanner operation is forbidden in read-only mode
|
||||||
conf.set("hbase.rest.readonly", "true");
|
conf.set("hbase.rest.readonly", "true");
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
|
|
||||||
// recall previous delete scanner operation with read-only off
|
// recall previous delete scanner operation with read-only off
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -304,7 +304,7 @@ public class TestScannerResource {
|
||||||
conf.set("hbase.rest.readonly", "true");
|
conf.set("hbase.rest.readonly", "true");
|
||||||
Response response = client.put("/" + TABLE + "/scanner",
|
Response response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNull(scannerURI);
|
assertNull(scannerURI);
|
||||||
|
|
||||||
|
@ -312,13 +312,13 @@ public class TestScannerResource {
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
response = client.put("/" + TABLE + "/scanner",
|
response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
scannerURI = response.getLocation();
|
scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
|
|
||||||
// get a cell
|
// get a cell
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_BINARY);
|
response = client.get(scannerURI, Constants.MIMETYPE_BINARY);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_BINARY, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_BINARY, response.getHeader("content-type"));
|
||||||
// verify that data was returned
|
// verify that data was returned
|
||||||
assertTrue(response.getBody().length > 0);
|
assertTrue(response.getBody().length > 0);
|
||||||
|
@ -341,23 +341,23 @@ public class TestScannerResource {
|
||||||
// test delete scanner operation is forbidden in read-only mode
|
// test delete scanner operation is forbidden in read-only mode
|
||||||
conf.set("hbase.rest.readonly", "true");
|
conf.set("hbase.rest.readonly", "true");
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
|
|
||||||
// recall previous delete scanner operation with read-only off
|
// recall previous delete scanner operation with read-only off
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFullTableScan() throws IOException {
|
public void testFullTableScan() throws IOException {
|
||||||
ScannerModel model = new ScannerModel();
|
ScannerModel model = new ScannerModel();
|
||||||
model.addColumn(Bytes.toBytes(COLUMN_1));
|
model.addColumn(Bytes.toBytes(COLUMN_1));
|
||||||
assertEquals(fullTableScan(model), expectedRows1);
|
assertEquals(expectedRows1, fullTableScan(model));
|
||||||
|
|
||||||
model = new ScannerModel();
|
model = new ScannerModel();
|
||||||
model.addColumn(Bytes.toBytes(COLUMN_2));
|
model.addColumn(Bytes.toBytes(COLUMN_2));
|
||||||
assertEquals(fullTableScan(model), expectedRows2);
|
assertEquals(expectedRows2, fullTableScan(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -371,7 +371,7 @@ public class TestScannerResource {
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(404, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// performs table scan during which the underlying table is disabled
|
// performs table scan during which the underlying table is disabled
|
||||||
|
@ -383,7 +383,7 @@ public class TestScannerResource {
|
||||||
model.setCaching(1);
|
model.setCaching(1);
|
||||||
Response response = client.put("/" + TABLE_TO_BE_DISABLED + "/scanner",
|
Response response = client.put("/" + TABLE_TO_BE_DISABLED + "/scanner",
|
||||||
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput());
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
TEST_UTIL.getAdmin().disableTable(TABLE_TO_BE_DISABLED);
|
TEST_UTIL.getAdmin().disableTable(TABLE_TO_BE_DISABLED);
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.apache.hadoop.hbase.client.Put;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.client.Table;
|
import org.apache.hadoop.hbase.client.Table;
|
||||||
import org.apache.hadoop.hbase.filter.BinaryComparator;
|
import org.apache.hadoop.hbase.filter.BinaryComparator;
|
||||||
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
|
|
||||||
import org.apache.hadoop.hbase.filter.Filter;
|
import org.apache.hadoop.hbase.filter.Filter;
|
||||||
import org.apache.hadoop.hbase.filter.FilterList;
|
import org.apache.hadoop.hbase.filter.FilterList;
|
||||||
import org.apache.hadoop.hbase.filter.FilterList.Operator;
|
import org.apache.hadoop.hbase.filter.FilterList.Operator;
|
||||||
|
@ -122,8 +121,8 @@ public class TestScannersWithFilters {
|
||||||
private static JAXBContext context;
|
private static JAXBContext context;
|
||||||
private static Marshaller marshaller;
|
private static Marshaller marshaller;
|
||||||
private static Unmarshaller unmarshaller;
|
private static Unmarshaller unmarshaller;
|
||||||
private static long numRows = ROWS_ONE.length + ROWS_TWO.length;
|
private static long numRows = (long) ROWS_ONE.length + ROWS_TWO.length;
|
||||||
private static long colsPerRow = FAMILIES.length * QUALIFIERS_ONE.length;
|
private static long colsPerRow = (long) FAMILIES.length * QUALIFIERS_ONE.length;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
@ -230,13 +229,13 @@ public class TestScannersWithFilters {
|
||||||
byte[] body = Bytes.toBytes(writer.toString());
|
byte[] body = Bytes.toBytes(writer.toString());
|
||||||
Response response = client.put("/" + TABLE + "/scanner",
|
Response response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_XML, body);
|
Constants.MIMETYPE_XML, body);
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
|
|
||||||
// get a cell set
|
// get a cell set
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cells = (CellSetModel)
|
CellSetModel cells = (CellSetModel)
|
||||||
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
|
@ -252,7 +251,7 @@ public class TestScannersWithFilters {
|
||||||
|
|
||||||
// delete the scanner
|
// delete the scanner
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void verifyScanFull(Scan s, KeyValue [] kvs)
|
private static void verifyScanFull(Scan s, KeyValue [] kvs)
|
||||||
|
@ -265,20 +264,20 @@ public class TestScannersWithFilters {
|
||||||
byte[] body = Bytes.toBytes(writer.toString());
|
byte[] body = Bytes.toBytes(writer.toString());
|
||||||
Response response = client.put("/" + TABLE + "/scanner",
|
Response response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_XML, body);
|
Constants.MIMETYPE_XML, body);
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
|
|
||||||
// get a cell set
|
// get a cell set
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel)
|
CellSetModel cellSet = (CellSetModel)
|
||||||
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
|
|
||||||
// delete the scanner
|
// delete the scanner
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
@ -319,20 +318,20 @@ public class TestScannersWithFilters {
|
||||||
byte[] body = Bytes.toBytes(writer.toString());
|
byte[] body = Bytes.toBytes(writer.toString());
|
||||||
Response response = client.put("/" + TABLE + "/scanner",
|
Response response = client.put("/" + TABLE + "/scanner",
|
||||||
Constants.MIMETYPE_XML, body);
|
Constants.MIMETYPE_XML, body);
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
|
|
||||||
// get a cell set
|
// get a cell set
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel)
|
CellSetModel cellSet = (CellSetModel)
|
||||||
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||||
|
|
||||||
// delete the scanner
|
// delete the scanner
|
||||||
response = client.delete(scannerURI);
|
response = client.delete(scannerURI);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
|
|
||||||
Iterator<RowModel> i = cellSet.getRows().iterator();
|
Iterator<RowModel> i = cellSet.getRows().iterator();
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
|
@ -17,11 +17,27 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.rest;
|
package org.apache.hadoop.hbase.rest;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.security.PrivilegedExceptionAction;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Marshaller;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.client.Admin;
|
import org.apache.hadoop.hbase.client.Admin;
|
||||||
import org.apache.hadoop.hbase.client.Connection;
|
import org.apache.hadoop.hbase.client.Connection;
|
||||||
|
@ -53,21 +69,6 @@ import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
import javax.xml.bind.Marshaller;
|
|
||||||
import javax.xml.bind.Unmarshaller;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
@Category({RestTests.class, MediumTests.class})
|
@Category({RestTests.class, MediumTests.class})
|
||||||
public class TestScannersWithLabels {
|
public class TestScannersWithLabels {
|
||||||
private static final TableName TABLE = TableName.valueOf("TestScannersWithLabels");
|
private static final TableName TABLE = TableName.valueOf("TestScannersWithLabels");
|
||||||
|
@ -163,6 +164,7 @@ public class TestScannersWithLabels {
|
||||||
|
|
||||||
private static void createLabels() throws IOException, InterruptedException {
|
private static void createLabels() throws IOException, InterruptedException {
|
||||||
PrivilegedExceptionAction<VisibilityLabelsResponse> action = new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
|
PrivilegedExceptionAction<VisibilityLabelsResponse> action = new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
|
||||||
|
@Override
|
||||||
public VisibilityLabelsResponse run() throws Exception {
|
public VisibilityLabelsResponse run() throws Exception {
|
||||||
String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
|
String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
|
||||||
try (Connection conn = ConnectionFactory.createConnection(conf)) {
|
try (Connection conn = ConnectionFactory.createConnection(conf)) {
|
||||||
|
@ -197,14 +199,14 @@ public class TestScannersWithLabels {
|
||||||
// recall previous put operation with read-only off
|
// recall previous put operation with read-only off
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
|
Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
|
|
||||||
// get a cell set
|
// get a cell set
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
||||||
// Respond with 204 as there are no cells to be retrieved
|
// Respond with 204 as there are no cells to be retrieved
|
||||||
assertEquals(response.getCode(), 204);
|
assertEquals(204, response.getCode());
|
||||||
// With no content in the payload, the 'Content-Type' header is not echo back
|
// With no content in the payload, the 'Content-Type' header is not echo back
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,18 +224,18 @@ public class TestScannersWithLabels {
|
||||||
// recall previous put operation with read-only off
|
// recall previous put operation with read-only off
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
|
Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
|
||||||
assertEquals(response.getCode(), 201);
|
assertEquals(201, response.getCode());
|
||||||
String scannerURI = response.getLocation();
|
String scannerURI = response.getLocation();
|
||||||
assertNotNull(scannerURI);
|
assertNotNull(scannerURI);
|
||||||
|
|
||||||
// get a cell set
|
// get a cell set
|
||||||
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
||||||
// Respond with 204 as there are no cells to be retrieved
|
// Respond with 204 as there are no cells to be retrieved
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response
|
CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response
|
||||||
.getBody()));
|
.getBody()));
|
||||||
assertEquals(countCellSet(cellSet), 5);
|
assertEquals(5, countCellSet(cellSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.rest;
|
package org.apache.hadoop.hbase.rest;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
@ -26,11 +30,8 @@ import java.util.Collection;
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
|
|
||||||
import org.apache.http.Header;
|
|
||||||
import org.apache.http.message.BasicHeader;
|
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.client.Admin;
|
import org.apache.hadoop.hbase.client.Admin;
|
||||||
|
@ -43,9 +44,8 @@ import org.apache.hadoop.hbase.rest.model.TestTableSchemaModel;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
import org.apache.http.Header;
|
||||||
import static org.junit.Assert.*;
|
import org.apache.http.message.BasicHeader;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -220,11 +220,11 @@ public class TestSchemaResource {
|
||||||
response = client.put(schemaPath, Constants.MIMETYPE_PROTOBUF,
|
response = client.put(schemaPath, Constants.MIMETYPE_PROTOBUF,
|
||||||
model.createProtobufOutput(), extraHdr);
|
model.createProtobufOutput(), extraHdr);
|
||||||
assertNotNull(extraHdr);
|
assertNotNull(extraHdr);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
|
|
||||||
// retrieve the schema and validate it
|
// retrieve the schema and validate it
|
||||||
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF);
|
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
||||||
model = new TableSchemaModel();
|
model = new TableSchemaModel();
|
||||||
model.getObjectFromMessage(response.getBody());
|
model.getObjectFromMessage(response.getBody());
|
||||||
|
@ -232,7 +232,7 @@ public class TestSchemaResource {
|
||||||
|
|
||||||
// retrieve the schema and validate it with alternate pbuf type
|
// retrieve the schema and validate it with alternate pbuf type
|
||||||
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF_IETF);
|
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF_IETF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
|
||||||
model = new TableSchemaModel();
|
model = new TableSchemaModel();
|
||||||
model.getObjectFromMessage(response.getBody());
|
model.getObjectFromMessage(response.getBody());
|
||||||
|
@ -246,14 +246,14 @@ public class TestSchemaResource {
|
||||||
|
|
||||||
// test delete schema operation is forbidden in read-only mode
|
// test delete schema operation is forbidden in read-only mode
|
||||||
response = client.delete(schemaPath, extraHdr);
|
response = client.delete(schemaPath, extraHdr);
|
||||||
assertEquals(response.getCode(), 403);
|
assertEquals(403, response.getCode());
|
||||||
|
|
||||||
// return read-only setting back to default
|
// return read-only setting back to default
|
||||||
conf.set("hbase.rest.readonly", "false");
|
conf.set("hbase.rest.readonly", "false");
|
||||||
|
|
||||||
// delete the table and make sure HBase concurs
|
// delete the table and make sure HBase concurs
|
||||||
response = client.delete(schemaPath, extraHdr);
|
response = client.delete(schemaPath, extraHdr);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertFalse(admin.tableExists(TableName.valueOf(TABLE2)));
|
assertFalse(admin.tableExists(TableName.valueOf(TABLE2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.rest;
|
package org.apache.hadoop.hbase.rest;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -35,9 +40,6 @@ import org.apache.hadoop.hbase.rest.model.StorageClusterStatusModel;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -108,7 +110,7 @@ public class TestStatusResource {
|
||||||
@Test
|
@Test
|
||||||
public void testGetClusterStatusXML() throws IOException, JAXBException {
|
public void testGetClusterStatusXML() throws IOException, JAXBException {
|
||||||
Response response = client.get("/status/cluster", Constants.MIMETYPE_XML);
|
Response response = client.get("/status/cluster", Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
StorageClusterStatusModel model = (StorageClusterStatusModel)
|
StorageClusterStatusModel model = (StorageClusterStatusModel)
|
||||||
context.createUnmarshaller().unmarshal(
|
context.createUnmarshaller().unmarshal(
|
||||||
|
@ -119,13 +121,13 @@ public class TestStatusResource {
|
||||||
@Test
|
@Test
|
||||||
public void testGetClusterStatusPB() throws IOException {
|
public void testGetClusterStatusPB() throws IOException {
|
||||||
Response response = client.get("/status/cluster", Constants.MIMETYPE_PROTOBUF);
|
Response response = client.get("/status/cluster", Constants.MIMETYPE_PROTOBUF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
||||||
StorageClusterStatusModel model = new StorageClusterStatusModel();
|
StorageClusterStatusModel model = new StorageClusterStatusModel();
|
||||||
model.getObjectFromMessage(response.getBody());
|
model.getObjectFromMessage(response.getBody());
|
||||||
validate(model);
|
validate(model);
|
||||||
response = client.get("/status/cluster", Constants.MIMETYPE_PROTOBUF_IETF);
|
response = client.get("/status/cluster", Constants.MIMETYPE_PROTOBUF_IETF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
|
||||||
model = new StorageClusterStatusModel();
|
model = new StorageClusterStatusModel();
|
||||||
model.getObjectFromMessage(response.getBody());
|
model.getObjectFromMessage(response.getBody());
|
||||||
|
|
|
@ -32,12 +32,12 @@ import java.util.List;
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.HRegionLocation;
|
import org.apache.hadoop.hbase.HRegionLocation;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.client.Admin;
|
import org.apache.hadoop.hbase.client.Admin;
|
||||||
|
@ -123,7 +123,7 @@ public class TestTableResource {
|
||||||
|
|
||||||
RegionLocator regionLocator = connection.getRegionLocator(TABLE);
|
RegionLocator regionLocator = connection.getRegionLocator(TABLE);
|
||||||
List<HRegionLocation> m = regionLocator.getAllRegionLocations();
|
List<HRegionLocation> m = regionLocator.getAllRegionLocations();
|
||||||
assertEquals(m.size(), 1);
|
assertEquals(1, m.size());
|
||||||
// tell the master to split the table
|
// tell the master to split the table
|
||||||
admin.split(TABLE);
|
admin.split(TABLE);
|
||||||
// give some time for the split to happen
|
// give some time for the split to happen
|
||||||
|
@ -142,7 +142,7 @@ public class TestTableResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
// should have two regions now
|
// should have two regions now
|
||||||
assertEquals(m.size(), 2);
|
assertEquals(2, m.size());
|
||||||
regionMap = m;
|
regionMap = m;
|
||||||
LOG.info("regions: " + regionMap);
|
LOG.info("regions: " + regionMap);
|
||||||
regionLocator.close();
|
regionLocator.close();
|
||||||
|
@ -202,14 +202,14 @@ public class TestTableResource {
|
||||||
@Test
|
@Test
|
||||||
public void testTableListText() throws IOException {
|
public void testTableListText() throws IOException {
|
||||||
Response response = client.get("/", Constants.MIMETYPE_TEXT);
|
Response response = client.get("/", Constants.MIMETYPE_TEXT);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_TEXT, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_TEXT, response.getHeader("content-type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTableListXML() throws IOException, JAXBException {
|
public void testTableListXML() throws IOException, JAXBException {
|
||||||
Response response = client.get("/", Constants.MIMETYPE_XML);
|
Response response = client.get("/", Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
TableListModel model = (TableListModel)
|
TableListModel model = (TableListModel)
|
||||||
context.createUnmarshaller()
|
context.createUnmarshaller()
|
||||||
|
@ -220,20 +220,20 @@ public class TestTableResource {
|
||||||
@Test
|
@Test
|
||||||
public void testTableListJSON() throws IOException {
|
public void testTableListJSON() throws IOException {
|
||||||
Response response = client.get("/", Constants.MIMETYPE_JSON);
|
Response response = client.get("/", Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTableListPB() throws IOException, JAXBException {
|
public void testTableListPB() throws IOException, JAXBException {
|
||||||
Response response = client.get("/", Constants.MIMETYPE_PROTOBUF);
|
Response response = client.get("/", Constants.MIMETYPE_PROTOBUF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
||||||
TableListModel model = new TableListModel();
|
TableListModel model = new TableListModel();
|
||||||
model.getObjectFromMessage(response.getBody());
|
model.getObjectFromMessage(response.getBody());
|
||||||
checkTableList(model);
|
checkTableList(model);
|
||||||
response = client.get("/", Constants.MIMETYPE_PROTOBUF_IETF);
|
response = client.get("/", Constants.MIMETYPE_PROTOBUF_IETF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
|
||||||
model = new TableListModel();
|
model = new TableListModel();
|
||||||
model.getObjectFromMessage(response.getBody());
|
model.getObjectFromMessage(response.getBody());
|
||||||
|
@ -243,14 +243,14 @@ public class TestTableResource {
|
||||||
@Test
|
@Test
|
||||||
public void testTableInfoText() throws IOException {
|
public void testTableInfoText() throws IOException {
|
||||||
Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_TEXT);
|
Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_TEXT);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_TEXT, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_TEXT, response.getHeader("content-type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTableInfoXML() throws IOException, JAXBException {
|
public void testTableInfoXML() throws IOException, JAXBException {
|
||||||
Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_XML);
|
Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
|
||||||
TableInfoModel model = (TableInfoModel)
|
TableInfoModel model = (TableInfoModel)
|
||||||
context.createUnmarshaller()
|
context.createUnmarshaller()
|
||||||
|
@ -261,20 +261,20 @@ public class TestTableResource {
|
||||||
@Test
|
@Test
|
||||||
public void testTableInfoJSON() throws IOException {
|
public void testTableInfoJSON() throws IOException {
|
||||||
Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_JSON);
|
Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_JSON);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTableInfoPB() throws IOException, JAXBException {
|
public void testTableInfoPB() throws IOException, JAXBException {
|
||||||
Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_PROTOBUF);
|
Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_PROTOBUF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type"));
|
||||||
TableInfoModel model = new TableInfoModel();
|
TableInfoModel model = new TableInfoModel();
|
||||||
model.getObjectFromMessage(response.getBody());
|
model.getObjectFromMessage(response.getBody());
|
||||||
checkTableInfo(model);
|
checkTableInfo(model);
|
||||||
response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_PROTOBUF_IETF);
|
response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_PROTOBUF_IETF);
|
||||||
assertEquals(response.getCode(), 200);
|
assertEquals(200, response.getCode());
|
||||||
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
|
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type"));
|
||||||
model = new TableInfoModel();
|
model = new TableInfoModel();
|
||||||
model.getObjectFromMessage(response.getBody());
|
model.getObjectFromMessage(response.getBody());
|
||||||
|
|
|
@ -22,12 +22,19 @@ import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonFactory;
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.core.JsonToken;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -70,12 +77,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonFactory;
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.core.JsonToken;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
|
||||||
|
|
||||||
@Category({RestTests.class, MediumTests.class})
|
@Category({RestTests.class, MediumTests.class})
|
||||||
public class TestTableScan {
|
public class TestTableScan {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TestTableScan.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TestTableScan.class);
|
||||||
|
@ -283,12 +284,14 @@ public class TestTableScan {
|
||||||
|
|
||||||
// install the callback on all ClientSideCellSetModel instances
|
// install the callback on all ClientSideCellSetModel instances
|
||||||
unmarshaller.setListener(new Unmarshaller.Listener() {
|
unmarshaller.setListener(new Unmarshaller.Listener() {
|
||||||
|
@Override
|
||||||
public void beforeUnmarshal(Object target, Object parent) {
|
public void beforeUnmarshal(Object target, Object parent) {
|
||||||
if (target instanceof ClientSideCellSetModel) {
|
if (target instanceof ClientSideCellSetModel) {
|
||||||
((ClientSideCellSetModel) target).setCellSetModelListener(listener);
|
((ClientSideCellSetModel) target).setCellSetModelListener(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void afterUnmarshal(Object target, Object parent) {
|
public void afterUnmarshal(Object target, Object parent) {
|
||||||
if (target instanceof ClientSideCellSetModel) {
|
if (target instanceof ClientSideCellSetModel) {
|
||||||
((ClientSideCellSetModel) target).setCellSetModelListener(null);
|
((ClientSideCellSetModel) target).setCellSetModelListener(null);
|
||||||
|
@ -460,7 +463,8 @@ public class TestTableScan {
|
||||||
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
|
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
|
||||||
int count = TestScannerResource.countCellSet(model);
|
int count = TestScannerResource.countCellSet(model);
|
||||||
assertEquals(1, count);
|
assertEquals(1, count);
|
||||||
assertEquals("aab", new String(model.getRows().get(0).getCells().get(0).getValue()));
|
assertEquals("aab",
|
||||||
|
new String(model.getRows().get(0).getCells().get(0).getValue(), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -478,7 +482,8 @@ public class TestTableScan {
|
||||||
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
|
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
|
||||||
int count = TestScannerResource.countCellSet(model);
|
int count = TestScannerResource.countCellSet(model);
|
||||||
assertEquals(1, count);
|
assertEquals(1, count);
|
||||||
assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue()));
|
assertEquals("abc",
|
||||||
|
new String(model.getRows().get(0).getCells().get(0).getValue(), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -496,7 +501,8 @@ public class TestTableScan {
|
||||||
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
|
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
|
||||||
int count = TestScannerResource.countCellSet(model);
|
int count = TestScannerResource.countCellSet(model);
|
||||||
assertEquals(1, count);
|
assertEquals(1, count);
|
||||||
assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue()));
|
assertEquals("abc",
|
||||||
|
new String(model.getRows().get(0).getCells().get(0).getValue(), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -515,7 +521,8 @@ public class TestTableScan {
|
||||||
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
|
CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream());
|
||||||
int count = TestScannerResource.countCellSet(model);
|
int count = TestScannerResource.countCellSet(model);
|
||||||
assertEquals(1, count);
|
assertEquals(1, count);
|
||||||
assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue()));
|
assertEquals("abc",
|
||||||
|
new String(model.getRows().get(0).getCells().get(0).getValue(), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -633,6 +640,7 @@ public class TestTableScan {
|
||||||
row = (l == null) ? null : new ArrayList<RowModel>() {
|
row = (l == null) ? null : new ArrayList<RowModel>() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean add(RowModel o) {
|
public boolean add(RowModel o) {
|
||||||
l.handleRowModel(ClientSideCellSetModel.this, o);
|
l.handleRowModel(ClientSideCellSetModel.this, o);
|
||||||
listenerInvoked = true;
|
listenerInvoked = true;
|
||||||
|
|
|
@ -18,6 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.rest;
|
package org.apache.hadoop.hbase.rest;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -34,17 +41,9 @@ import org.apache.hadoop.hbase.rest.model.VersionModel;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.glassfish.jersey.servlet.ServletContainer;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -79,7 +78,7 @@ public class TestVersionResource {
|
||||||
private static void validate(VersionModel model) {
|
private static void validate(VersionModel model) {
|
||||||
assertNotNull(model);
|
assertNotNull(model);
|
||||||
assertNotNull(model.getRESTVersion());
|
assertNotNull(model.getRESTVersion());
|
||||||
assertEquals(model.getRESTVersion(), RESTServlet.VERSION_STRING);
|
assertEquals(RESTServlet.VERSION_STRING, model.getRESTVersion());
|
||||||
String osVersion = model.getOSVersion();
|
String osVersion = model.getOSVersion();
|
||||||
assertNotNull(osVersion);
|
assertNotNull(osVersion);
|
||||||
assertTrue(osVersion.contains(System.getProperty("os.name")));
|
assertTrue(osVersion.contains(System.getProperty("os.name")));
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
import org.apache.hadoop.hbase.rest.Constants;
|
import org.apache.hadoop.hbase.rest.Constants;
|
||||||
import org.apache.hadoop.hbase.rest.model.StorageClusterVersionModel;
|
import org.apache.hadoop.hbase.rest.model.StorageClusterVersionModel;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
@ -48,7 +49,7 @@ public class TestXmlParsing {
|
||||||
+ "<ClusterVersion Version=\"2.0.0\"/>";
|
+ "<ClusterVersion Version=\"2.0.0\"/>";
|
||||||
Client client = mock(Client.class);
|
Client client = mock(Client.class);
|
||||||
RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null);
|
RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null);
|
||||||
Response resp = new Response(200, null, xml.getBytes());
|
Response resp = new Response(200, null, Bytes.toBytes(xml));
|
||||||
|
|
||||||
when(client.get("/version/cluster", Constants.MIMETYPE_XML)).thenReturn(resp);
|
when(client.get("/version/cluster", Constants.MIMETYPE_XML)).thenReturn(resp);
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ public class TestXmlParsing {
|
||||||
+ " <ClusterVersion>&xee;</ClusterVersion>";
|
+ " <ClusterVersion>&xee;</ClusterVersion>";
|
||||||
Client client = mock(Client.class);
|
Client client = mock(Client.class);
|
||||||
RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null);
|
RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null);
|
||||||
Response resp = new Response(200, null, externalEntitiesXml.getBytes());
|
Response resp = new Response(200, null, Bytes.toBytes(externalEntitiesXml));
|
||||||
|
|
||||||
when(client.get("/version/cluster", Constants.MIMETYPE_XML)).thenReturn(resp);
|
when(client.get("/version/cluster", Constants.MIMETYPE_XML)).thenReturn(resp);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
@ -48,6 +52,7 @@ public class TestCellModel extends TestModelBase<CellModel> {
|
||||||
"{\"column\":\"dGVzdGNvbHVtbg==\",\"timestamp\":1245219839331,\"$\":\"dGVzdHZhbHVl\"}";
|
"{\"column\":\"dGVzdGNvbHVtbg==\",\"timestamp\":1245219839331,\"$\":\"dGVzdHZhbHVl\"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected CellModel buildTestModel() {
|
protected CellModel buildTestModel() {
|
||||||
CellModel model = new CellModel();
|
CellModel model = new CellModel();
|
||||||
model.setColumn(COLUMN);
|
model.setColumn(COLUMN);
|
||||||
|
@ -56,21 +61,25 @@ public class TestCellModel extends TestModelBase<CellModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(CellModel model) {
|
protected void checkModel(CellModel model) {
|
||||||
assertTrue(Bytes.equals(model.getColumn(), COLUMN));
|
assertTrue(Bytes.equals(model.getColumn(), COLUMN));
|
||||||
assertTrue(Bytes.equals(model.getValue(), VALUE));
|
assertTrue(Bytes.equals(model.getValue(), VALUE));
|
||||||
assertTrue(model.hasUserTimestamp());
|
assertTrue(model.hasUserTimestamp());
|
||||||
assertEquals(model.getTimestamp(), TIMESTAMP);
|
assertEquals(TIMESTAMP, model.getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testBuildModel() throws Exception {
|
public void testBuildModel() throws Exception {
|
||||||
checkModel(buildTestModel());
|
checkModel(buildTestModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
checkModel(fromXML(AS_XML));
|
checkModel(fromXML(AS_XML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testFromPB() throws Exception {
|
public void testFromPB() throws Exception {
|
||||||
checkModel(fromPB(AS_PB));
|
checkModel(fromPB(AS_PB));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
|
@ -81,6 +85,7 @@ public class TestCellSetModel extends TestModelBase<CellSetModel> {
|
||||||
"\"timestamp\":1245393318192,\"$\":\"dGVzdHZhbHVlMw==\"}]}]}";
|
"\"timestamp\":1245393318192,\"$\":\"dGVzdHZhbHVlMw==\"}]}]}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected CellSetModel buildTestModel() {
|
protected CellSetModel buildTestModel() {
|
||||||
CellSetModel model = new CellSetModel();
|
CellSetModel model = new CellSetModel();
|
||||||
RowModel row;
|
RowModel row;
|
||||||
|
@ -96,6 +101,7 @@ public class TestCellSetModel extends TestModelBase<CellSetModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(CellSetModel model) {
|
protected void checkModel(CellSetModel model) {
|
||||||
Iterator<RowModel> rows = model.getRows().iterator();
|
Iterator<RowModel> rows = model.getRows().iterator();
|
||||||
RowModel row = rows.next();
|
RowModel row = rows.next();
|
||||||
|
@ -105,7 +111,7 @@ public class TestCellSetModel extends TestModelBase<CellSetModel> {
|
||||||
assertTrue(Bytes.equals(COLUMN1, cell.getColumn()));
|
assertTrue(Bytes.equals(COLUMN1, cell.getColumn()));
|
||||||
assertTrue(Bytes.equals(VALUE1, cell.getValue()));
|
assertTrue(Bytes.equals(VALUE1, cell.getValue()));
|
||||||
assertTrue(cell.hasUserTimestamp());
|
assertTrue(cell.hasUserTimestamp());
|
||||||
assertEquals(cell.getTimestamp(), TIMESTAMP1);
|
assertEquals(TIMESTAMP1, cell.getTimestamp());
|
||||||
assertFalse(cells.hasNext());
|
assertFalse(cells.hasNext());
|
||||||
row = rows.next();
|
row = rows.next();
|
||||||
assertTrue(Bytes.equals(ROW2, row.getKey()));
|
assertTrue(Bytes.equals(ROW2, row.getKey()));
|
||||||
|
@ -114,23 +120,26 @@ public class TestCellSetModel extends TestModelBase<CellSetModel> {
|
||||||
assertTrue(Bytes.equals(COLUMN2, cell.getColumn()));
|
assertTrue(Bytes.equals(COLUMN2, cell.getColumn()));
|
||||||
assertTrue(Bytes.equals(VALUE2, cell.getValue()));
|
assertTrue(Bytes.equals(VALUE2, cell.getValue()));
|
||||||
assertTrue(cell.hasUserTimestamp());
|
assertTrue(cell.hasUserTimestamp());
|
||||||
assertEquals(cell.getTimestamp(), TIMESTAMP2);
|
assertEquals(TIMESTAMP2, cell.getTimestamp());
|
||||||
cell = cells.next();
|
cell = cells.next();
|
||||||
assertTrue(Bytes.equals(COLUMN3, cell.getColumn()));
|
assertTrue(Bytes.equals(COLUMN3, cell.getColumn()));
|
||||||
assertTrue(Bytes.equals(VALUE3, cell.getValue()));
|
assertTrue(Bytes.equals(VALUE3, cell.getValue()));
|
||||||
assertTrue(cell.hasUserTimestamp());
|
assertTrue(cell.hasUserTimestamp());
|
||||||
assertEquals(cell.getTimestamp(), TIMESTAMP3);
|
assertEquals(TIMESTAMP3, cell.getTimestamp());
|
||||||
assertFalse(cells.hasNext());
|
assertFalse(cells.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testBuildModel() throws Exception {
|
public void testBuildModel() throws Exception {
|
||||||
checkModel(buildTestModel());
|
checkModel(buildTestModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
checkModel(fromXML(AS_XML));
|
checkModel(fromXML(AS_XML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testFromPB() throws Exception {
|
public void testFromPB() throws Exception {
|
||||||
checkModel(fromPB(AS_PB));
|
checkModel(fromPB(AS_PB));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,12 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category({RestTests.class, SmallTests.class})
|
@Category({RestTests.class, SmallTests.class})
|
||||||
|
@ -48,6 +52,7 @@ public class TestColumnSchemaModel extends TestModelBase<ColumnSchemaModel> {
|
||||||
"\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}";
|
"\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected ColumnSchemaModel buildTestModel() {
|
protected ColumnSchemaModel buildTestModel() {
|
||||||
ColumnSchemaModel model = new ColumnSchemaModel();
|
ColumnSchemaModel model = new ColumnSchemaModel();
|
||||||
model.setName(COLUMN_NAME);
|
model.setName(COLUMN_NAME);
|
||||||
|
@ -61,6 +66,7 @@ public class TestColumnSchemaModel extends TestModelBase<ColumnSchemaModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(ColumnSchemaModel model) {
|
protected void checkModel(ColumnSchemaModel model) {
|
||||||
assertEquals("name", COLUMN_NAME, model.getName());
|
assertEquals("name", COLUMN_NAME, model.getName());
|
||||||
assertEquals("block cache", BLOCKCACHE, model.__getBlockcache());
|
assertEquals("block cache", BLOCKCACHE, model.__getBlockcache());
|
||||||
|
@ -72,6 +78,8 @@ public class TestColumnSchemaModel extends TestModelBase<ColumnSchemaModel> {
|
||||||
assertEquals("versions", VERSIONS, model.__getVersions());
|
assertEquals("versions", VERSIONS, model.__getVersions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Test
|
||||||
public void testFromPB() throws Exception {
|
public void testFromPB() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,26 +18,30 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
|
import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
|
||||||
import org.apache.hadoop.hbase.rest.provider.JAXBContextResolver;
|
import org.apache.hadoop.hbase.rest.provider.JAXBContextResolver;
|
||||||
import org.apache.hadoop.hbase.util.Base64;
|
import org.apache.hadoop.hbase.util.Base64;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.xml.bind.JAXBContext;
|
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
|
||||||
|
|
||||||
@Category({RestTests.class, SmallTests.class})
|
@Category({RestTests.class, SmallTests.class})
|
||||||
public abstract class TestModelBase<T> extends TestCase {
|
public abstract class TestModelBase<T> {
|
||||||
|
|
||||||
protected String AS_XML;
|
protected String AS_XML;
|
||||||
|
|
||||||
|
@ -94,29 +98,34 @@ public abstract class TestModelBase<T> extends TestCase {
|
||||||
protected T fromPB(String pb) throws
|
protected T fromPB(String pb) throws
|
||||||
Exception {
|
Exception {
|
||||||
return (T)clazz.getMethod("getObjectFromMessage", byte[].class).invoke(
|
return (T)clazz.getMethod("getObjectFromMessage", byte[].class).invoke(
|
||||||
clazz.newInstance(),
|
clazz.getDeclaredConstructor().newInstance(),
|
||||||
Base64.decode(AS_PB));
|
Base64.decode(AS_PB));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void checkModel(T model);
|
protected abstract void checkModel(T model);
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBuildModel() throws Exception {
|
public void testBuildModel() throws Exception {
|
||||||
checkModel(buildTestModel());
|
checkModel(buildTestModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFromPB() throws Exception {
|
public void testFromPB() throws Exception {
|
||||||
checkModel(fromPB(AS_PB));
|
checkModel(fromPB(AS_PB));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
checkModel(fromXML(AS_XML));
|
checkModel(fromXML(AS_XML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testToXML() throws Exception {
|
public void testToXML() throws Exception {
|
||||||
// Uses fromXML to check model because XML element ordering can be random.
|
// Uses fromXML to check model because XML element ordering can be random.
|
||||||
checkModel(fromXML(toXML(buildTestModel())));
|
checkModel(fromXML(toXML(buildTestModel())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testToJSON() throws Exception {
|
public void testToJSON() throws Exception {
|
||||||
try {
|
try {
|
||||||
ObjectNode expObj = mapper.readValue(AS_JSON, ObjectNode.class);
|
ObjectNode expObj = mapper.readValue(AS_JSON, ObjectNode.class);
|
||||||
|
@ -127,6 +136,7 @@ public abstract class TestModelBase<T> extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFromJSON() throws Exception {
|
public void testFromJSON() throws Exception {
|
||||||
checkModel(fromJSON(AS_JSON));
|
checkModel(fromJSON(AS_JSON));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotSame;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -53,6 +56,7 @@ public class TestNamespacesInstanceModel extends TestModelBase<NamespacesInstanc
|
||||||
"\"KEY_1\":\"VALUE_1\",\"KEY_2\":\"VALUE_2\"}}";
|
"\"KEY_1\":\"VALUE_1\",\"KEY_2\":\"VALUE_2\"}}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected NamespacesInstanceModel buildTestModel() {
|
protected NamespacesInstanceModel buildTestModel() {
|
||||||
return buildTestModel(NAMESPACE_NAME, NAMESPACE_PROPERTIES);
|
return buildTestModel(NAMESPACE_NAME, NAMESPACE_PROPERTIES);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +69,7 @@ public class TestNamespacesInstanceModel extends TestModelBase<NamespacesInstanc
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(NamespacesInstanceModel model) {
|
protected void checkModel(NamespacesInstanceModel model) {
|
||||||
checkModel(model, NAMESPACE_NAME, NAMESPACE_PROPERTIES);
|
checkModel(model, NAMESPACE_NAME, NAMESPACE_PROPERTIES);
|
||||||
}
|
}
|
||||||
|
@ -80,16 +85,19 @@ public class TestNamespacesInstanceModel extends TestModelBase<NamespacesInstanc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testBuildModel() throws Exception {
|
public void testBuildModel() throws Exception {
|
||||||
checkModel(buildTestModel());
|
checkModel(buildTestModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
checkModel(fromXML(AS_XML));
|
checkModel(fromXML(AS_XML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFromPB() throws Exception {
|
public void testFromPB() throws Exception {
|
||||||
checkModel(fromPB(AS_PB));
|
checkModel(fromPB(AS_PB));
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -47,6 +50,7 @@ public class TestNamespacesModel extends TestModelBase<NamespacesModel> {
|
||||||
AS_JSON = "{\"Namespace\":[\"testNamespace1\",\"testNamespace2\"]}";
|
AS_JSON = "{\"Namespace\":[\"testNamespace1\",\"testNamespace2\"]}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected NamespacesModel buildTestModel() {
|
protected NamespacesModel buildTestModel() {
|
||||||
return buildTestModel(NAMESPACE_NAME_1, NAMESPACE_NAME_2);
|
return buildTestModel(NAMESPACE_NAME_1, NAMESPACE_NAME_2);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +61,7 @@ public class TestNamespacesModel extends TestModelBase<NamespacesModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(NamespacesModel model) {
|
protected void checkModel(NamespacesModel model) {
|
||||||
checkModel(model, NAMESPACE_NAME_1, NAMESPACE_NAME_2);
|
checkModel(model, NAMESPACE_NAME_1, NAMESPACE_NAME_2);
|
||||||
}
|
}
|
||||||
|
@ -69,16 +74,19 @@ public class TestNamespacesModel extends TestModelBase<NamespacesModel> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testBuildModel() throws Exception {
|
public void testBuildModel() throws Exception {
|
||||||
checkModel(buildTestModel());
|
checkModel(buildTestModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
checkModel(fromXML(AS_XML));
|
checkModel(fromXML(AS_XML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFromPB() throws Exception {
|
public void testFromPB() throws Exception {
|
||||||
checkModel(fromPB(AS_PB));
|
checkModel(fromPB(AS_PB));
|
||||||
|
|
|
@ -19,9 +19,11 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
@ -41,8 +43,6 @@ public class TestRowModel extends TestModelBase<RowModel> {
|
||||||
private static final byte[] VALUE1 = Bytes.toBytes("testvalue1");
|
private static final byte[] VALUE1 = Bytes.toBytes("testvalue1");
|
||||||
private static final long TIMESTAMP1 = 1245219839331L;
|
private static final long TIMESTAMP1 = 1245219839331L;
|
||||||
|
|
||||||
private JAXBContext context;
|
|
||||||
|
|
||||||
public TestRowModel() throws Exception {
|
public TestRowModel() throws Exception {
|
||||||
super(RowModel.class);
|
super(RowModel.class);
|
||||||
AS_XML =
|
AS_XML =
|
||||||
|
@ -54,6 +54,7 @@ public class TestRowModel extends TestModelBase<RowModel> {
|
||||||
"\"timestamp\":1245219839331,\"$\":\"dGVzdHZhbHVlMQ==\"}]}";
|
"\"timestamp\":1245219839331,\"$\":\"dGVzdHZhbHVlMQ==\"}]}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected RowModel buildTestModel() {
|
protected RowModel buildTestModel() {
|
||||||
RowModel model = new RowModel();
|
RowModel model = new RowModel();
|
||||||
model.setKey(ROW1);
|
model.setKey(ROW1);
|
||||||
|
@ -61,6 +62,7 @@ public class TestRowModel extends TestModelBase<RowModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(RowModel model) {
|
protected void checkModel(RowModel model) {
|
||||||
assertTrue(Bytes.equals(ROW1, model.getKey()));
|
assertTrue(Bytes.equals(ROW1, model.getKey()));
|
||||||
Iterator<CellModel> cells = model.getCells().iterator();
|
Iterator<CellModel> cells = model.getCells().iterator();
|
||||||
|
@ -68,7 +70,7 @@ public class TestRowModel extends TestModelBase<RowModel> {
|
||||||
assertTrue(Bytes.equals(COLUMN1, cell.getColumn()));
|
assertTrue(Bytes.equals(COLUMN1, cell.getColumn()));
|
||||||
assertTrue(Bytes.equals(VALUE1, cell.getValue()));
|
assertTrue(Bytes.equals(VALUE1, cell.getValue()));
|
||||||
assertTrue(cell.hasUserTimestamp());
|
assertTrue(cell.hasUserTimestamp());
|
||||||
assertEquals(cell.getTimestamp(), TIMESTAMP1);
|
assertEquals(TIMESTAMP1, cell.getTimestamp());
|
||||||
assertFalse(cells.hasNext());
|
assertFalse(cells.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
@ -58,6 +61,7 @@ public class TestScannerModel extends TestModelBase<ScannerModel> {
|
||||||
+ "JDj/////B0joB1IHcHJpdmF0ZVIGcHVibGljWAA=";
|
+ "JDj/////B0joB1IHcHJpdmF0ZVIGcHVibGljWAA=";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected ScannerModel buildTestModel() {
|
protected ScannerModel buildTestModel() {
|
||||||
ScannerModel model = new ScannerModel();
|
ScannerModel model = new ScannerModel();
|
||||||
model.setStartRow(START_ROW);
|
model.setStartRow(START_ROW);
|
||||||
|
@ -74,6 +78,7 @@ public class TestScannerModel extends TestModelBase<ScannerModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(ScannerModel model) {
|
protected void checkModel(ScannerModel model) {
|
||||||
assertTrue(Bytes.equals(model.getStartRow(), START_ROW));
|
assertTrue(Bytes.equals(model.getStartRow(), START_ROW));
|
||||||
assertTrue(Bytes.equals(model.getEndRow(), END_ROW));
|
assertTrue(Bytes.equals(model.getEndRow(), END_ROW));
|
||||||
|
@ -87,11 +92,11 @@ public class TestScannerModel extends TestModelBase<ScannerModel> {
|
||||||
}
|
}
|
||||||
assertTrue(foundCol1);
|
assertTrue(foundCol1);
|
||||||
assertTrue(foundCol2);
|
assertTrue(foundCol2);
|
||||||
assertEquals(model.getStartTime(), START_TIME);
|
assertEquals(START_TIME, model.getStartTime());
|
||||||
assertEquals(model.getEndTime(), END_TIME);
|
assertEquals(END_TIME, model.getEndTime());
|
||||||
assertEquals(model.getBatch(), BATCH);
|
assertEquals(BATCH, model.getBatch());
|
||||||
assertEquals(model.getCaching(), CACHING);
|
assertEquals(CACHING, model.getCaching());
|
||||||
assertEquals(model.getCacheBlocks(), CACHE_BLOCKS);
|
assertEquals(CACHE_BLOCKS, model.getCacheBlocks());
|
||||||
boolean foundLabel1 = false;
|
boolean foundLabel1 = false;
|
||||||
boolean foundLabel2 = false;
|
boolean foundLabel2 = false;
|
||||||
if (model.getLabels() != null && model.getLabels().size() > 0) {
|
if (model.getLabels() != null && model.getLabels().size() > 0) {
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
|
@ -74,6 +78,7 @@ public class TestStorageClusterStatusModel extends TestModelBase<StorageClusterS
|
||||||
"\"heapSizeMB\":512,\"maxHeapSizeMB\":1024}],\"DeadNodes\":[]}";
|
"\"heapSizeMB\":512,\"maxHeapSizeMB\":1024}],\"DeadNodes\":[]}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected StorageClusterStatusModel buildTestModel() {
|
protected StorageClusterStatusModel buildTestModel() {
|
||||||
StorageClusterStatusModel model = new StorageClusterStatusModel();
|
StorageClusterStatusModel model = new StorageClusterStatusModel();
|
||||||
model.setRegions(2);
|
model.setRegions(2);
|
||||||
|
@ -87,56 +92,57 @@ public class TestStorageClusterStatusModel extends TestModelBase<StorageClusterS
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(StorageClusterStatusModel model) {
|
protected void checkModel(StorageClusterStatusModel model) {
|
||||||
assertEquals(model.getRegions(), 2);
|
assertEquals(2, model.getRegions());
|
||||||
assertEquals(model.getRequests(), 0);
|
assertEquals(0, model.getRequests());
|
||||||
assertEquals(model.getAverageLoad(), 1.0);
|
assertEquals(1.0, model.getAverageLoad(), 0.0);
|
||||||
Iterator<StorageClusterStatusModel.Node> nodes =
|
Iterator<StorageClusterStatusModel.Node> nodes =
|
||||||
model.getLiveNodes().iterator();
|
model.getLiveNodes().iterator();
|
||||||
StorageClusterStatusModel.Node node = nodes.next();
|
StorageClusterStatusModel.Node node = nodes.next();
|
||||||
assertEquals(node.getName(), "test1");
|
assertEquals("test1", node.getName());
|
||||||
assertEquals(node.getStartCode(), 1245219839331L);
|
assertEquals(1245219839331L, node.getStartCode());
|
||||||
assertEquals(node.getHeapSizeMB(), 128);
|
assertEquals(128, node.getHeapSizeMB());
|
||||||
assertEquals(node.getMaxHeapSizeMB(), 1024);
|
assertEquals(1024, node.getMaxHeapSizeMB());
|
||||||
Iterator<StorageClusterStatusModel.Node.Region> regions =
|
Iterator<StorageClusterStatusModel.Node.Region> regions =
|
||||||
node.getRegions().iterator();
|
node.getRegions().iterator();
|
||||||
StorageClusterStatusModel.Node.Region region = regions.next();
|
StorageClusterStatusModel.Node.Region region = regions.next();
|
||||||
assertTrue(Bytes.toString(region.getName()).equals(
|
assertTrue(Bytes.toString(region.getName()).equals(
|
||||||
"hbase:root,,0"));
|
"hbase:root,,0"));
|
||||||
assertEquals(region.getStores(), 1);
|
assertEquals(1, region.getStores());
|
||||||
assertEquals(region.getStorefiles(), 1);
|
assertEquals(1, region.getStorefiles());
|
||||||
assertEquals(region.getStorefileSizeMB(), 0);
|
assertEquals(0, region.getStorefileSizeMB());
|
||||||
assertEquals(region.getMemStoreSizeMB(), 0);
|
assertEquals(0, region.getMemStoreSizeMB());
|
||||||
assertEquals(region.getStorefileIndexSizeKB(), 0);
|
assertEquals(0, region.getStorefileIndexSizeKB());
|
||||||
assertEquals(region.getReadRequestsCount(), 1);
|
assertEquals(1, region.getReadRequestsCount());
|
||||||
assertEquals(region.getWriteRequestsCount(), 2);
|
assertEquals(2, region.getWriteRequestsCount());
|
||||||
assertEquals(region.getRootIndexSizeKB(), 1);
|
assertEquals(1, region.getRootIndexSizeKB());
|
||||||
assertEquals(region.getTotalStaticIndexSizeKB(), 1);
|
assertEquals(1, region.getTotalStaticIndexSizeKB());
|
||||||
assertEquals(region.getTotalStaticBloomSizeKB(), 1);
|
assertEquals(1, region.getTotalStaticBloomSizeKB());
|
||||||
assertEquals(region.getTotalCompactingKVs(), 1);
|
assertEquals(1, region.getTotalCompactingKVs());
|
||||||
assertEquals(region.getCurrentCompactedKVs(), 1);
|
assertEquals(1, region.getCurrentCompactedKVs());
|
||||||
assertFalse(regions.hasNext());
|
assertFalse(regions.hasNext());
|
||||||
node = nodes.next();
|
node = nodes.next();
|
||||||
assertEquals(node.getName(), "test2");
|
assertEquals("test2", node.getName());
|
||||||
assertEquals(node.getStartCode(), 1245239331198L);
|
assertEquals(1245239331198L, node.getStartCode());
|
||||||
assertEquals(node.getHeapSizeMB(), 512);
|
assertEquals(512, node.getHeapSizeMB());
|
||||||
assertEquals(node.getMaxHeapSizeMB(), 1024);
|
assertEquals(1024, node.getMaxHeapSizeMB());
|
||||||
regions = node.getRegions().iterator();
|
regions = node.getRegions().iterator();
|
||||||
region = regions.next();
|
region = regions.next();
|
||||||
assertEquals(Bytes.toString(region.getName()),
|
assertEquals(Bytes.toString(region.getName()),
|
||||||
TableName.META_TABLE_NAME+",,1246000043724");
|
TableName.META_TABLE_NAME+",,1246000043724");
|
||||||
assertEquals(region.getStores(), 1);
|
assertEquals(1, region.getStores());
|
||||||
assertEquals(region.getStorefiles(), 1);
|
assertEquals(1, region.getStorefiles());
|
||||||
assertEquals(region.getStorefileSizeMB(), 0);
|
assertEquals(0, region.getStorefileSizeMB());
|
||||||
assertEquals(region.getMemStoreSizeMB(), 0);
|
assertEquals(0, region.getMemStoreSizeMB());
|
||||||
assertEquals(region.getStorefileIndexSizeKB(), 0);
|
assertEquals(0, region.getStorefileIndexSizeKB());
|
||||||
assertEquals(region.getReadRequestsCount(), 1);
|
assertEquals(1, region.getReadRequestsCount());
|
||||||
assertEquals(region.getWriteRequestsCount(), 2);
|
assertEquals(2, region.getWriteRequestsCount());
|
||||||
assertEquals(region.getRootIndexSizeKB(), 1);
|
assertEquals(1, region.getRootIndexSizeKB());
|
||||||
assertEquals(region.getTotalStaticIndexSizeKB(), 1);
|
assertEquals(1, region.getTotalStaticIndexSizeKB());
|
||||||
assertEquals(region.getTotalStaticBloomSizeKB(), 1);
|
assertEquals(1, region.getTotalStaticBloomSizeKB());
|
||||||
assertEquals(region.getTotalCompactingKVs(), 1);
|
assertEquals(1, region.getTotalCompactingKVs());
|
||||||
assertEquals(region.getCurrentCompactedKVs(), 1);
|
assertEquals(1, region.getCurrentCompactedKVs());
|
||||||
|
|
||||||
assertFalse(regions.hasNext());
|
assertFalse(regions.hasNext());
|
||||||
assertFalse(nodes.hasNext());
|
assertFalse(nodes.hasNext());
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
@ -36,14 +38,16 @@ public class TestStorageClusterVersionModel extends TestModelBase<StorageCluster
|
||||||
AS_JSON = "{\"Version\": \"0.0.1-testing\"}";
|
AS_JSON = "{\"Version\": \"0.0.1-testing\"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected StorageClusterVersionModel buildTestModel() {
|
protected StorageClusterVersionModel buildTestModel() {
|
||||||
StorageClusterVersionModel model = new StorageClusterVersionModel();
|
StorageClusterVersionModel model = new StorageClusterVersionModel();
|
||||||
model.setVersion(VERSION);
|
model.setVersion(VERSION);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(StorageClusterVersionModel model) {
|
protected void checkModel(StorageClusterVersionModel model) {
|
||||||
assertEquals(model.getVersion(), VERSION);
|
assertEquals(VERSION, model.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
|
@ -55,6 +59,7 @@ public class TestTableInfoModel extends TestModelBase<TableInfoModel> {
|
||||||
"startKey\":\"YWJyYWNhZGJyYQ==\"}]}";
|
"startKey\":\"YWJyYWNhZGJyYQ==\"}]}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected TableInfoModel buildTestModel() {
|
protected TableInfoModel buildTestModel() {
|
||||||
TableInfoModel model = new TableInfoModel();
|
TableInfoModel model = new TableInfoModel();
|
||||||
model.setName(TABLE);
|
model.setName(TABLE);
|
||||||
|
@ -62,25 +67,29 @@ public class TestTableInfoModel extends TestModelBase<TableInfoModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(TableInfoModel model) {
|
protected void checkModel(TableInfoModel model) {
|
||||||
assertEquals(model.getName(), TABLE);
|
assertEquals(TABLE, model.getName());
|
||||||
Iterator<TableRegionModel> regions = model.getRegions().iterator();
|
Iterator<TableRegionModel> regions = model.getRegions().iterator();
|
||||||
TableRegionModel region = regions.next();
|
TableRegionModel region = regions.next();
|
||||||
assertTrue(Bytes.equals(region.getStartKey(), START_KEY));
|
assertTrue(Bytes.equals(region.getStartKey(), START_KEY));
|
||||||
assertTrue(Bytes.equals(region.getEndKey(), END_KEY));
|
assertTrue(Bytes.equals(region.getEndKey(), END_KEY));
|
||||||
assertEquals(region.getId(), ID);
|
assertEquals(ID, region.getId());
|
||||||
assertEquals(region.getLocation(), LOCATION);
|
assertEquals(LOCATION, region.getLocation());
|
||||||
assertFalse(regions.hasNext());
|
assertFalse(regions.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testBuildModel() throws Exception {
|
public void testBuildModel() throws Exception {
|
||||||
checkModel(buildTestModel());
|
checkModel(buildTestModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
checkModel(fromXML(AS_XML));
|
checkModel(fromXML(AS_XML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testFromPB() throws Exception {
|
public void testFromPB() throws Exception {
|
||||||
checkModel(fromPB(AS_PB));
|
checkModel(fromPB(AS_PB));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
|
@ -44,6 +47,7 @@ public class TestTableListModel extends TestModelBase<TableListModel> {
|
||||||
"{\"table\":[{\"name\":\"table1\"},{\"name\":\"table2\"},{\"name\":\"table3\"}]}";
|
"{\"table\":[{\"name\":\"table1\"},{\"name\":\"table2\"},{\"name\":\"table3\"}]}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected TableListModel buildTestModel() {
|
protected TableListModel buildTestModel() {
|
||||||
TableListModel model = new TableListModel();
|
TableListModel model = new TableListModel();
|
||||||
model.add(new TableModel(TABLE1));
|
model.add(new TableModel(TABLE1));
|
||||||
|
@ -52,14 +56,15 @@ public class TestTableListModel extends TestModelBase<TableListModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(TableListModel model) {
|
protected void checkModel(TableListModel model) {
|
||||||
Iterator<TableModel> tables = model.getTables().iterator();
|
Iterator<TableModel> tables = model.getTables().iterator();
|
||||||
TableModel table = tables.next();
|
TableModel table = tables.next();
|
||||||
assertEquals(table.getName(), TABLE1);
|
assertEquals(TABLE1, table.getName());
|
||||||
table = tables.next();
|
table = tables.next();
|
||||||
assertEquals(table.getName(), TABLE2);
|
assertEquals(TABLE2, table.getName());
|
||||||
table = tables.next();
|
table = tables.next();
|
||||||
assertEquals(table.getName(), TABLE3);
|
assertEquals(TABLE3, table.getName());
|
||||||
assertFalse(tables.hasNext());
|
assertFalse(tables.hasNext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,16 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category({RestTests.class, SmallTests.class})
|
@Category({RestTests.class, SmallTests.class})
|
||||||
|
@ -49,22 +54,25 @@ public class TestTableRegionModel extends TestModelBase<TableRegionModel> {
|
||||||
"startKey\":\"YWJyYWNhZGJyYQ==\"}";
|
"startKey\":\"YWJyYWNhZGJyYQ==\"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected TableRegionModel buildTestModel() {
|
protected TableRegionModel buildTestModel() {
|
||||||
TableRegionModel model =
|
TableRegionModel model =
|
||||||
new TableRegionModel(TABLE, ID, START_KEY, END_KEY, LOCATION);
|
new TableRegionModel(TABLE, ID, START_KEY, END_KEY, LOCATION);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(TableRegionModel model) {
|
protected void checkModel(TableRegionModel model) {
|
||||||
assertTrue(Bytes.equals(model.getStartKey(), START_KEY));
|
assertTrue(Bytes.equals(model.getStartKey(), START_KEY));
|
||||||
assertTrue(Bytes.equals(model.getEndKey(), END_KEY));
|
assertTrue(Bytes.equals(model.getEndKey(), END_KEY));
|
||||||
assertEquals(model.getId(), ID);
|
assertEquals(ID, model.getId());
|
||||||
assertEquals(model.getLocation(), LOCATION);
|
assertEquals(LOCATION, model.getLocation());
|
||||||
assertEquals(model.getName(),
|
assertEquals(model.getName(),
|
||||||
TABLE + "," + Bytes.toString(START_KEY) + "," + Long.toString(ID) +
|
TABLE + "," + Bytes.toString(START_KEY) + "," + Long.toString(ID) +
|
||||||
".ad9860f031282c46ed431d7af8f94aca.");
|
".ad9860f031282c46ed431d7af8f94aca.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetName() {
|
public void testGetName() {
|
||||||
TableRegionModel model = buildTestModel();
|
TableRegionModel model = buildTestModel();
|
||||||
String modelName = model.getName();
|
String modelName = model.getName();
|
||||||
|
@ -73,6 +81,7 @@ public class TestTableRegionModel extends TestModelBase<TableRegionModel> {
|
||||||
assertEquals(modelName, hri.getRegionNameAsString());
|
assertEquals(modelName, hri.getRegionNameAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSetName() {
|
public void testSetName() {
|
||||||
TableRegionModel model = buildTestModel();
|
TableRegionModel model = buildTestModel();
|
||||||
String name = model.getName();
|
String name = model.getName();
|
||||||
|
|
|
@ -19,13 +19,16 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -41,8 +44,6 @@ public class TestTableSchemaModel extends TestModelBase<TableSchemaModel> {
|
||||||
|
|
||||||
TestColumnSchemaModel testColumnSchemaModel;
|
TestColumnSchemaModel testColumnSchemaModel;
|
||||||
|
|
||||||
private JAXBContext context;
|
|
||||||
|
|
||||||
public TestTableSchemaModel() throws Exception {
|
public TestTableSchemaModel() throws Exception {
|
||||||
super(TableSchemaModel.class);
|
super(TableSchemaModel.class);
|
||||||
testColumnSchemaModel = new TestColumnSchemaModel();
|
testColumnSchemaModel = new TestColumnSchemaModel();
|
||||||
|
@ -67,6 +68,7 @@ public class TestTableSchemaModel extends TestModelBase<TableSchemaModel> {
|
||||||
"\"COMPRESSION\":\"GZ\",\"VERSIONS\":\"1\",\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}]}";
|
"\"COMPRESSION\":\"GZ\",\"VERSIONS\":\"1\",\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}]}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected TableSchemaModel buildTestModel() {
|
protected TableSchemaModel buildTestModel() {
|
||||||
return buildTestModel(TABLE_NAME);
|
return buildTestModel(TABLE_NAME);
|
||||||
}
|
}
|
||||||
|
@ -81,15 +83,16 @@ public class TestTableSchemaModel extends TestModelBase<TableSchemaModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(TableSchemaModel model) {
|
protected void checkModel(TableSchemaModel model) {
|
||||||
checkModel(model, TABLE_NAME);
|
checkModel(model, TABLE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkModel(TableSchemaModel model, String tableName) {
|
public void checkModel(TableSchemaModel model, String tableName) {
|
||||||
assertEquals(model.getName(), tableName);
|
assertEquals(model.getName(), tableName);
|
||||||
assertEquals(model.__getIsMeta(), IS_META);
|
assertEquals(IS_META, model.__getIsMeta());
|
||||||
assertEquals(model.__getIsRoot(), IS_ROOT);
|
assertEquals(IS_ROOT, model.__getIsRoot());
|
||||||
assertEquals(model.__getReadOnly(), READONLY);
|
assertEquals(READONLY, model.__getReadOnly());
|
||||||
Iterator<ColumnSchemaModel> families = model.getColumns().iterator();
|
Iterator<ColumnSchemaModel> families = model.getColumns().iterator();
|
||||||
assertTrue(families.hasNext());
|
assertTrue(families.hasNext());
|
||||||
ColumnSchemaModel family = families.next();
|
ColumnSchemaModel family = families.next();
|
||||||
|
@ -97,14 +100,20 @@ public class TestTableSchemaModel extends TestModelBase<TableSchemaModel> {
|
||||||
assertFalse(families.hasNext());
|
assertFalse(families.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Test
|
||||||
public void testBuildModel() throws Exception {
|
public void testBuildModel() throws Exception {
|
||||||
checkModel(buildTestModel());
|
checkModel(buildTestModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Test
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
checkModel(fromXML(AS_XML));
|
checkModel(fromXML(AS_XML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Test
|
||||||
public void testFromPB() throws Exception {
|
public void testFromPB() throws Exception {
|
||||||
checkModel(fromPB(AS_PB));
|
checkModel(fromPB(AS_PB));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.rest.model;
|
package org.apache.hadoop.hbase.rest.model;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.testclassification.RestTests;
|
import org.apache.hadoop.hbase.testclassification.RestTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
|
||||||
import org.junit.Assume;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
|
|
||||||
@Category({RestTests.class, SmallTests.class})
|
@Category({RestTests.class, SmallTests.class})
|
||||||
public class TestVersionModel extends TestModelBase<VersionModel> {
|
public class TestVersionModel extends TestModelBase<VersionModel> {
|
||||||
|
@ -55,6 +51,7 @@ public class TestVersionModel extends TestModelBase<VersionModel> {
|
||||||
"REST\":\"0.0.1\",\"Server\":\"6.1.14\"}";
|
"REST\":\"0.0.1\",\"Server\":\"6.1.14\"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected VersionModel buildTestModel() {
|
protected VersionModel buildTestModel() {
|
||||||
VersionModel model = new VersionModel();
|
VersionModel model = new VersionModel();
|
||||||
model.setRESTVersion(REST_VERSION);
|
model.setRESTVersion(REST_VERSION);
|
||||||
|
@ -65,12 +62,13 @@ public class TestVersionModel extends TestModelBase<VersionModel> {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkModel(VersionModel model) {
|
protected void checkModel(VersionModel model) {
|
||||||
assertEquals(model.getRESTVersion(), REST_VERSION);
|
assertEquals(REST_VERSION, model.getRESTVersion());
|
||||||
assertEquals(model.getOSVersion(), OS_VERSION);
|
assertEquals(OS_VERSION, model.getOSVersion());
|
||||||
assertEquals(model.getJVMVersion(), JVM_VERSION);
|
assertEquals(JVM_VERSION, model.getJVMVersion());
|
||||||
assertEquals(model.getServerVersion(), JETTY_VERSION);
|
assertEquals(JETTY_VERSION, model.getServerVersion());
|
||||||
assertEquals(model.getJerseyVersion(), JERSEY_VERSION);
|
assertEquals(JERSEY_VERSION, model.getJerseyVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue