You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2018/08/22 10:49:41 UTC
[sling-whiteboard] 01/02: Add importContent.feature
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit a5e08cc7b03bbd0cb827c0fb32a847187ba3dbab
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Aug 22 12:49:26 2018 +0200
Add importContent.feature
---
.../createcontent/createContent.feature | 2 +-
.../createcontent/importContent.feature | 50 ++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/literate-http-testing/karate/src/test/java/sling/postservlet/createcontent/createContent.feature b/literate-http-testing/karate/src/test/java/sling/postservlet/createcontent/createContent.feature
index 1a88cb8..44779a8 100644
--- a/literate-http-testing/karate/src/test/java/sling/postservlet/createcontent/createContent.feature
+++ b/literate-http-testing/karate/src/test/java/sling/postservlet/createcontent/createContent.feature
@@ -22,7 +22,7 @@ When method GET
Then status 200
# ------------------------------------------------------------------------
-# Scenario: Create a resource, update, read back, delete
+Scenario: Create a resource, update, read back, delete
# ------------------------------------------------------------------------
# Create a resource
diff --git a/literate-http-testing/karate/src/test/java/sling/postservlet/createcontent/importContent.feature b/literate-http-testing/karate/src/test/java/sling/postservlet/createcontent/importContent.feature
new file mode 100644
index 0000000..9ce9f03
--- /dev/null
+++ b/literate-http-testing/karate/src/test/java/sling/postservlet/createcontent/importContent.feature
@@ -0,0 +1,50 @@
+# ------------------------------------------------------------------------
+Feature: Import content using the Sling POST Servlet
+# ------------------------------------------------------------------------
+
+Background:
+* url baseURL
+
+# Use admin credentials for all requests
+* configure headers = call read('basic-auth-header.js') { username: 'admin', password: 'admin' }
+
+* def testID = '' + java.util.UUID.randomUUID()
+* def testFolderPath = 'importContentTest/' + testID
+
+# ------------------------------------------------------------------------
+Scenario: Create the parent folder, import JSON content, verify and delete
+# ------------------------------------------------------------------------
+
+* def newContent = { 'jcr:primaryType' : 'nt:unstructured', p1 : '#(testID)', p2: [ 'a', 'b', '#(testID)' ] }
+
+# Create parent folder
+Given path testFolderPath, testID
+And request ""
+When method POST
+Then status 201
+And def parentFolder = responseHeaders['Location'][0]
+
+# Import content
+Given path parentFolder
+And form field :operation = 'import'
+And form field :contentType = 'json'
+And form field :name = testID
+And form field :content = newContent
+When method POST
+Then status 201
+
+# Verify imported content
+Given path parentFolder, testID + ".json"
+When method GET
+Then status 200
+And match $ == newContent
+And match $.p2[2] == testID
+
+# Delete parent folder
+Given path testFolderPath, testID
+When method DELETE
+Then status 204
+
+Given path testFolderPath, testID
+When method GET
+Then status 404
\ No newline at end of file