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 c71f0d6715586b099af01b40eae1720136c38f2a Author: Bertrand Delacretaz <[email protected]> AuthorDate: Thu Jul 26 16:48:08 2018 +0200 First Sling scenario --- .../createcontent/createContent.feature | 68 +++++++++------------- 1 file changed, 26 insertions(+), 42 deletions(-) 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 ddba1d0..e7bbc80 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 @@ -1,54 +1,38 @@ -Feature: sample karate test script - If you are using Eclipse, install the free Cucumber-Eclipse plugin from - https://cucumber.io/cucumber-eclipse/ - Then you will see syntax-coloring for this file. But best of all, - you will be able to right-click within this file and [Run As -> Cucumber Feature]. - If you see warnings like "does not have a matching glue code", - go to the Eclipse preferences, find the 'Cucumber User Settings' - and enter the following Root Package Name: com.intuit.karate - Refer to the Cucumber-Eclipse wiki for more: http://bit.ly/2mDaXeV +Feature: create content using the Sling POST Servlet Background: -* url 'https://jsonplaceholder.typicode.com' -Scenario: get all users and then get the first user by id +# TODO for now you need to start Sling manually +# TODO get this from the environment -Given path 'users' -When method get -Then status 200 +* url 'http://localhost:8080' -* def first = response[0] +# Use admin:admin credentials for all requests +* configure headers = { 'Authorization' : 'Basic YWRtaW46YWRtaW4=' } -Given path 'users', first.id +Scenario: get the root resource + +Given path '/.json' When method get Then status 200 -Scenario: create a user and then get it by id - -* def user = -""" -{ - "name": "Test User", - "username": "testuser", - "email": "[email protected]", - "address": { - "street": "Has No Name", - "suite": "Apt. 123", - "city": "Electri", - "zipcode": "54321-6789" - } -} -""" - -Given url 'https://jsonplaceholder.typicode.com/users' -And request user -When method post +Scenario: create a content resource and verify its output + +* def id = java.util.UUID.randomUUID() +* def title = 'Title for the First Resource at ' + id + +Given url 'http://localhost:8080/tmp/' + id +And form field title = title +And form field const = 'const42' +When method POST Then status 201 -* def id = response.id -* print 'created id is: ' + id +# TODO use a variable for the base URL + +* def location = 'http://localhost:8080' + responseHeaders['Location'][0] -Given path id -# When method get -# Then status 200 -# And match response contains user \ No newline at end of file +Given url location + '.json' +When method get +Then status 200 +Then match response.title == title +Then match response.const == 'const42' \ No newline at end of file
