[ 
https://issues.apache.org/jira/browse/SLING-7346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16312528#comment-16312528
 ] 

ASF GitHub Bot commented on SLING-7346:
---------------------------------------

bhardwajrahul20 closed pull request #2:  SLING-7346-Adding test case to 
showcase backward compatibility break
URL: https://github.com/apache/sling-org-apache-sling-servlets-post/pull/2
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/test/java/org/apache/sling/servlets/post/JsonResponseTest.java 
b/src/test/java/org/apache/sling/servlets/post/JsonResponseTest.java
index d591628..33b1687 100644
--- a/src/test/java/org/apache/sling/servlets/post/JsonResponseTest.java
+++ b/src/test/java/org/apache/sling/servlets/post/JsonResponseTest.java
@@ -107,6 +107,16 @@ public void testSend_3xx() throws Exception {
         }
     }
 
+    public void testSendWithJsonAsPropertyValue() throws Exception {
+        String testResponseJson = 
"{\"user\":\"testUser\",\"properties\":{\"id\":\"testId\", \"name\":\"test\"}}";
+        JsonObject customProperty = Json.createReader(new 
StringReader(testResponseJson)).readObject();
+        res.setProperty("response", customProperty);
+        MockResponseWithHeader response = new MockResponseWithHeader();
+        res.send(response, true);
+        JsonObject result = Json.createReader(new 
StringReader(response.getOutput().toString())).readObject();
+        assertProperty(result, "response", customProperty);
+    }
+
     public void testNoChangesOnError() throws Exception {
         res.onChange("modified", "argument1");
         res.setError(new Exception("some exception"));
@@ -127,6 +137,13 @@ private static JsonString assertProperty(JsonObject obj, 
String key, String expe
         return res;
     }
 
+    @SuppressWarnings({"unchecked"})
+    private static JsonObject assertProperty(JsonObject obj, String key, 
JsonObject expected) {
+        JsonObject res = (JsonObject) assertProperty(obj, key);
+        assertEquals(expected, res);
+        return res;
+    }
+
     @SuppressWarnings({"unchecked"})
     private static <T> T assertInstanceOf(Object obj, Class<T> clazz) {
         try {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Issues with custom fields in PostResponse as a result of fix for 
> SLING-6681(Replace commons.json usage in org.apache.sling.servlets.post)
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-7346
>                 URL: https://issues.apache.org/jira/browse/SLING-7346
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.3.22
>            Reporter: Rahul Bhardwaj
>            Assignee: Karl Pauls
>             Fix For: Servlets Post 2.3.24
>
>
> If you set a value of type as map as a custom property in response type, 
> instead of parsing properly, whole map is converted into one string and 
> therefore, json response does not reach client side in an orderly fashion.
> This can be attributed to [0] which was merged as part of fix for 
> SLING-6681(Replace commons.json usage in org.apache.sling.servlets.post)
> [0] 
> -https://github.com/apache/sling/commit/a598bd4f6e9fc4f967e118de705643a04a47bc44#diff-2ff02a567147f2cbef2e344d5338dd14R106



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to