Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package blueprintservice
- import groovyx.net.http.HTTPBuilder
- import groovyx.net.http.RESTClient
- import static groovyx.net.http.ContentType.*
- this.metaClass.mixin(cucumber.api.groovy.Hooks)
- this.metaClass.mixin(cucumber.api.groovy.EN)
- def responceCode = ""
- Given(~/^An "([^"]*)" user opens the browser$/) { String user ->
- testUsername = user
- }
- Given(~/^provides "([^"]*)" password$/) { String password ->
- testPass = password
- }
- When(~/^he opens the "([^"]*)" link with path "([^"]*)"$/) { String url, String uri->
- testUrl = url
- testUri = uri
- }
- Then(~/^He will get a respond with status (\d+)$/) { int httpcode ->
- try {
- def http = new RESTClient(testUrl)
- http.auth.basic testUsername, testPass
- http.get(path: testUri ) { resp ->
- responceCode = resp.statusLine.statusCode
- assert httpcode == responceCode
- }
- } catch (groovyx.net.http.HttpResponseException ex) {
- responceCode = ex.getStatusCode()
- assert httpcode == responceCode
- }
- }
Advertisement