hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-17713 the interface '/version/cluster' with header 'Accept: application/json' return is not JSON but plain text
Date Wed, 06 Sep 2017 14:36:07 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 4733aa465 -> 13da97d85


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/13da97d8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/13da97d8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/13da97d8

Branch: refs/heads/branch-1
Commit: 13da97d85efcf81200d8f081a87c46b43339110c
Parents: 4733aa4
Author: Guangxu Cheng <guangxucheng@gmail.com>
Authored: Wed Sep 6 12:55:29 2017 +0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Wed Sep 6 07:36: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/13da97d8/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 54fc8de..bf163f2 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/13da97d8/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 cbacc40..60a4340 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
@@ -22,6 +22,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;
 
@@ -38,6 +39,8 @@ import org.apache.hadoop.hbase.util.Bytes;
 
 import static org.junit.Assert.*;
 
+import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.codehaus.jackson.map.ObjectMapper;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -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/13da97d8/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/13da97d8/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 fb004bf..e468549 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
@@ -30,9 +30,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