Query Parameters in Integration Test

21 views
Skip to first unread message

Jason Rowland

unread,
May 16, 2013, 3:15:53 PM5/16/13
to grails-jax...@googlegroups.com
In the current grails-jaxrs code, it is not immediate obvious how you pass in query parameters in an Integration test.

Fails:
sendRequest('/api/test07?max=10', 'GET', ''.bytes)

Succeeds:
controller.request.queryString = 'max=10'
sendRequest('/api/test07', 'GET', ''.bytes)

If you modify the JaxRsIntegrationTestMixin.groovy file like follows, it will support the intuitive syntax that currently fails:


diff --git a/src/groovy/org/grails/jaxrs/itest/JaxRsIntegrationTestMixin.groovy b/src/groovy/org/grails/jaxrs/itest/JaxRsIntegrationTestMixin.groovy
index b96fdd5..f1a07b7 100644
--- a/src/groovy/org/grails/jaxrs/itest/JaxRsIntegrationTestMixin.groovy
+++ b/src/groovy/org/grails/jaxrs/itest/JaxRsIntegrationTestMixin.groovy
@@ -51,7 +51,9 @@ class JaxRsIntegrationTestMixin implements JaxRsIntegrationTest {
     HttpServletResponse sendRequest(String url, String method, Map<String, Object> headers, byte[] content = ''.bytes) {
         resetResponse()
 
-        requestUrl = url
+        URI uri = new URI(url)
+        controller.request.queryString = uri.query
+        requestUrl = uri.path
         requestMethod = method
         requestContent = content 

Noam Tenne

unread,
May 16, 2013, 4:23:07 PM5/16/13
to grails-jax...@googlegroups.com
Thanks much for the suggestion and contribution.
Can you please add this change as a pull request on the GitHub project? 

Cheers,
Noam

--
You received this message because you are subscribed to the Google Groups "grails-jaxrs-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-jaxrs-dis...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Noam Tenne

unread,
Jun 12, 2013, 9:56:33 AM6/12/13
to grails-jax...@googlegroups.com
Added to the master
Reply all
Reply to author
Forward
0 new messages