falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From venkat...@apache.org
Subject [1/2] git commit: FALCON-159 Version API endpoint does not emit valid JSON. Contributed by Srimanth Gunturi
Date Wed, 13 Nov 2013 02:02:39 GMT
Updated Branches:
  refs/heads/master cd78c3aa5 -> 2703d52ca


FALCON-159 Version API endpoint does not emit valid JSON. Contributed by Srimanth Gunturi


Project: http://git-wip-us.apache.org/repos/asf/incubator-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-falcon/commit/51c6eb20
Tree: http://git-wip-us.apache.org/repos/asf/incubator-falcon/tree/51c6eb20
Diff: http://git-wip-us.apache.org/repos/asf/incubator-falcon/diff/51c6eb20

Branch: refs/heads/master
Commit: 51c6eb20353adf603280d0cf08bedf2686043150
Parents: cd78c3a
Author: Venkatesh Seetharam <venkatesh@apache.org>
Authored: Tue Nov 12 17:59:20 2013 -0800
Committer: Venkatesh Seetharam <venkatesh@apache.org>
Committed: Tue Nov 12 17:59:20 2013 -0800

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 +++
 .../org/apache/falcon/client/FalconClient.java  |  2 +-
 docs/src/site/twiki/restapi/AdminVersion.twiki  | 12 +++++++++--
 .../falcon/resource/admin/AdminResource.java    | 22 +++++++++++++++-----
 .../falcon/resource/EntityManagerJerseyIT.java  | 18 +++++++++++-----
 5 files changed, 44 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/51c6eb20/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d86b98a..a54c3cd 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -78,6 +78,9 @@ Trunk (Unreleased)
 
   IMPROVEMENTS
 
+    FALCON-159 Version API endpoint does not emit valid JSON
+    (Srimanth Gunturi via Venkatesh Seetharam)
+
     FALCON-171 Provide status in /api/entities/list.
     (Haohui Mai via Venkatesh Seetharam)
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/51c6eb20/client/src/main/java/org/apache/falcon/client/FalconClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/client/FalconClient.java b/client/src/main/java/org/apache/falcon/client/FalconClient.java
index 9839745..f633db5 100644
--- a/client/src/main/java/org/apache/falcon/client/FalconClient.java
+++ b/client/src/main/java/org/apache/falcon/client/FalconClient.java
@@ -153,7 +153,7 @@ public class FalconClient {
     protected static enum AdminOperations {
 
         STACK("api/admin/stack", HttpMethod.GET, MediaType.TEXT_PLAIN),
-        VERSION("api/admin/version", HttpMethod.GET, MediaType.TEXT_PLAIN);
+        VERSION("api/admin/version", HttpMethod.GET, MediaType.APPLICATION_JSON);
 
         private String path;
         private String method;

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/51c6eb20/docs/src/site/twiki/restapi/AdminVersion.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/restapi/AdminVersion.twiki b/docs/src/site/twiki/restapi/AdminVersion.twiki
index 48315ed..fbf1405 100644
--- a/docs/src/site/twiki/restapi/AdminVersion.twiki
+++ b/docs/src/site/twiki/restapi/AdminVersion.twiki
@@ -21,7 +21,15 @@ Remote-User: rgautam
 ---+++ Result
 <verbatim>
 {
-    Version:"0.4-incubating-SNAPSHOT-rc0f2701549628f2f97746bd024518512c07d5442",
-    Mode:"embedded"
+    "properties":[
+        {
+            "key":"Version",
+            "value":"0.4-incubating-SNAPSHOT-rb47788d1112fcf949c22a3860934167237b395b0"
+        },
+        {
+            "key":"Mode",
+            "value":"embedded"
+        }
+    ]
 }
 </verbatim>

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/51c6eb20/prism/src/main/java/org/apache/falcon/resource/admin/AdminResource.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/admin/AdminResource.java b/prism/src/main/java/org/apache/falcon/resource/admin/AdminResource.java
index 03a9149..41fb1c7 100644
--- a/prism/src/main/java/org/apache/falcon/resource/admin/AdminResource.java
+++ b/prism/src/main/java/org/apache/falcon/resource/admin/AdminResource.java
@@ -64,15 +64,27 @@ public class AdminResource {
         return builder.toString();
     }
 
-    private String version;
+    private PropertyList version;
 
     @GET
     @Path("version")
-    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
-    public String getVersion() {
+    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
+    public PropertyList getVersion() {
         if (version == null) {
-            version = "{Version:\"" + BuildProperties.get().getProperty("build.version")
-                    + "\",Mode:\"" + DeploymentProperties.get().getProperty("deploy.mode")
+ "\"}";
+            List<Property> props = new ArrayList<Property>();
+
+            Property property = new Property();
+            property.key = "Version";
+            property.value = BuildProperties.get().getProperty("build.version");
+            props.add(property);
+
+            property = new Property();
+            property.key = "Mode";
+            property.value = DeploymentProperties.get().getProperty("deploy.mode");
+            props.add(property);
+
+            version = new PropertyList();
+            version.properties = props;
         }
         return version;
     }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/51c6eb20/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java b/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
index 3cebb60..767ff4b 100644
--- a/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
+++ b/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
+import java.util.regex.Pattern;
 
 import javax.servlet.ServletInputStream;
 import javax.ws.rs.core.MediaType;
@@ -345,11 +346,18 @@ public class EntityManagerJerseyIT {
         response = context.service
                 .path("api/admin/version")
                 .header("Remote-User", TestContext.REMOTE_USER)
-                .accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
-        String status = response.getEntity(String.class);
-        Assert.assertEquals(status, "{Version:\""
-                + BuildProperties.get().getProperty("build.version") + "\",Mode:\""
-                + DeploymentProperties.get().getProperty("deploy.mode") + "\"}");
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        String json = response.getEntity(String.class);
+        String buildVersion = BuildProperties.get().getProperty("build.version");
+        String deployMode = DeploymentProperties.get().getProperty("deploy.mode");
+        Assert.assertTrue(Pattern.matches(
+                ".*\\{\\s*\"key\"\\s*:\\s*\"Version\"\\s*,\\s*\"value\"\\s*:\\s*\""
+                        + buildVersion + "\"\\s*}.*", json),
+                "No build.version found in /api/admin/version");
+        Assert.assertTrue(Pattern.matches(
+                ".*\\{\\s*\"key\"\\s*:\\s*\"Mode\"\\s*,\\s*\"value\"\\s*:\\s*\""
+                        + deployMode + "\"\\s*}.*", json),
+                "No deploy.mode found in /api/admin/version");
     }
 
     @Test


Mime
View raw message