You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2018/03/24 16:28:00 UTC

[sling-org-apache-sling-launchpad-integration-tests] branch master updated: SLING-7553 - Test basic order of Patch add/remove

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-integration-tests.git


The following commit(s) were added to refs/heads/master by this push:
     new 8cd77e5  SLING-7553 - Test basic order of Patch add/remove
8cd77e5 is described below

commit 8cd77e52769fb9bf708321c41f882e84ce888a30
Author: John Logan <jo...@texture.com>
AuthorDate: Fri Mar 23 12:45:53 2018 -0700

    SLING-7553 - Test basic order of Patch add/remove
---
 .../servlets/post/PostServletPatchTest.java        | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPatchTest.java b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPatchTest.java
index 2249bc1..f750610 100644
--- a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPatchTest.java
+++ b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPatchTest.java
@@ -66,6 +66,43 @@ public class PostServletPatchTest extends HttpTestBase {
         assertJavascript("delta", content, "out.println(data.prop[4])");
     }
 
+    public void testEmptyPatch() throws Exception {
+        final NameValuePairList props = new NameValuePairList();
+
+        // 1. create multi-value property, adding and removing a value via Patch
+        //    to intentionally create an empty result
+        props.add("prop@TypeHint", "String[]");
+        props.add("prop@Patch", "true");
+        props.add("prop", "+dummy");
+        props.add("prop", "-dummy");
+
+        String location = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX,
+                props, null, false);
+        props.clear();
+
+        String content = getContent(location + ".json", CONTENT_TYPE_JSON);
+        assertJavascript("true", content, "out.println(data.prop.length == 0)");
+    }
+
+    public void testReversedEmptyPatch() throws Exception {
+        final NameValuePairList props = new NameValuePairList();
+
+        // 1. create multi-value property, removing and adding a value via Patch
+        //    to verify that the order of patches is significant
+        props.add("prop@TypeHint", "String[]");
+        props.add("prop@Patch", "true");
+        props.add("prop", "-dummy");
+        props.add("prop", "+dummy");
+
+        String location = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX,
+                props, null, false);
+        props.clear();
+
+        String content = getContent(location + ".json", CONTENT_TYPE_JSON);
+        assertJavascript("true", content, "out.println(data.prop.length == 1)");
+        assertJavascript("dummy", content, "out.println(data.prop[0])");
+    }
+
     public void testInvalidPatch() throws Exception {
         final NameValuePairList props = new NameValuePairList();
         

-- 
To stop receiving notification emails like this one, please contact
rombert@apache.org.