hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [07/50] [abbrv] hbase git commit: HBASE-17713 the interface '/version/cluster' with header 'Accept: application/json' return is not JSON but plain text
Date Mon, 11 Sep 2017 07:42:34 GMT
HBASE-17713 the interface '/version/cluster' with header 'Accept: application/json' return
is not JSON but plain text

Signed-off-by: tedyu <yuzhihong@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7fb52e73
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7fb52e73
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7fb52e73

Branch: refs/heads/HBASE-18467
Commit: 7fb52e73f340f41792e3a5aed5665402c4bb383c
Parents: 2f14a05
Author: Guangxu Cheng <guangxucheng@gmail.com>
Authored: Wed Sep 6 11:58:24 2017 +0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Wed Sep 6 07:31:01 2017 -0700

----------------------------------------------------------------------
 .../rest/model/StorageClusterVersionModel.java   |  4 ++--
 .../hadoop/hbase/rest/TestVersionResource.java   | 19 +++++++++++++++++--
 .../hadoop/hbase/rest/client/TestXmlParsing.java |  2 +-
 .../model/TestStorageClusterVersionModel.java    |  4 ++--
 4 files changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/7fb52e73/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterVersionModel.java
----------------------------------------------------------------------
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 e332d49..548ca20 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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/7fb52e73/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java
----------------------------------------------------------------------
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 b96a5d5..99fce2c 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");
   }
-
 }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/7fb52e73/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java
----------------------------------------------------------------------
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 56dc05e..5e259f2 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 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
-        + "<ClusterVersion>2.0.0</ClusterVersion>";
+        + "<ClusterVersion Version=\"2.0.0\"/>";
     Client client = mock(Client.class);
     RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null);
     Response resp = new Response(200, null, xml.getBytes());

http://git-wip-us.apache.org/repos/asf/hbase/blob/7fb52e73/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterVersionModel.java
----------------------------------------------------------------------
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 602312d..8c7e22b 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<StorageCluster
     super(StorageClusterVersionModel.class);
     AS_XML =
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"+
-      "<ClusterVersion>" + VERSION + "</ClusterVersion>";
+      "<ClusterVersion Version=\"" + VERSION + "\"/>";
 
-    AS_JSON = "\"0.0.1-testing\"";
+    AS_JSON = "{\"Version\": \"0.0.1-testing\"}";
   }
 
   protected StorageClusterVersionModel buildTestModel() {


Mime
View raw message