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]


With regards,
Apache Git Services

Reply via email to