Testing Rest services 2.0

So I have run into more problems testing my restful services. However, it seems to stem from the fact that unit tests do not provide all the necessary tools for testing the services properly. Below is my new integration tests.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
    void testGETXMLResponse() {
        def controller = new UserController()
        controller.request.method = 'GET'
        controller.request.contentType = 'text/xml'
        controller.params.format = 'xml'
        controller.params.id = '1'
       
        controller.show()
       
        def getXMLUser = XML.parse(controller.response.contentAsString)
        assert getXMLUser.user.id == 1
        assert getXMLUser.user.username == "fred"
        assert getXMLUser.user.password == User.encrypt("letmein") 
    }

Posted in: REST, grails, groovy



This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

addLeave a comment

You must be logged in to post a comment.