Grails 3 functional test -
i trying upgrade application grails 2 grails 3. however, functional test working in grails 2 fails run now. in grails 2, use restbuilder send request , response. in grails 3, there no corresponding restbuilder release. how can send post , request in grails 3 functional test?
thanks much.
my test code in grails 2:
void testrequestnewenvironment() { setup: def rest = new restbuilder(connecttimeout:1000, readtimeout:20000) int timeout = 10 string environmentid = 0 string environmentstatus = "not ready" when: /** * postmethod. send out post , response status should 200 , body of response include env_id */ def resp = rest.post('http://localhost:8080/test-environment-manager/environment') { contenttype "multipart/form-data" buildfile= new file('script.sh') username = "apps" keepenvflag = "false" env_flavor = "default" } then: resp.getstatus() == 200 environmentid = resp.json.env_id println "environment id: $environmentid" println ("environment status"+resp.json.status)
i use restclient
executing http requests in grails functional tests. it's class httpbuilder library, should work in every grails version (because has dependency on grails).
some example usages shown here. before can use it, you'll need add dependency on library adding following build.gradle
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
Comments
Post a Comment