diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterVersionModel.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterVersionModel.java
index e332d49f1c5..548ca20b772 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterVersionModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterVersionModel.java
@@ -23,6 +23,7 @@ import org.codehaus.jackson.annotate.JsonValue;
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
@@ -47,7 +48,7 @@ public class StorageClusterVersionModel implements Serializable {
/**
* @return the storage cluster version
*/
- @XmlValue
+ @XmlAttribute(name="Version")
public String getVersion() {
return version;
}
@@ -62,7 +63,6 @@ public class StorageClusterVersionModel implements Serializable {
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
- @JsonValue
@Override
public String toString() {
return version;
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java
index b96a5d5a2a7..99fce2c80a3 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.rest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
@@ -35,6 +36,8 @@ import org.apache.hadoop.hbase.rest.model.VersionModel;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RestTests;
import org.apache.hadoop.hbase.util.Bytes;
+import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.codehaus.jackson.map.ObjectMapper;
import org.glassfish.jersey.servlet.ServletContainer;
import static org.junit.Assert.*;
@@ -128,6 +131,12 @@ public class TestVersionResource {
Response response = client.get("/version", Constants.MIMETYPE_JSON);
assertTrue(response.getCode() == 200);
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
+ ObjectMapper mapper = new JacksonJaxbJsonProvider()
+ .locateMapper(VersionModel.class, MediaType.APPLICATION_JSON_TYPE);
+ VersionModel model
+ = mapper.readValue(response.getBody(), VersionModel.class);
+ validate(model);
+ LOG.info("success retrieving Stargate version as JSON");
}
@Test
@@ -169,11 +178,17 @@ public class TestVersionResource {
}
@Test
- public void doTestGetStorageClusterVersionJSON() throws IOException {
+ public void testGetStorageClusterVersionJSON() throws IOException {
Response response = client.get("/version/cluster", Constants.MIMETYPE_JSON);
assertTrue(response.getCode() == 200);
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
+ ObjectMapper mapper = new JacksonJaxbJsonProvider()
+ .locateMapper(StorageClusterVersionModel.class, MediaType.APPLICATION_JSON_TYPE);
+ StorageClusterVersionModel clusterVersionModel
+ = mapper.readValue(response.getBody(), StorageClusterVersionModel.class);
+ assertNotNull(clusterVersionModel);
+ assertNotNull(clusterVersionModel.getVersion());
+ LOG.info("success retrieving storage cluster version as JSON");
}
-
}
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java
index 56dc05e1625..5e259f29085 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java
@@ -41,7 +41,7 @@ public class TestXmlParsing {
@Test
public void testParsingClusterVersion() throws Exception {
final String xml = ""
- + "2.0.0";
+ + "";
Client client = mock(Client.class);
RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null);
Response resp = new Response(200, null, xml.getBytes());
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java
index 602312d29d6..8c7e22bd234 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java
@@ -31,9 +31,9 @@ public class TestStorageClusterVersionModel extends TestModelBase"+
- "" + VERSION + "";
+ "";
- AS_JSON = "\"0.0.1-testing\"";
+ AS_JSON = "{\"Version\": \"0.0.1-testing\"}";
}
protected StorageClusterVersionModel buildTestModel() {