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 ae7fb07d76dae48065ab05a71c30f2de93df3f01 Author: Bertrand Delacretaz <[email protected]> AuthorDate: Tue Sep 4 15:44:25 2018 +0200 Test image upload --- .../src/test/java/images/testimage.jpg | Bin 0 -> 10102 bytes .../java/sling/filestorage/uploadImage.feature | 64 +++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/karate-http-testing/src/test/java/images/testimage.jpg b/karate-http-testing/src/test/java/images/testimage.jpg new file mode 100644 index 0000000..9dcb9e3 Binary files /dev/null and b/karate-http-testing/src/test/java/images/testimage.jpg differ diff --git a/karate-http-testing/src/test/java/sling/filestorage/uploadImage.feature b/karate-http-testing/src/test/java/sling/filestorage/uploadImage.feature new file mode 100644 index 0000000..9a1f1cd --- /dev/null +++ b/karate-http-testing/src/test/java/sling/filestorage/uploadImage.feature @@ -0,0 +1,64 @@ +# ------------------------------------------------------------------------ +Feature: Upload an image in Sling and check the result +# ------------------------------------------------------------------------ + +# ------------------------------------------------------------------------ +Background: +# ------------------------------------------------------------------------ + +* url baseURL + +# Use admin credentials for all requests +* configure headers = call read('classpath:sling/util/basic-auth-header.js') { username: 'admin', password: 'admin' } + +* def testID = '' + java.util.UUID.randomUUID() +* def testFolderPath = '/uploadImageTest/folder_' + testID +* def filename = 'file_' + testID + +# ------------------------------------------------------------------------ +Scenario: Check access to the Sling instance under test +# ------------------------------------------------------------------------ +Given path '/.json' +When method GET +Then status 200 + +# ------------------------------------------------------------------------ +Scenario: Upload an image, read back and check +# ------------------------------------------------------------------------ + +# Create a resource +Given path testFolderPath + '/*' +And multipart field file = read("classpath:images/testimage.jpg") +And multipart field name = filename +When method POST +Then status 201 + +# The Location header provides the path where the resource was created +* def imagePath = responseHeaders['Location'][0] + +# Read metadata back +Given path imagePath + '.tidy.5.json' +When method GET +Then status 200 +And match response.jcr:primaryType == 'nt:unstructured' +And match response.name == filename +And match response.file.jcr:primaryType == 'nt:resource' +And match response.file.jcr:mimeType == 'application/octet-stream' + +# Delete and verify that the resource is gone +Given path imagePath +When method DELETE +Then status 204 + +Given path imagePath +When method GET +Then status 404 + +# Cleanup test folder +Given path testFolderPath +When method DELETE +Then status 204 + +Given path testFolderPath +When method GET +Then status 404 \ No newline at end of file
